sciveo 0.1.6__tar.gz → 0.1.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {sciveo-0.1.6 → sciveo-0.1.7}/PKG-INFO +1 -1
- {sciveo-0.1.6 → sciveo-0.1.7}/sciveo/monitoring/monitor.py +13 -9
- {sciveo-0.1.6 → sciveo-0.1.7}/sciveo/monitoring/network.py +47 -3
- sciveo-0.1.7/sciveo/version.py +2 -0
- {sciveo-0.1.6 → sciveo-0.1.7}/sciveo.egg-info/PKG-INFO +1 -1
- sciveo-0.1.6/sciveo/version.py +0 -2
- {sciveo-0.1.6 → sciveo-0.1.7}/README.md +0 -0
- {sciveo-0.1.6 → sciveo-0.1.7}/sciveo/__init__.py +0 -0
- {sciveo-0.1.6 → sciveo-0.1.7}/sciveo/api/__init__.py +0 -0
- {sciveo-0.1.6 → sciveo-0.1.7}/sciveo/api/base.py +0 -0
- {sciveo-0.1.6 → sciveo-0.1.7}/sciveo/api/upload.py +0 -0
- {sciveo-0.1.6 → sciveo-0.1.7}/sciveo/common/__init__.py +0 -0
- {sciveo-0.1.6 → sciveo-0.1.7}/sciveo/common/configuration.py +0 -0
- {sciveo-0.1.6 → sciveo-0.1.7}/sciveo/common/model.py +0 -0
- {sciveo-0.1.6 → sciveo-0.1.7}/sciveo/common/optimizers.py +0 -0
- {sciveo-0.1.6 → sciveo-0.1.7}/sciveo/common/sampling.py +0 -0
- {sciveo-0.1.6 → sciveo-0.1.7}/sciveo/common/tools/__init__.py +0 -0
- {sciveo-0.1.6 → sciveo-0.1.7}/sciveo/common/tools/daemon.py +0 -0
- {sciveo-0.1.6 → sciveo-0.1.7}/sciveo/common/tools/formating.py +0 -0
- {sciveo-0.1.6 → sciveo-0.1.7}/sciveo/common/tools/hardware.py +0 -0
- {sciveo-0.1.6 → sciveo-0.1.7}/sciveo/common/tools/logger.py +0 -0
- {sciveo-0.1.6 → sciveo-0.1.7}/sciveo/common/tools/synchronized.py +0 -0
- {sciveo-0.1.6 → sciveo-0.1.7}/sciveo/common/tools/timers.py +0 -0
- {sciveo-0.1.6 → sciveo-0.1.7}/sciveo/content/__init__.py +0 -0
- {sciveo-0.1.6 → sciveo-0.1.7}/sciveo/content/dataset.py +0 -0
- {sciveo-0.1.6 → sciveo-0.1.7}/sciveo/content/experiment.py +0 -0
- {sciveo-0.1.6 → sciveo-0.1.7}/sciveo/content/project.py +0 -0
- {sciveo-0.1.6 → sciveo-0.1.7}/sciveo/content/runner.py +0 -0
- {sciveo-0.1.6 → sciveo-0.1.7}/sciveo/monitoring/__init__.py +0 -0
- {sciveo-0.1.6 → sciveo-0.1.7}/sciveo/monitoring/start.py +0 -0
- {sciveo-0.1.6 → sciveo-0.1.7}/sciveo.egg-info/SOURCES.txt +0 -0
- {sciveo-0.1.6 → sciveo-0.1.7}/sciveo.egg-info/dependency_links.txt +0 -0
- {sciveo-0.1.6 → sciveo-0.1.7}/sciveo.egg-info/requires.txt +0 -0
- {sciveo-0.1.6 → sciveo-0.1.7}/sciveo.egg-info/top_level.txt +0 -0
- {sciveo-0.1.6 → sciveo-0.1.7}/setup.cfg +0 -0
- {sciveo-0.1.6 → sciveo-0.1.7}/setup.py +0 -0
- {sciveo-0.1.6 → sciveo-0.1.7}/test/test_configuration.py +0 -0
- {sciveo-0.1.6 → sciveo-0.1.7}/test/test_monitoring.py +0 -0
- {sciveo-0.1.6 → sciveo-0.1.7}/test/test_runner.py +0 -0
- {sciveo-0.1.6 → sciveo-0.1.7}/test/test_sampling.py +0 -0
|
@@ -46,13 +46,17 @@ class BaseMonitor(DaemonBase):
|
|
|
46
46
|
def __init__(self, period=5):
|
|
47
47
|
super().__init__(period=period)
|
|
48
48
|
|
|
49
|
-
self.data =
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
49
|
+
self.data = {
|
|
50
|
+
"CPU": {},
|
|
51
|
+
"RAM": {},
|
|
52
|
+
"DISK": {},
|
|
53
|
+
"NET": {},
|
|
54
|
+
"TEMP": {},
|
|
55
|
+
"LOG": {},
|
|
56
|
+
"INFO": {},
|
|
57
|
+
}
|
|
58
|
+
self.data["INFO"] = HardwareInfo()()
|
|
59
|
+
self.data["INFO"].setdefault("CPU", {})
|
|
56
60
|
self.list_logs = []
|
|
57
61
|
|
|
58
62
|
self.api = APIRemoteClient()
|
|
@@ -116,7 +120,7 @@ class BaseMonitor(DaemonBase):
|
|
|
116
120
|
self.data["RAM"]["total"] = memory.total
|
|
117
121
|
self.data["RAM"]["free"] = memory.free
|
|
118
122
|
# self.data["RAM"]["installed"] = format_memory_size(memory.total)
|
|
119
|
-
self.data["
|
|
123
|
+
self.data["INFO"]["RAM"] = f"total: {format_memory_size(memory.total)} used: {format_memory_size(memory.used)}"
|
|
120
124
|
except Exception:
|
|
121
125
|
pass
|
|
122
126
|
|
|
@@ -156,7 +160,7 @@ class BaseMonitor(DaemonBase):
|
|
|
156
160
|
self.get_io_metrics("DISK", list_metrics, disk_io_counters)
|
|
157
161
|
|
|
158
162
|
disk_usage = psutil.disk_usage('/')._asdict()
|
|
159
|
-
self.data["
|
|
163
|
+
self.data["INFO"]["DISK"] = f"{disk_usage['percent']}% ({round(disk_usage['used'] / (1024 * 1024 * 1024), 1)} GB / {round(disk_usage['total'] / (1024 * 1024 * 1024), 1)} GB)"
|
|
160
164
|
except Exception as e:
|
|
161
165
|
pass
|
|
162
166
|
|
|
@@ -10,11 +10,41 @@
|
|
|
10
10
|
#
|
|
11
11
|
|
|
12
12
|
import socket
|
|
13
|
+
import asyncio
|
|
13
14
|
|
|
14
15
|
from sciveo.common.tools.logger import *
|
|
15
16
|
from sciveo.common.tools.timers import Timer
|
|
16
17
|
|
|
17
18
|
|
|
19
|
+
class NetworkScanner:
|
|
20
|
+
def __init__(self, timeout=1.0):
|
|
21
|
+
self.timeout = timeout
|
|
22
|
+
|
|
23
|
+
async def scan_port(self, ip, port):
|
|
24
|
+
try:
|
|
25
|
+
reader, writer = await asyncio.wait_for(asyncio.open_connection(ip, port), timeout=self.timeout)
|
|
26
|
+
writer.close()
|
|
27
|
+
await writer.wait_closed()
|
|
28
|
+
return (ip, port)
|
|
29
|
+
except Exception as e:
|
|
30
|
+
# print("Exception", e)
|
|
31
|
+
return None
|
|
32
|
+
|
|
33
|
+
async def scan_all_ports(self, ip, ports):
|
|
34
|
+
tasks = [self.scan_port(ip, port) for port in ports]
|
|
35
|
+
return await asyncio.gather(*tasks)
|
|
36
|
+
|
|
37
|
+
async def scan_async(self, ips, ports):
|
|
38
|
+
results = []
|
|
39
|
+
for ip in ips:
|
|
40
|
+
results.extend(await self.scan_all_ports(ip, ports))
|
|
41
|
+
results = [x for x in results if x is not None]
|
|
42
|
+
return results
|
|
43
|
+
|
|
44
|
+
def scan(self, ips, ports):
|
|
45
|
+
return asyncio.run(self.scan_async(ips, ports))
|
|
46
|
+
|
|
47
|
+
|
|
18
48
|
class NetworkTools:
|
|
19
49
|
def __init__(self, **kwargs):
|
|
20
50
|
self.default_arguments = {
|
|
@@ -81,6 +111,20 @@ class NetworkTools:
|
|
|
81
111
|
|
|
82
112
|
|
|
83
113
|
if __name__ == "__main__":
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
114
|
+
t1 = Timer()
|
|
115
|
+
net = NetworkTools(timeout=0.5, localhost=True)
|
|
116
|
+
result = net.scan_port(port=22)
|
|
117
|
+
t1 = t1.stop()
|
|
118
|
+
print(result, "elapsed", t1)
|
|
119
|
+
|
|
120
|
+
t2 = Timer()
|
|
121
|
+
list_local_ips = net.get_local_nets()
|
|
122
|
+
list_scan_ips = []
|
|
123
|
+
for local_ip in list_local_ips:
|
|
124
|
+
list_scan_ips += net.generate_ip_list(local_ip)
|
|
125
|
+
# print(list_scan_ips)
|
|
126
|
+
ns = NetworkScanner(timeout=0.5)
|
|
127
|
+
result = ns.scan(list_scan_ips, [22])
|
|
128
|
+
t2 = t2.stop()
|
|
129
|
+
print(result, "elapsed", t2)
|
|
130
|
+
print("elapsed", t1, t2, t1 - t2)
|
sciveo-0.1.6/sciveo/version.py
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|