archlinux pacman check; forcecommand.cfg template

This commit is contained in:
Moritz Rudert (helios) 2013-01-21 10:56:09 +01:00
parent ade091bf3d
commit 5a2c23f29d
2 changed files with 61 additions and 0 deletions

50
check_pacman Executable file
View File

@ -0,0 +1,50 @@
#!/bin/bash
export TERM=linux
set -eu
declare -i STATE_OK=0;
declare -i STATE_WARNING=1;
declare -i STATE_CRITICAL=2;
declare -i STATE_UNKNOWN=3;
declare -i WARN_LEVEL=1
declare -i CRIT_LEVEL=3
PACMAN_NAME="yaourt"
PACMAN="$(which "${PACMAN_NAME}")"
PACMAN_OPTS="-Sud --print"
if [ ! -x "${PACMAN}" ]; then
echo "[UNKNOWN] Found no executable pacman"
exit ${STATE_UNKNOWN}
fi
result="$("${PACMAN}" ${PACMAN_OPTS})"
declare -i lines=$(echo "${result}" | wc -l)
lines=$((${lines} - 1))
if echo "${result}" | grep "there is nothing to do" &> /dev/null; then
lines=0
fi
if [ ${lines} -lt 0 ]; then
echo "[UNKNOWN] Got unexpected zero line result"
exit ${STATE_UNKNOWN}
elif [ ${lines} -eq 0 ]; then
echo "[OK] No updates available"
exit ${STATE_OK}
elif [ ${lines} -ge ${CRIT_LEVEL} ]; then
echo "[CRITICAL] ${lines} updates available"
exit ${STATE_CRITICAL}
elif [ ${lines} -ge ${WARN_LEVEL} ]; then
echo "[WARNING] ${lines} updates available"
exit ${STATE_WARNING}
else
echo "[UNKNOWN] Something gone wrong"
exit ${STATE_UNKNOWN}
fi

11
forcecommand.cfg Normal file
View File

@ -0,0 +1,11 @@
check_users = /usr/lib/nagios/plugins/check_users -w 10 -c 15
check_load = /usr/lib/nagios/plugins/check_load -w 15,10,5 -c 30,25,20
check_disk_root = /usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /dev/vda1
check_zombies = /usr/lib/nagios/plugins/check_procs -w 5 -c 10 -s Z
check_total_procs = /usr/lib/nagios/plugins/check_procs -w 500 -c 600
check_swap = /usr/lib/nagios/plugins/check_swap -w 20 -c 10
check_sensors = /usr/lib/nagios/plugins/check_sensors
check_apt = /usr/lib/nagios/plugins/check_apt -d
check_peering_ping = /usr/local/lib/nagios/plugins/check_peering_ping
check_libs = sudo /usr/local/lib/nagios/plugins/check_libs
check_kernel = /usr/local/lib/nagios/plugins/check_kernel