From 5a2c23f29dfe309d237765f31fc0e5821206aff4 Mon Sep 17 00:00:00 2001 From: "Moritz Rudert (helios)" Date: Mon, 21 Jan 2013 10:56:09 +0100 Subject: [PATCH] archlinux pacman check; forcecommand.cfg template --- check_pacman | 50 ++++++++++++++++++++++++++++++++++++++++++++++++ forcecommand.cfg | 11 +++++++++++ 2 files changed, 61 insertions(+) create mode 100755 check_pacman create mode 100644 forcecommand.cfg diff --git a/check_pacman b/check_pacman new file mode 100755 index 0000000..3dc2a57 --- /dev/null +++ b/check_pacman @@ -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 + diff --git a/forcecommand.cfg b/forcecommand.cfg new file mode 100644 index 0000000..422f4a7 --- /dev/null +++ b/forcecommand.cfg @@ -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