From 0ba74f80d74c00aefb1765ac2a78085c51dbb6a3 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 2 Apr 2019 15:09:44 +0200 Subject: [PATCH] heck for dependencies between check_source and failing services fixes #63 --- 1 | 1 + icinga-diagnostics.sh | 26 ++++++++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 1 diff --git a/1 b/1 new file mode 100644 index 0000000..c076b93 --- /dev/null +++ b/1 @@ -0,0 +1 @@ +Unable to talk to NTP daemon. Is it running? diff --git a/icinga-diagnostics.sh b/icinga-diagnostics.sh index ddf9e40..af1a4b2 100755 --- a/icinga-diagnostics.sh +++ b/icinga-diagnostics.sh @@ -15,7 +15,7 @@ echo "" ## Static variables ## -OPTSTR="fhtzg" +OPTSTR="fhtzgs" TIMESTAMP=$(date +%Y%m%d) UNAME_S=$(uname -s) @@ -78,6 +78,7 @@ show_help() { -t create a tarball instead of just printing the output -z list all zones in standard output (ignored in "full" mode) -g provide gdb output for debugging + -s list all servicies which are not okay. You should give first the zones names, on which the service have to be checkecd. " exit 0 } @@ -208,7 +209,27 @@ doc_icinga2() { echo "GDB mode requested but gdb not found" fi fi - + # Checking not okay servicies on the given zones +if [ "${SERVICES}" = true ]; +then +echo "please give the Zones, on which the not okay services will be checked. When you are finish press 0" +while : +do + read input + if [ "${input}" != "0" ] + then + zones+=("${input}") + else break + fi +done +for zone in "${zones[@]}" +do + SERVICESFILTER=$(curl -k -s -u root:icinga -H 'Accept: application/json' -H 'X-HTTP-Method-Override: GET' -X POST "https://127.0.0.1:5665/v1/objects/services?filter=service.last_check_result.check_source%3D%3D%22$zone%22%26%26service.state%3E0" -d '{ "pretty": true }' | awk ' /__name/ { match($0, ": \"([^\"]+)\"", m); print m[1] }') + SERVICENUMBER=$(curl -k -s -u root:icinga -H 'Accept: application/json' -H 'X-HTTP-Method-Override: GET' -X POST "https://127.0.0.1:5665/v1/objects/services?filter=service.last_check_result.check_source%3D%3D%22$zone%22%26%26service.state%3E0" -d '{ "pretty": true }' | awk ' /__name/ { match($0, ": \"([^\"]+)\"", m); print m[1] }' | wc -l) + echo "********************** Not okay services on $zone are $SERVICENUMBER **********************" + echo "${SERVICESFILTER}" +done +fi } doc_icingaweb2() { @@ -488,6 +509,7 @@ do t) create_tarball;; z) ZONES=true;; g) GDB=true;; + s) SERVICES=true;; esac done