@command
-def health_status(name="monitoring", show_pwn=True, show_system=True):
+def health_status(vm=None, show_pwn=True, show_system=True, monitoring_name='monitoring'):
"""Checks the health status of all challenges with a pwn script,
i.e. having a folder structure like: ./<category>/<challenge_name>/exploit/Dockerfile
optional:
+ - vm: string name, regex or Droplet objects, None shows all VM's (default: None)
- show_pwn: bool show pwn script status (default: True)
- show_system: bool show pwn script status (default: True)
+ - monitoring_name: string the name of the monitoring vm (default: monitoring)
"""
- monitoring_vm = get(name)
+ monitoring_vm = get(monitoring_name)
if not monitoring_vm or monitoring_vm[0].status != "active":
- print(f"could not find running vm with name {name}. Exiting now.")
+ print(red(f"could not find running vm with name {monitoring_name}. Exiting now."))
return
def show_system_status(vm):
print(bright("\tMem: ") + f"{mem[0]}MiB/{mem[1]}MiB {100 * int(mem[0]) // int(mem[1])}%")
print(bright("\tDisk: ") + f"{disk[0]}/{disk[1]} {disk[2]}")
- for challenge_path in get_monitorable_challs():
- challenge_name = basename(challenge_path)
+ vms = [vm.name for vm in get(vm)] if vm else list(map(basename, get_monitorable_challs()))
+ for challenge_name in vms:
print(f"[*] monitoring report for {challenge_name}:")
if show_pwn:
if show_system:
show_system_status(challenge_name)
- if show_system:
+ if not vm and show_system:
print(f"[*] monitoring report for ctfd-backup:")
show_system_status('ctfd-backup')