added some error handling in the nagios checks

This commit is contained in:
Rasmus Thorslund 2025-04-23 11:55:50 +02:00
parent cb0f0c5125
commit 584c44352f
No known key found for this signature in database
GPG key ID: 502D33332E9E305D
3 changed files with 9 additions and 2 deletions

View file

@ -1,6 +1,9 @@
#!/bin/bash
# This file is managed by puppet.
set -euo pipefail
trap 'echo "UNKNOWN: failed to query Kubernetes API" >&2; exit 3' ERR
STATUS=$(/snap/bin/kubectl get events --all-namespaces -o json)
# number warnings required to make critical status (any warning makes warning and any critical makes critical)

View file

@ -1,6 +1,9 @@
#!/bin/bash
# This file is managed by puppet.
set -euo pipefail
trap 'echo "UNKNOWN: failed to query Kubernetes API" >&2; exit 3' ERR
num_replica=$(/snap/bin/kubectl get pods -n sunet-cnpg -o json \
| jq -r '
.items[]

View file

@ -6,11 +6,12 @@ export OS_AUTH_URL="https://v2.api.sto4.safedc.net:5000/v3/"
export OS_AUTH_TYPE="v3applicationcredential"
export OS_APPLICATION_CREDENTIAL_ID="<%= scope.call_function('safe_hiera',['sto4_application_credential_id']) %>"
export OS_APPLICATION_CREDENTIAL_SECRET="<%= scope.call_function('safe_hiera',['sto4_application_credential_secret']) %>"
export OS_REGION_NAME="sto4"
export OS_INTERFACE="public"
set -euo pipefail
trap 'echo "UNKNOWN: failed to query OpenStack" >&2; exit 3' ERR
num_snaps=$(openstack volume snapshot list -f json \
| jq -r '.[].ID' \
| wc -l | tr -d ' ')