Skip to content
Snippets Groups Projects
Verified Commit 8d97f543 authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

Use sysstat in servers lsit

parent 271157f6
Branches 11-retrieve-system-parameters-from-servers
No related tags found
No related merge requests found
......@@ -82,15 +82,20 @@ def servers_list(ctx):
# Update all possible data for all servers
ctx.obj["apis"].refresh()
data = [
(
name,
api.host,
", ".join(["{:.2f}".format(val) for val in api.sysstat.get("loadavg", "")]),
str(api.sysstat.get("cpus", ""))
)
for name, api in ctx.obj["apis"].apis.items()
]
data = []
for name, api in ctx.obj["apis"].apis.items():
if api.sysstat is not None:
loadavgs = (
float(api.sysstat.reports["queue"].tail(1)["ldavg-1"]),
float(api.sysstat.reports["queue"].tail(1)["ldavg-5"]),
float(api.sysstat.reports["queue"].tail(1)["ldavg-15"]),
)
num_cpus = api.sysstat.num_cpus
else:
loadavgs = tuple()
num_cpus = ""
data.append((name, api.host, ", ".join([str(val) for val in loadavgs]), str(num_cpus)))
headers = ("Name", "Hostname", "Load avg.", "CPUs")
print(tabulate(data, headers=headers))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment