Check every machine from a program
One program walks your machines and prints the memory available and the disk space left on each. It only reads, so the agent token it uses needs no extra classes.
When to use this
A cron job, a status page or a script that should notice a full disk before you do.
Steps
-
Install the SDK (Python or TypeScript).
-
Create an agent token on your page and set the two variables. Treat the token like a password.
-
Run:
import cmdop with cmdop.connect() as c: # CMDOP_TOKEN, CMDOP_URL for m in c.machines_list(): if m.state != "online": continue info = c.machine(m.name).sys_info() root = next(d for d in info.disks if d.mount == "/") print(m.name, info.memory_available // 2**20, "MiB available,", root.available // 2**30, "GiB left on /")
Check
One line per online machine, with numbers you can compare with the system’s own settings.
If it fails
unauthorized: the token ran out or was revoked; create a new one.- A machine is skipped: it is not
onlineinmachines_list.