Created
October 15, 2017 09:47
-
-
Save tzermias/e229ac1ab67d78e9071bec7c12885f0c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
CGI_URL="https://server/icinga/cgi-bin" | |
USERNAME="" | |
PASSWORD="" | |
out=$(curl --silent -u $USERNAME:$PASSWORD "$CGI_URL/status.cgi?jsonoutput&servicestatustypes=28" |jq .status.service_status[].status 2>&1) | |
echo $out | awk 'BEGIN {RS=" ";d=0;c=0;u=0;w=0} | |
/DOWN/ {d++} | |
/CRITICAL/ {c++} | |
/UNKNOWN/ {u++} | |
/WARNING/ {w++} | |
END { | |
if (d>0) printf d" " | |
if (c>0) printf "#[bg=red]"c" #[default]" | |
if (u>0) printf "#[bg=magenta]#[fg=black]"u" #[default]" | |
if (w>0) printf "#[bg=yellow]#[fg=black]"w" #[default]" | |
}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment