root / plugins / network / pf_openbsd @ dd4afac8
Historique | Voir | Annoter | Télécharger (1,89 ko)
| 1 | 9e9466fe | 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 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 usage statistics |
||
| 30 | EOF |
||
| 31 | cat <<EOF |
||
| 32 | matches.label Matches |
||
| 33 | matches.min 0 |
||
| 34 | matches.type DERIVE |
||
| 35 | mismatches.label State mismatches |
||
| 36 | mismatches.min 0 |
||
| 37 | mismatches.type DERIVE |
||
| 38 | blocks.label Blocked packets |
||
| 39 | blocks.type DERIVE |
||
| 40 | blocks.min 0 |
||
| 41 | EOF |
||
| 42 | exit 0 |
||
| 43 | ;; |
||
| 44 | autoconf) |
||
| 45 | # FreeBSD |
||
| 46 | ostype=`uname -s` |
||
| 47 | if [ ${ostype} = "FreeBSD" ]; then
|
||
| 48 | # pf(4) module loaded? |
||
| 49 | if [ `kldstat -v | grep pf | wc -l` -eq 0 ]; then |
||
| 50 | echo "no (pf(4) is not loaded)" |
||
| 51 | exit 1 |
||
| 52 | fi |
||
| 53 | # enabled? |
||
| 54 | if [ `pfctl -si 2>/dev/null | awk '/^Status:/{print $2}'` != "Enabled" ]; then
|
||
| 55 | echo "no (pf(4) is not enabled, consult pfctl(8)" |
||
| 56 | exit 1 |
||
| 57 | fi |
||
| 58 | # OpenBSD |
||
| 59 | elif [ ${ostype} = "OpenBSD" ]; then
|
||
| 60 | # enabled? |
||
| 61 | if [ `pfctl -si 2>/dev/null | awk '/^Status:/{print $2}'` != "Enabled" ]; then
|
||
| 62 | echo "no (pf(4) is not enabled, consult pfctl(8)" |
||
| 63 | exit 1 |
||
| 64 | fi |
||
| 65 | # Other OSes |
||
| 66 | else |
||
| 67 | echo "no (this plugin is not supported on your OS)" |
||
| 68 | exit 1 |
||
| 69 | fi |
||
| 70 | echo "yes" |
||
| 71 | exit 0 |
||
| 72 | ;; |
||
| 73 | suggest) |
||
| 74 | exit 0; |
||
| 75 | ;; |
||
| 76 | esac |
||
| 77 | |||
| 78 | # |
||
| 79 | ${pfctl} -si 2>/dev/null | awk '
|
||
| 80 | $1~/^match$/{print "matches.value",$2}
|
||
| 81 | /state-mismatch/{print "mismatches.value",$2}'
|
||
| 82 | ${pfctl} -vsr 2> /dev/null| grep -A 1 ^block | awk 'BEGIN {sum=0}/^[ \t]*\[/{sum=sum+$5} END {print "blocks.value",sum}' |
