root / plugins / network / pf_states @ dd4afac8
Historique | Voir | Annoter | Télécharger (1,77 ko)
| 1 | 96bae2ba | immerda project group | #!/bin/sh |
|---|---|---|---|
| 2 | # |
||
| 3 | # OpenBSD's pf(4) monitoring for OpenBSD |
||
| 4 | # 2007, Originally by Gergely Czuczy <phoemix@harmless.hu> |
||
| 5 | # for FreeBSD systems. Ported and splitted by the |
||
| 6 | # immerda admin team admin(at)immerda.ch |
||
| 7 | # this version is adapted for openbsd and is only tested on |
||
| 8 | # openbsd systems. |
||
| 9 | # |
||
| 10 | # Needs to run as root. |
||
| 11 | # Add "user root" for the [pf] into plugins.conf. |
||
| 12 | # |
||
| 13 | # Options: |
||
| 14 | # - env.do_searches yes: to enable state table search monitoring` |
||
| 15 | # |
||
| 16 | #%# family=auto |
||
| 17 | #%# capabilities=autoconf |
||
| 18 | |||
| 19 | pfctl='/sbin/pfctl' |
||
| 20 | |||
| 21 | case $1 in |
||
| 22 | config) |
||
| 23 | cat <<EOF |
||
| 24 | graph_title OpenBSD pf state statistics |
||
| 25 | graph_vlabel Entries per second |
||
| 26 | graph_scale no |
||
| 27 | graph_category network |
||
| 28 | graph_args -l 0 |
||
| 29 | graph_info OpenBSD's pf state statistics |
||
| 30 | states.label States |
||
| 31 | states.type GAUGE |
||
| 32 | searches.label Searches |
||
| 33 | searches.min 0 |
||
| 34 | searches.type DERIVE |
||
| 35 | EOF |
||
| 36 | ${pfctl} -sm 2> /dev/null | awk '
|
||
| 37 | /states/ {print "states.warning "$4*0.9; print "states.critical "$4*0.95}'
|
||
| 38 | exit 0 |
||
| 39 | ;; |
||
| 40 | autoconf) |
||
| 41 | # FreeBSD |
||
| 42 | ostype=`uname -s` |
||
| 43 | if [ ${ostype} = "FreeBSD" ]; then
|
||
| 44 | # pf(4) module loaded? |
||
| 45 | if [ `kldstat -v | grep pf | wc -l` -eq 0 ]; then |
||
| 46 | echo "no (pf(4) is not loaded)" |
||
| 47 | exit 1 |
||
| 48 | fi |
||
| 49 | # enabled? |
||
| 50 | if [ `pfctl -si 2>/dev/null | awk '/^Status:/{print $2}'` != "Enabled" ]; then
|
||
| 51 | echo "no (pf(4) is not enabled, consult pfctl(8)" |
||
| 52 | exit 1 |
||
| 53 | fi |
||
| 54 | # OpenBSD |
||
| 55 | elif [ ${ostype} = "OpenBSD" ]; then
|
||
| 56 | # enabled? |
||
| 57 | if [ `pfctl -si 2>/dev/null | awk '/^Status:/{print $2}'` != "Enabled" ]; then
|
||
| 58 | echo "no (pf(4) is not enabled, consult pfctl(8)" |
||
| 59 | exit 1 |
||
| 60 | fi |
||
| 61 | # Other OSes |
||
| 62 | else |
||
| 63 | echo "no (this plugin is not supported on your OS)" |
||
| 64 | exit 1 |
||
| 65 | fi |
||
| 66 | echo "yes" |
||
| 67 | exit 0 |
||
| 68 | ;; |
||
| 69 | suggest) |
||
| 70 | exit 0; |
||
| 71 | ;; |
||
| 72 | esac |
||
| 73 | |||
| 74 | # |
||
| 75 | ${pfctl} -si 2>/dev/null | awk '
|
||
| 76 | /current entries/{print "states.value",$3}
|
||
| 77 | /searches/ { print "searches.value",$2}' |
