From 454978c9ae28f952b93c969ee6333cbc04287e0e Mon Sep 17 00:00:00 2001 From: Nicolai Buchwitz Date: Sun, 12 May 2024 13:29:44 +0200 Subject: [PATCH] feat: Make check mode naming more consistent Introduc aliases for check modes to make naming more consistent: - io_wait: io-wait - vm_status: vm-status Signed-off-by: Nicolai Buchwitz --- README.md | 9 ++++----- check_pve.py | 8 +++++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index aef71df..d739c7a 100644 --- a/README.md +++ b/README.md @@ -102,9 +102,9 @@ The ``icinga2`` folder contains the command definition and service examples for ``` usage: check_pve.py [-h] -e API_ENDPOINT [--api-port API_PORT] -u API_USER (-p API_PASSWORD | -t API_TOKEN) [-k] -m - {cluster,version,cpu,memory,swap,storage,io_wait,updates,services,subscription,vm,vm_status,replication,disk-health,ceph-health,zfs-health,zfs-fragmentation,backup} - [-n NODE] [--name NAME] [--vmid VMID] [--expected-vm-status {running,stopped,paused}] [--ignore-vm-status] [--ignore-service NAME] [--ignore-disk NAME] - [-w THRESHOLD_WARNING] [-c THRESHOLD_CRITICAL] [-M] [-V MIN_VERSION] [--unit {GB,MB,KB,GiB,MiB,KiB,B}] + {cluster,version,cpu,memory,swap,storage,io_wait,io-wait,updates,services,subscription,vm,vm_status,vm-status,replication,disk-health,ceph-health,zfs-health,zfs-fragmentation,backup} [-n NODE] [--name NAME] + [--vmid VMID] [--expected-vm-status {running,stopped,paused}] [--ignore-vm-status] [--ignore-service NAME] [--ignore-disk NAME] [-w THRESHOLD_WARNING] [-c THRESHOLD_CRITICAL] [-M] [-V MIN_VERSION] + [--unit {GB,MB,KB,GiB,MiB,KiB,B}] Check command for PVE hosts via API @@ -124,7 +124,7 @@ API Options: -k, --insecure Don't verify HTTPS certificate Check Options: - -m {cluster,version,cpu,memory,swap,storage,io_wait,updates,services,subscription,vm,vm_status,replication,disk-health,ceph-health,zfs-health,zfs-fragmentation,backup}, --mode {cluster,version,cpu,memory,swap,storage,io_wait,updates,services,subscription,vm,vm_status,replication,disk-health,ceph-health,zfs-health,zfs-fragmentation,backup} + -m {cluster,version,cpu,memory,swap,storage,io_wait,io-wait,updates,services,subscription,vm,vm_status,vm-status,replication,disk-health,ceph-health,zfs-health,zfs-fragmentation,backup}, --mode {cluster,version,cpu,memory,swap,storage,io_wait,io-wait,updates,services,subscription,vm,vm_status,vm-status,replication,disk-health,ceph-health,zfs-health,zfs-fragmentation,backup} Mode to use. -n NODE, --node NODE Node to check (necessary for all modes except cluster, version and backup) --name NAME Name of storage, vm, or container @@ -144,7 +144,6 @@ Check Options: The minimal pve version to check for. Any version lower than this will return CRITICAL. --unit {GB,MB,KB,GiB,MiB,KiB,B} Unit which is used for performance data and other values - ``` ## Check examples diff --git a/check_pve.py b/check_pve.py index 29e63ce..209cf6f 100755 --- a/check_pve.py +++ b/check_pve.py @@ -835,7 +835,7 @@ def check(self) -> None: self.check_memory() elif self.options.mode == "swap": self.check_swap() - elif self.options.mode == "io_wait": + elif self.options.mode in ("io_wait", "io-wait"): self.check_io_wait() elif self.options.mode == "disk-health": self.check_disks() @@ -849,8 +849,8 @@ def check(self) -> None: self.check_subscription() elif self.options.mode == "storage": self.check_storage(self.options.name) - elif self.options.mode in ["vm", "vm_status"]: - only_status = self.options.mode == "vm_status" + elif self.options.mode in ["vm", "vm_status", "vm-status"]: + only_status = self.options.mode in ["vm_status", "vm-status"] if self.options.name: idx = self.options.name @@ -936,11 +936,13 @@ def parse_args(self) -> None: "swap", "storage", "io_wait", + "io-wait", "updates", "services", "subscription", "vm", "vm_status", + "vm-status", "replication", "disk-health", "ceph-health",