Spaces:
Sleeping
Sleeping
Update vps_monitor.py
Browse files- vps_monitor.py +4 -4
vps_monitor.py
CHANGED
@@ -63,7 +63,7 @@ def check_and_run_script(config):
|
|
63 |
|
64 |
script_path = config['script_path']
|
65 |
script_name = os.path.basename(script_path)
|
66 |
-
key = f"{config['hostname']}:{script_name}"
|
67 |
|
68 |
check_command = f"ps aux | grep '{script_path}' | grep -v grep"
|
69 |
|
@@ -92,7 +92,7 @@ def check_and_run_script(config):
|
|
92 |
|
93 |
except Exception as e:
|
94 |
logger.error(f"Error occurred while checking VPS {config['index']} - {config['hostname']} - {script_name}: {str(e)}")
|
95 |
-
vps_status[f"{config['hostname']}:{script_name}"] = {
|
96 |
'index': config['index'],
|
97 |
'status': f"Error: {str(e)}",
|
98 |
'last_check': time.strftime('%Y-%m-%d %H:%M:%S'),
|
@@ -113,7 +113,7 @@ def check_all_vps():
|
|
113 |
table += "+---------+-----------------------+------------------+----------+-------------------------+----------+\n"
|
114 |
|
115 |
for key, status in vps_status.items():
|
116 |
-
hostname, script_name = key.split(':')
|
117 |
table += "| {:<7} | {:<21} | {:<16} | {:<8} | {:<23} | {:<8} |\n".format(
|
118 |
status['index'], hostname[:21], script_name[:16], status['status'][:8],
|
119 |
status['last_check'], status['username'][:8]
|
@@ -138,7 +138,7 @@ def index():
|
|
138 |
{% for key, data in vps_status.items() %}
|
139 |
<tr>
|
140 |
<td>{{ data.index }}</td>
|
141 |
-
<td><a href="/status/{{ key }}">{{ key.split(':')[
|
142 |
<td>{{ data.script_name }}</td>
|
143 |
<td>{{ data.status }}</td>
|
144 |
<td>{{ data.last_check }}</td>
|
|
|
63 |
|
64 |
script_path = config['script_path']
|
65 |
script_name = os.path.basename(script_path)
|
66 |
+
key = f"{config['index']}:{config['hostname']}:{script_name}"
|
67 |
|
68 |
check_command = f"ps aux | grep '{script_path}' | grep -v grep"
|
69 |
|
|
|
92 |
|
93 |
except Exception as e:
|
94 |
logger.error(f"Error occurred while checking VPS {config['index']} - {config['hostname']} - {script_name}: {str(e)}")
|
95 |
+
vps_status[f"{config['index']}:{config['hostname']}:{script_name}"] = {
|
96 |
'index': config['index'],
|
97 |
'status': f"Error: {str(e)}",
|
98 |
'last_check': time.strftime('%Y-%m-%d %H:%M:%S'),
|
|
|
113 |
table += "+---------+-----------------------+------------------+----------+-------------------------+----------+\n"
|
114 |
|
115 |
for key, status in vps_status.items():
|
116 |
+
index, hostname, script_name = key.split(':')
|
117 |
table += "| {:<7} | {:<21} | {:<16} | {:<8} | {:<23} | {:<8} |\n".format(
|
118 |
status['index'], hostname[:21], script_name[:16], status['status'][:8],
|
119 |
status['last_check'], status['username'][:8]
|
|
|
138 |
{% for key, data in vps_status.items() %}
|
139 |
<tr>
|
140 |
<td>{{ data.index }}</td>
|
141 |
+
<td><a href="/status/{{ key }}">{{ key.split(':')[1] }}</a></td>
|
142 |
<td>{{ data.script_name }}</td>
|
143 |
<td>{{ data.status }}</td>
|
144 |
<td>{{ data.last_check }}</td>
|