From 96bae2ba3cbf1db680b1933e3f86ce54e3550a34 Mon Sep 17 00:00:00 2001 From: immerda project group Date: Thu, 13 Sep 2007 14:50:16 +0200 Subject: [PATCH] Initial version --- plugins/other/pf_states | 77 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100755 plugins/other/pf_states diff --git a/plugins/other/pf_states b/plugins/other/pf_states new file mode 100755 index 00000000..5e57ea60 --- /dev/null +++ b/plugins/other/pf_states @@ -0,0 +1,77 @@ +#!/bin/sh +# +# OpenBSD's pf(4) monitoring for OpenBSD +# 2007, Originally by Gergely Czuczy +# for FreeBSD systems. Ported and splitted by the +# immerda admin team admin(at)immerda.ch +# this version is adapted for openbsd and is only tested on +# openbsd systems. +# +# Needs to run as root. +# Add "user root" for the [pf] into plugins.conf. +# +# Options: +# - env.do_searches yes: to enable state table search monitoring` +# +#%# family=auto +#%# capabilities=autoconf + +pfctl='/sbin/pfctl' + +case $1 in + config) + cat < /dev/null | awk ' +/states/ {print "states.warning "$4*0.9; print "states.critical "$4*0.95}' + exit 0 + ;; + autoconf) + # FreeBSD + ostype=`uname -s` + if [ ${ostype} = "FreeBSD" ]; then + # pf(4) module loaded? + if [ `kldstat -v | grep pf | wc -l` -eq 0 ]; then + echo "no (pf(4) is not loaded)" + exit 1 + fi + # enabled? + if [ `pfctl -si 2>/dev/null | awk '/^Status:/{print $2}'` != "Enabled" ]; then + echo "no (pf(4) is not enabled, consult pfctl(8)" + exit 1 + fi + # OpenBSD + elif [ ${ostype} = "OpenBSD" ]; then + # enabled? + if [ `pfctl -si 2>/dev/null | awk '/^Status:/{print $2}'` != "Enabled" ]; then + echo "no (pf(4) is not enabled, consult pfctl(8)" + exit 1 + fi + # Other OSes + else + echo "no (this plugin is not supported on your OS)" + exit 1 + fi + echo "yes" + exit 0 + ;; + suggest) + exit 0; + ;; +esac + +# +${pfctl} -si 2>/dev/null | awk ' +/current entries/{print "states.value",$3} +/searches/ { print "searches.value",$2}'