diff --git a/files/nrpe/check_pbs_backup b/files/nrpe/check_pbs_backup index f4b0ae7..287e9ef 100755 --- a/files/nrpe/check_pbs_backup +++ b/files/nrpe/check_pbs_backup @@ -15,7 +15,7 @@ STATE_UNKNOWN=3 PBS_HOST="" PBS_PORT=8007 PBS_TOKEN="" -PBS_STORE="" +PBS_DATASTORE="" BACKUP_ID="" BACKUP_TYPE="host" NAMESPACE="" @@ -50,7 +50,7 @@ while getopts "H:T:s:n:t:P:N:k" opt; do case "$opt" in H) PBS_HOST="$OPTARG" ;; T) PBS_TOKEN="$OPTARG" ;; - s) PBS_STORE="$OPTARG" ;; + s) PBS_DATASTORE="$OPTARG" ;; n) BACKUP_ID="$OPTARG" ;; t) BACKUP_TYPE="$OPTARG" ;; P) PBS_PORT="$OPTARG" ;; @@ -60,7 +60,7 @@ while getopts "H:T:s:n:t:P:N:k" opt; do esac done -if [[ -z "$PBS_HOST" || -z "$PBS_TOKEN" || -z "$PBS_STORE" || -z "$BACKUP_ID" ]]; then +if [[ -z "$PBS_HOST" || -z "$PBS_TOKEN" || -z "$PBS_DATASTORE" || -z "$BACKUP_ID" ]]; then usage fi @@ -75,7 +75,7 @@ CURL_OPTS=(-sf --max-time 15) # --- URL de l'API --- BASE_URL="https://${PBS_HOST}:${PBS_PORT}/api2/json" -SNAPSHOTS_URL="${BASE_URL}/admin/datastore/${PBS_STORE}/snapshots?backup-type=${BACKUP_TYPE}&backup-id=${BACKUP_ID}" +SNAPSHOTS_URL="${BASE_URL}/admin/datastore/${PBS_DATASTORE}/snapshots?backup-type=${BACKUP_TYPE}&backup-id=${BACKUP_ID}" [[ -n "$NAMESPACE" ]] && SNAPSHOTS_URL+="&ns=${NAMESPACE}" # --- Appel API --- @@ -108,7 +108,7 @@ SNAPSHOTS=$(echo "$RESPONSE" | jq -r '.data // []') TOTAL_COUNT=$(echo "$SNAPSHOTS" | jq 'length') if [[ "$TOTAL_COUNT" -eq 0 ]]; then - echo "CRITICAL: Aucun backup trouvé pour '${BACKUP_ID}' dans le datastore '${PBS_STORE}'" + echo "CRITICAL: Aucun backup trouvé pour '${BACKUP_ID}' dans le datastore '${PBS_DATASTORE}'" exit $STATE_CRITICAL fi diff --git a/templates/nrpe.j2 b/templates/nrpe.j2 index 9374e01..a4c4dd9 100644 --- a/templates/nrpe.j2 +++ b/templates/nrpe.j2 @@ -163,9 +163,9 @@ command[check_ceph_cap]=/usr/lib/nagios/plugins/check_ceph cap command[check_ceph_pg]=/usr/lib/nagios/plugins/check_ceph pg {% endif %} -{% if nrpe_pbs is defined %} +{% if nrpe_pbs_backups is defined %} # pbs backups -{% for backup_id in nrpe_pbs.backups %} -command[check_pbs_backup_{{ backup_id }}]=/usr/lib/nagios/plugins/check_pbs_backup -H {{ nrpe_pbs.host }} -T {{ nrpe_pbs.token }} -s {{ nrpe_pbs.store }} -n {{ backup_id }}{{ ' -t ' + nrpe_pbs.type if nrpe_pbs.type is defined else '' }}{{ ' -P ' + nrpe_pbs.port|string if nrpe_pbs.port is defined else '' }}{{ ' -N ' + nrpe_pbs.namespace if nrpe_pbs.namespace is defined else '' }}{{ ' -k' if nrpe_pbs.ssl_insecure | default(false) else '' }} +{% for backup_id in nrpe_pbs_backups %} +command[check_pbs_backup_{{ backup_id }}]=/usr/lib/nagios/plugins/check_pbs_backup -H {{ nrpe_pbs_host }} -T {{ nrpe_pbs_token }} -s {{ nrpe_pbs_datastore }} -n {{ backup_id }}{{ ' -t ' + nrpe_pbs_type if nrpe_pbs_type is defined else '' }}{{ ' -P ' + nrpe_pbs_port|string if nrpe_pbs_port is defined else '' }}{{ ' -N ' + nrpe_pbs_namespace if nrpe_pbs_namespace is defined else '' }}{{ ' -k' if nrpe_pbs_ssl_insecure | default(false) else '' }} {% endfor %} {% endif %} \ No newline at end of file