sciveo 0.0.28__tar.gz → 0.0.30__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.0.28 → sciveo-0.0.30}/PKG-INFO +1 -1
- {sciveo-0.0.28 → sciveo-0.0.30}/sciveo/api/base.py +1 -1
- {sciveo-0.0.28 → sciveo-0.0.30}/sciveo/common/tools/hardware.py +16 -0
- {sciveo-0.0.28 → sciveo-0.0.30}/sciveo/monitoring/monitor.py +49 -2
- sciveo-0.0.30/sciveo/version.py +2 -0
- {sciveo-0.0.28 → sciveo-0.0.30}/sciveo.egg-info/PKG-INFO +1 -1
- sciveo-0.0.28/sciveo/version.py +0 -2
- {sciveo-0.0.28 → sciveo-0.0.30}/README.md +0 -0
- {sciveo-0.0.28 → sciveo-0.0.30}/sciveo/__init__.py +0 -0
- {sciveo-0.0.28 → sciveo-0.0.30}/sciveo/api/__init__.py +0 -0
- {sciveo-0.0.28 → sciveo-0.0.30}/sciveo/api/upload.py +0 -0
- {sciveo-0.0.28 → sciveo-0.0.30}/sciveo/common/__init__.py +0 -0
- {sciveo-0.0.28 → sciveo-0.0.30}/sciveo/common/configuration.py +0 -0
- {sciveo-0.0.28 → sciveo-0.0.30}/sciveo/common/model.py +0 -0
- {sciveo-0.0.28 → sciveo-0.0.30}/sciveo/common/optimizers.py +0 -0
- {sciveo-0.0.28 → sciveo-0.0.30}/sciveo/common/sampling.py +0 -0
- {sciveo-0.0.28 → sciveo-0.0.30}/sciveo/common/tools/__init__.py +0 -0
- {sciveo-0.0.28 → sciveo-0.0.30}/sciveo/common/tools/daemon.py +0 -0
- {sciveo-0.0.28 → sciveo-0.0.30}/sciveo/common/tools/formating.py +0 -0
- {sciveo-0.0.28 → sciveo-0.0.30}/sciveo/common/tools/logger.py +0 -0
- {sciveo-0.0.28 → sciveo-0.0.30}/sciveo/common/tools/synchronized.py +0 -0
- {sciveo-0.0.28 → sciveo-0.0.30}/sciveo/content/__init__.py +0 -0
- {sciveo-0.0.28 → sciveo-0.0.30}/sciveo/content/dataset.py +0 -0
- {sciveo-0.0.28 → sciveo-0.0.30}/sciveo/content/experiment.py +0 -0
- {sciveo-0.0.28 → sciveo-0.0.30}/sciveo/content/project.py +0 -0
- {sciveo-0.0.28 → sciveo-0.0.30}/sciveo/content/runner.py +0 -0
- {sciveo-0.0.28 → sciveo-0.0.30}/sciveo/monitoring/__init__.py +0 -0
- {sciveo-0.0.28 → sciveo-0.0.30}/sciveo.egg-info/SOURCES.txt +0 -0
- {sciveo-0.0.28 → sciveo-0.0.30}/sciveo.egg-info/dependency_links.txt +0 -0
- {sciveo-0.0.28 → sciveo-0.0.30}/sciveo.egg-info/requires.txt +0 -0
- {sciveo-0.0.28 → sciveo-0.0.30}/sciveo.egg-info/top_level.txt +0 -0
- {sciveo-0.0.28 → sciveo-0.0.30}/setup.cfg +0 -0
- {sciveo-0.0.28 → sciveo-0.0.30}/setup.py +0 -0
- {sciveo-0.0.28 → sciveo-0.0.30}/test/test_configuration.py +0 -0
- {sciveo-0.0.28 → sciveo-0.0.30}/test/test_runner.py +0 -0
- {sciveo-0.0.28 → sciveo-0.0.30}/test/test_sampling.py +0 -0
|
@@ -22,7 +22,7 @@ class APIRemoteClient:
|
|
|
22
22
|
if base_url is None:
|
|
23
23
|
base_url = os.environ.get("SCIVEO_API_BASE_URL", "https://sciveo.com")
|
|
24
24
|
self.base_url = f"{base_url}/api/v{ver}/"
|
|
25
|
-
self.headers = { "Auth-Token": os.environ
|
|
25
|
+
self.headers = { "Auth-Token": os.environ.get('SCIVEO_SECRET_ACCESS_KEY', "") }
|
|
26
26
|
debug(type(self).__name__, f"base url: {self.base_url}")
|
|
27
27
|
|
|
28
28
|
def POST_SCI(self, content_type, data, timeout=30):
|
|
@@ -10,9 +10,25 @@
|
|
|
10
10
|
#
|
|
11
11
|
|
|
12
12
|
import os
|
|
13
|
+
import datetime
|
|
14
|
+
import uuid
|
|
15
|
+
import random
|
|
16
|
+
import string
|
|
13
17
|
|
|
14
18
|
from sciveo.common.tools.formating import format_memory_size
|
|
15
19
|
|
|
20
|
+
|
|
21
|
+
def new_guid_uuid():
|
|
22
|
+
return datetime.datetime.now().strftime("%Y%m%d%H%M%S") + "-" + str(uuid.uuid4()).replace("-", "")
|
|
23
|
+
|
|
24
|
+
def random_token(num_characters):
|
|
25
|
+
characters = string.ascii_letters + string.digits
|
|
26
|
+
return ''.join(random.choices(characters, k=num_characters))
|
|
27
|
+
|
|
28
|
+
def new_guid(num_characters=32):
|
|
29
|
+
return datetime.datetime.now().strftime("%Y%m%d%H%M%S") + "-" + random_token(num_characters)
|
|
30
|
+
|
|
31
|
+
|
|
16
32
|
class HardwareInfo:
|
|
17
33
|
def __init__(self):
|
|
18
34
|
self.data = {
|
|
@@ -11,12 +11,14 @@
|
|
|
11
11
|
|
|
12
12
|
import os
|
|
13
13
|
import time
|
|
14
|
+
import datetime
|
|
15
|
+
import socket
|
|
14
16
|
import psutil
|
|
15
17
|
import numpy as np
|
|
16
18
|
|
|
17
19
|
from sciveo.common.tools.logger import *
|
|
18
20
|
from sciveo.common.tools.daemon import DaemonBase
|
|
19
|
-
from sciveo.common.tools.hardware import
|
|
21
|
+
from sciveo.common.tools.hardware import *
|
|
20
22
|
from sciveo.common.tools.formating import format_memory_size
|
|
21
23
|
from sciveo.api.base import APIRemoteClient
|
|
22
24
|
|
|
@@ -24,12 +26,18 @@ from sciveo.api.base import APIRemoteClient
|
|
|
24
26
|
class BaseMonitor(DaemonBase):
|
|
25
27
|
def __init__(self, period=5):
|
|
26
28
|
super().__init__(period=period)
|
|
29
|
+
|
|
27
30
|
self.data = HardwareInfo()()
|
|
28
31
|
self.data.setdefault("CPU", {})
|
|
29
32
|
self.data["RAM"] = {
|
|
30
33
|
"installed": self.data["RAM"]
|
|
31
34
|
}
|
|
32
35
|
psutil.cpu_percent(interval=0.5)
|
|
36
|
+
self.getserial()
|
|
37
|
+
|
|
38
|
+
self.data["logs"] = {}
|
|
39
|
+
self.list_logs = []
|
|
40
|
+
|
|
33
41
|
self.api = APIRemoteClient()
|
|
34
42
|
|
|
35
43
|
def __call__(self):
|
|
@@ -38,7 +46,17 @@ class BaseMonitor(DaemonBase):
|
|
|
38
46
|
def loop(self):
|
|
39
47
|
self.get_cpu_usage()
|
|
40
48
|
self.get_memory()
|
|
41
|
-
|
|
49
|
+
|
|
50
|
+
self.tail_logs()
|
|
51
|
+
self.data["local_time"] = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
|
52
|
+
|
|
53
|
+
api_result = self.api.POST_SCI("monitor", {"data": self.data})
|
|
54
|
+
|
|
55
|
+
debug(type(self).__name__, self(), "api_result", api_result)
|
|
56
|
+
|
|
57
|
+
def tail_logs(self):
|
|
58
|
+
for log_name, log_path in self.list_logs:
|
|
59
|
+
self.data["logs"][log_name] = self.tail_file(log_path)[-3:]
|
|
42
60
|
|
|
43
61
|
def get_cpu_usage(self):
|
|
44
62
|
self.data["CPU"]["usage_per_core"] = psutil.cpu_percent(interval=None, percpu=True)
|
|
@@ -52,6 +70,35 @@ class BaseMonitor(DaemonBase):
|
|
|
52
70
|
self.data["RAM"]["free"] = memory.free
|
|
53
71
|
self.data["RAM"]["print"] = f"total: {format_memory_size(memory.total)} used: {format_memory_size(memory.used)}"
|
|
54
72
|
|
|
73
|
+
def getserial(self):
|
|
74
|
+
cpuserial = None
|
|
75
|
+
try:
|
|
76
|
+
with open('/proc/cpuinfo','r') as fp:
|
|
77
|
+
for line in fp:
|
|
78
|
+
if line.startswith('Serial'):
|
|
79
|
+
cpuserial = line[10:26]
|
|
80
|
+
except Exception:
|
|
81
|
+
pass
|
|
82
|
+
if cpuserial is None:
|
|
83
|
+
try:
|
|
84
|
+
cpuserial = socket.gethostname()
|
|
85
|
+
except Exception:
|
|
86
|
+
pass
|
|
87
|
+
if cpuserial is None:
|
|
88
|
+
cpuserial = f"RND-{random_token(8)}"
|
|
89
|
+
self.data["serial"] = cpuserial
|
|
90
|
+
return cpuserial
|
|
91
|
+
|
|
92
|
+
def tail_file(self, file_path, block_size=1024):
|
|
93
|
+
result = ["EMPTY"]
|
|
94
|
+
try:
|
|
95
|
+
with open(file_path,'rb') as fp:
|
|
96
|
+
fp.seek(-block_size, os.SEEK_END)
|
|
97
|
+
result = str(fp.read(block_size).rstrip()).split("\\n")
|
|
98
|
+
except Exception as e:
|
|
99
|
+
error(e, "tail_file", file_path)
|
|
100
|
+
return result
|
|
101
|
+
|
|
55
102
|
|
|
56
103
|
if __name__ == "__main__":
|
|
57
104
|
mon = BaseMonitor(period=10)
|
sciveo-0.0.28/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
|