Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / plugins / network / pf_packets @ c3660c2a

Historique | Voir | Annoter | Télécharger (1,88 ko)

1 3b5831fc immerda admin 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
#%# family=auto
14
#%# capabilities=autoconf
15
16
pfctl='/sbin/pfctl'
17
18
case $1 in
19
    config)
20
    cat <<EOF
21
graph_title OpenBSD pf label packets statistics
22
graph_vlabel packets per second
23
graph_scale no
24
graph_category network
25
graph_args -l 0
26
graph_info OpenBSD's pf label packets usage statistics
27
EOF
28
pfctl -sl | awk '
29
BEGIN {
30
 total=0
31
}
32
{
33
 l=$1;
34
 f_packets=l;
35
 gsub(/[^a-z0-9A-Z]/, "_", f_packets);
36
 fields[f_packets]=l;
37
 total=total+1
38
}
39
END {
40
 if ( total == 0 ) exit 0;
41
 for ( k in fields ) print k".label "fields[k]"\n"k".type DERIVE\n"k".min 0"
42
}'
43
44
    exit 0
45
    ;;
46
    autoconf)
47
	# FreeBSD
48
	ostype=`uname -s`
49
	if [ ${ostype} = "FreeBSD" ]; then
50
	    # pf(4) module loaded?
51
	    if [ `kldstat -v | grep pf | wc -l` -eq 0 ]; then
52
		echo "no (pf(4) is not loaded)"
53
		exit 1
54
	    fi
55
	    # enabled?
56
	    if [ `pfctl -si 2>/dev/null | awk '/^Status:/{print $2}'` != "Enabled" ]; then
57
		echo "no (pf(4) is not enabled, consult pfctl(8)"
58
		exit 1
59
	    fi
60
	# OpenBSD
61
	elif [ ${ostype} = "OpenBSD" ]; then
62
            # enabled?
63
	    if [ `pfctl -si 2>/dev/null | awk '/^Status:/{print $2}'` != "Enabled" ]; then
64
		echo "no (pf(4) is not enabled, consult pfctl(8)"
65
		exit 1
66
	    fi
67
	# Other OSes
68
	else
69
	    echo "no (this plugin is not supported on your OS)"
70
	    exit 1
71
	fi
72
	echo "yes"
73
	exit 0
74
	;;
75
    suggest)
76
	exit 0;
77
	;;
78
esac
79
80 2a3932cf Antoine Beaupré
pfctl -sl | awk '
81 3b5831fc immerda admin group
BEGIN {
82
 total=0
83
}
84
{
85
 l=$1;
86
 f_packets=l;
87
 gsub(/[^a-z0-9A-Z]/, "_", f_packets);
88
 total=total+1;
89
 fields[f_packets]=fields[f_packets]+$3;
90
}
91
END {
92
 if ( total == 0 ) exit 0;
93
 for ( k in fields ) print k".value "fields[k]
94
}'
95