1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- #!/bin/bash
- PLUGINDIR=/usr/lib/nagios/plugins/
- . $PLUGINDIR/utils.sh
- status=$(systemctl list-units --failed --no-legend --plain | cut -f1 -d" " |xargs)
- r=$?
- while getopts "w" opt; do
- case $opt in
- w)
-
- readarray -t units < /etc/icinga2/service_whitelist
- esac
- status=( $(systemctl list-units --failed --no-legend --plain ${units[*]}| cut -f1 -d" " |xargs) )
- r=$?
- done
- if [ $r -ne 0 ]; then
- echo "UNKNOWN: Check command failed."
- exit $STATE_UNKNOWN
- fi
- if [ -z "$status" ]; then
- echo "OK: No Failed Units."
- exit $STATE_OK
- else
- echo "CRITICAL: Some units failed. ${status[*]}."
- exit $STATE_CRITICAL
- fi
- echo "OK: service $service is running"
- exit $STATE_OK
|