mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
adding memory percent
This commit is contained in:
parent
7d91c9b636
commit
637407cc78
@ -42,6 +42,7 @@ class Stats:
|
|||||||
process_stats = {
|
process_stats = {
|
||||||
'cpu_usage': 0,
|
'cpu_usage': 0,
|
||||||
'memory_usage': 0,
|
'memory_usage': 0,
|
||||||
|
'mem_percentage': 0
|
||||||
}
|
}
|
||||||
return process_stats
|
return process_stats
|
||||||
|
|
||||||
@ -61,6 +62,7 @@ class Stats:
|
|||||||
process_stats = {
|
process_stats = {
|
||||||
'cpu_usage': real_cpu,
|
'cpu_usage': real_cpu,
|
||||||
'memory_usage': helper.human_readable_file_size(p.memory_info()[0]),
|
'memory_usage': helper.human_readable_file_size(p.memory_info()[0]),
|
||||||
|
'mem_percentage': round(p.memory_percent(), 0)
|
||||||
}
|
}
|
||||||
return process_stats
|
return process_stats
|
||||||
|
|
||||||
@ -192,8 +194,9 @@ class Stats:
|
|||||||
'id': server_id,
|
'id': server_id,
|
||||||
'started': server_obj.get_start_time(),
|
'started': server_obj.get_start_time(),
|
||||||
'running': server_obj.check_running(),
|
'running': server_obj.check_running(),
|
||||||
'cpu': p_stats.get('cpu_usage', '0'),
|
'cpu': p_stats.get('cpu_usage', 0),
|
||||||
'mem': p_stats.get('memory_usage', '0'),
|
'mem': p_stats.get('memory_usage', 0),
|
||||||
|
"mem_percent": p_stats.get('mem_percentage', 0),
|
||||||
'world_name': world_name,
|
'world_name': world_name,
|
||||||
'world_size': self.get_world_size(world_path),
|
'world_size': self.get_world_size(world_path),
|
||||||
'server_port': server_port,
|
'server_port': server_port,
|
||||||
@ -208,7 +211,6 @@ class Stats:
|
|||||||
# add this servers data to the stack
|
# add this servers data to the stack
|
||||||
server_stats_list.append(server_stats)
|
server_stats_list.append(server_stats)
|
||||||
|
|
||||||
|
|
||||||
return server_stats_list
|
return server_stats_list
|
||||||
|
|
||||||
def record_stats(self):
|
def record_stats(self):
|
||||||
@ -234,9 +236,10 @@ class Stats:
|
|||||||
Server_Stats.insert({
|
Server_Stats.insert({
|
||||||
Server_Stats.server_id: server.get('id', 0),
|
Server_Stats.server_id: server.get('id', 0),
|
||||||
Server_Stats.started: server.get('started', ""),
|
Server_Stats.started: server.get('started', ""),
|
||||||
Server_Stats.running: server.get('running', ""),
|
Server_Stats.running: server.get('running', False),
|
||||||
Server_Stats.cpu: server.get('cpu', ""),
|
Server_Stats.cpu: server.get('cpu', 0),
|
||||||
Server_Stats.mem: server.get('mem', ""),
|
Server_Stats.mem: server.get('mem', 0),
|
||||||
|
Server_Stats.mem_percent: server.get('mem_percent', 0),
|
||||||
Server_Stats.world_name: server.get('world_name', ""),
|
Server_Stats.world_name: server.get('world_name', ""),
|
||||||
Server_Stats.world_size: server.get('world_size', ""),
|
Server_Stats.world_size: server.get('world_size', ""),
|
||||||
Server_Stats.server_port: server.get('server_port', ""),
|
Server_Stats.server_port: server.get('server_port', ""),
|
||||||
|
@ -89,6 +89,7 @@ class Server_Stats(BaseModel):
|
|||||||
running = BooleanField(default=False)
|
running = BooleanField(default=False)
|
||||||
cpu = FloatField(default=0)
|
cpu = FloatField(default=0)
|
||||||
mem = FloatField(default=0)
|
mem = FloatField(default=0)
|
||||||
|
mem_percent = FloatField(default=0)
|
||||||
world_name = CharField(default="")
|
world_name = CharField(default="")
|
||||||
world_size = CharField(default="")
|
world_size = CharField(default="")
|
||||||
server_port = IntegerField(default=25565)
|
server_port = IntegerField(default=25565)
|
||||||
|
@ -127,13 +127,14 @@
|
|||||||
<div class="progress-bar bg-success" role="progressbar" style="width: {{server['cpu']}}%" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div>
|
<div class="progress-bar bg-success" role="progressbar" style="width: {{server['cpu']}}%" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
{{server['cpu']}}
|
{{server['cpu']}}%
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
<div class="progress" data-toggle="tooltip" data-placement="top" title="{{server['mem']}}">
|
<div class="progress" data-toggle="tooltip" data-placement="top" title="{{server['mem']}}">
|
||||||
<div class="progress-bar bg-danger" role="progressbar" style="{{server['mem']}}%" aria-valuenow="24" aria-valuemin="0" aria-valuemax="100"></div>
|
<div class="progress-bar bg-success" role="progressbar" style="width: {{server['mem_percent']}}%" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div>
|
||||||
</div>
|
</div>
|
||||||
|
{{server['mem_percent']}}% - {{server['mem']}}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{{ server['world_name'] }} : {{ server['world_size'] }}
|
{{ server['world_name'] }} : {{ server['world_size'] }}
|
||||||
|
2
main.py
2
main.py
@ -107,8 +107,6 @@ if __name__ == '__main__':
|
|||||||
# this should always be last
|
# this should always be last
|
||||||
tasks_manager.start_main_kill_switch_watcher()
|
tasks_manager.start_main_kill_switch_watcher()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# our main loop - eventually a shell
|
# our main loop - eventually a shell
|
||||||
while True:
|
while True:
|
||||||
if tasks_manager.get_main_thread_run_status():
|
if tasks_manager.get_main_thread_run_status():
|
||||||
|
Loading…
Reference in New Issue
Block a user