Skip to content

Instantly share code, notes, and snippets.

@tzermias
Created October 15, 2017 09:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tzermias/e229ac1ab67d78e9071bec7c12885f0c to your computer and use it in GitHub Desktop.
Save tzermias/e229ac1ab67d78e9071bec7c12885f0c to your computer and use it in GitHub Desktop.
#!/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