blob: dcb6c7f38f93a680292795031f69d97a0db103e8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
typeset output
typeset sv_ok sv_warn sv_crit sv_unknown
typeset host_up host_down host_unreachable
output=($(ssh aneurysm \
'/usr/sbin/icingastats -md NUMSVCOK,NUMSVCWARN,NUMSVCUNKN,NUMSVCCRIT,'\
'NUMHSTUP,NUMHSTDOWN,NUMHSTUNR'))
function _icinga_format {
typeset format
case ${1} in
yellow) format='%F{black}%K{yellow}' ;;
red) format='%K{red}' ;;
blue) format='%K{blue}' ;;
esac
(( ${3} == 0 )) && format=
print -Pn ${format}
printf "%-16s %s%s" ${2} $(print -P '%F{default}%K{default}') ${3}
echo
}
_icinga_format green 'Service OK' ${output[1]}
_icinga_format yellow 'Sercice WARN' ${output[2]}
_icinga_format blue 'Service UNKNOWN' ${output[3]}
_icinga_format red 'Service CRIT' ${output[4]}
echo
_icinga_format green 'Host UP' ${output[5]}
_icinga_format red 'Host DOWN' ${output[6]}
_icinga_format blue 'Host UNREACHABLE' ${output[7]}
|