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.
Files changed (40) hide show
  1. {sciveo-0.1.6 → sciveo-0.1.7}/PKG-INFO +1 -1
  2. {sciveo-0.1.6 → sciveo-0.1.7}/sciveo/monitoring/monitor.py +13 -9
  3. {sciveo-0.1.6 → sciveo-0.1.7}/sciveo/monitoring/network.py +47 -3
  4. sciveo-0.1.7/sciveo/version.py +2 -0
  5. {sciveo-0.1.6 → sciveo-0.1.7}/sciveo.egg-info/PKG-INFO +1 -1
  6. sciveo-0.1.6/sciveo/version.py +0 -2
  7. {sciveo-0.1.6 → sciveo-0.1.7}/README.md +0 -0
  8. {sciveo-0.1.6 → sciveo-0.1.7}/sciveo/__init__.py +0 -0
  9. {sciveo-0.1.6 → sciveo-0.1.7}/sciveo/api/__init__.py +0 -0
  10. {sciveo-0.1.6 → sciveo-0.1.7}/sciveo/api/base.py +0 -0
  11. {sciveo-0.1.6 → sciveo-0.1.7}/sciveo/api/upload.py +0 -0
  12. {sciveo-0.1.6 → sciveo-0.1.7}/sciveo/common/__init__.py +0 -0
  13. {sciveo-0.1.6 → sciveo-0.1.7}/sciveo/common/configuration.py +0 -0
  14. {sciveo-0.1.6 → sciveo-0.1.7}/sciveo/common/model.py +0 -0
  15. {sciveo-0.1.6 → sciveo-0.1.7}/sciveo/common/optimizers.py +0 -0
  16. {sciveo-0.1.6 → sciveo-0.1.7}/sciveo/common/sampling.py +0 -0
  17. {sciveo-0.1.6 → sciveo-0.1.7}/sciveo/common/tools/__init__.py +0 -0
  18. {sciveo-0.1.6 → sciveo-0.1.7}/sciveo/common/tools/daemon.py +0 -0
  19. {sciveo-0.1.6 → sciveo-0.1.7}/sciveo/common/tools/formating.py +0 -0
  20. {sciveo-0.1.6 → sciveo-0.1.7}/sciveo/common/tools/hardware.py +0 -0
  21. {sciveo-0.1.6 → sciveo-0.1.7}/sciveo/common/tools/logger.py +0 -0
  22. {sciveo-0.1.6 → sciveo-0.1.7}/sciveo/common/tools/synchronized.py +0 -0
  23. {sciveo-0.1.6 → sciveo-0.1.7}/sciveo/common/tools/timers.py +0 -0
  24. {sciveo-0.1.6 → sciveo-0.1.7}/sciveo/content/__init__.py +0 -0
  25. {sciveo-0.1.6 → sciveo-0.1.7}/sciveo/content/dataset.py +0 -0
  26. {sciveo-0.1.6 → sciveo-0.1.7}/sciveo/content/experiment.py +0 -0
  27. {sciveo-0.1.6 → sciveo-0.1.7}/sciveo/content/project.py +0 -0
  28. {sciveo-0.1.6 → sciveo-0.1.7}/sciveo/content/runner.py +0 -0
  29. {sciveo-0.1.6 → sciveo-0.1.7}/sciveo/monitoring/__init__.py +0 -0
  30. {sciveo-0.1.6 → sciveo-0.1.7}/sciveo/monitoring/start.py +0 -0
  31. {sciveo-0.1.6 → sciveo-0.1.7}/sciveo.egg-info/SOURCES.txt +0 -0
  32. {sciveo-0.1.6 → sciveo-0.1.7}/sciveo.egg-info/dependency_links.txt +0 -0
  33. {sciveo-0.1.6 → sciveo-0.1.7}/sciveo.egg-info/requires.txt +0 -0
  34. {sciveo-0.1.6 → sciveo-0.1.7}/sciveo.egg-info/top_level.txt +0 -0
  35. {sciveo-0.1.6 → sciveo-0.1.7}/setup.cfg +0 -0
  36. {sciveo-0.1.6 → sciveo-0.1.7}/setup.py +0 -0
  37. {sciveo-0.1.6 → sciveo-0.1.7}/test/test_configuration.py +0 -0
  38. {sciveo-0.1.6 → sciveo-0.1.7}/test/test_monitoring.py +0 -0
  39. {sciveo-0.1.6 → sciveo-0.1.7}/test/test_runner.py +0 -0
  40. {sciveo-0.1.6 → sciveo-0.1.7}/test/test_sampling.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sciveo
3
- Version: 0.1.6
3
+ Version: 0.1.7
4
4
  Description-Content-Type: text/markdown
5
5
  Provides-Extra: mon
6
6
  Provides-Extra: net
@@ -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 = HardwareInfo()()
50
- self.data.setdefault("CPU", {})
51
- self.data.setdefault("DISK", {})
52
- self.data.setdefault("NET", {})
53
- self.data.setdefault("TEMP", {})
54
- self.data["RAM"] = {}
55
- self.data["LOG"] = {}
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["RAM"]["print"] = f"total: {format_memory_size(memory.total)} used: {format_memory_size(memory.used)}"
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["DISK"]["print"] = f"{disk_usage['percent']}% ({round(disk_usage['used'] / (1024 * 1024 * 1024), 1)} GB / {round(disk_usage['total'] / (1024 * 1024 * 1024), 1)} GB)"
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
- net = NetworkTools(timeout=0.01, localhost=True)
85
- list_hosts = net.scan_port(port=22)
86
- print(list_hosts)
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)
@@ -0,0 +1,2 @@
1
+
2
+ __version__ = '0.1.7'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sciveo
3
- Version: 0.1.6
3
+ Version: 0.1.7
4
4
  Description-Content-Type: text/markdown
5
5
  Provides-Extra: mon
6
6
  Provides-Extra: net
@@ -1,2 +0,0 @@
1
-
2
- __version__ = '0.1.6'
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