gyc12 commited on
Commit
79ec395
·
verified ·
1 Parent(s): cb79ab2

Update vps_monitor.py

Browse files
Files changed (1) hide show
  1. vps_monitor.py +20 -6
vps_monitor.py CHANGED
@@ -148,15 +148,29 @@ def check_and_run_script(config):
148
 
149
  def check_all_vps():
150
  logger.info("Starting VPS check")
151
- print("Starting VPS check")
152
- sys.stdout.flush()
153
  vps_configs = get_vps_configs()
154
  for config in vps_configs:
155
  check_and_run_script(config)
156
- logger.info("Finished VPS check")
157
- for hostname, status in vps_status.items():
158
- print(f"VPS {status['index']} - {hostname}: Status: {status['status']}, Username: {status['username']}")
159
- sys.stdout.flush()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
160
 
161
  @app.route('/')
162
  def index():
 
148
 
149
  def check_all_vps():
150
  logger.info("Starting VPS check")
 
 
151
  vps_configs = get_vps_configs()
152
  for config in vps_configs:
153
  check_and_run_script(config)
154
+
155
+ # 创建表格头
156
+ table = "+---------+-----------------------+----------+-------------------------+----------+\n"
157
+ table += "| Index | Hostname | Status | Last Check | Username |\n"
158
+ table += "+---------+-----------------------+----------+-------------------------+----------+\n"
159
+
160
+ # 添加每个VPS的状态
161
+ for index in sorted(vps_status.keys()):
162
+ status = vps_status[index]
163
+ table += "| {:<7} | {:<21} | {:<8} | {:<23} | {:<8} |\n".format(
164
+ status['index'],
165
+ status['hostname'][:21],
166
+ status['status'][:8],
167
+ status['last_check'],
168
+ status['username'][:8]
169
+ )
170
+ table += "+---------+-----------------------+----------+-------------------------+----------+\n"
171
+
172
+ logger.info("\n" + table)
173
+
174
 
175
  @app.route('/')
176
  def index():