mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-09-19 09:03:20 +00:00
NetBSD support added
This commit is contained in:
parent
fc51c3a69e
commit
acb3839b40
1 changed files with 86 additions and 84 deletions
170
plugins/other/pf
170
plugins/other/pf
|
@ -32,112 +32,114 @@
|
||||||
#
|
#
|
||||||
#%# family=auto
|
#%# family=auto
|
||||||
#%# capabilities=autoconf
|
#%# capabilities=autoconf
|
||||||
|
PATH=/bin:/sbin:/usr/bin:/usr/sbin
|
||||||
|
export PATH
|
||||||
|
|
||||||
pfctl='/sbin/pfctl'
|
pfctl="/sbin/pfctl"
|
||||||
|
|
||||||
case $1 in
|
case $1 in
|
||||||
config)
|
config)
|
||||||
cat <<EOF
|
echo "graph_title OpenBSD pf statistics"
|
||||||
graph_title OpenBSD pf statistics
|
echo "graph_vlabel Entries per second"
|
||||||
graph_vlabel Entries per second
|
echo "graph_scale no"
|
||||||
graph_scale no
|
echo "graph_category network"
|
||||||
graph_category network
|
echo "graph_args -l 0"
|
||||||
graph_args -l 0
|
echo "graph_info OpenBSD's pf usage statistics"
|
||||||
graph_info OpenBSD's pf usage statistics
|
echo "states.label States"
|
||||||
states.label States
|
echo "states.type GAUGE"
|
||||||
states.type GAUGE
|
${pfctl} -sm 2> /dev/null | awk '/states/ {print "states.warning "$4*0.9; print "states.critical "$4*0.95}'
|
||||||
EOF
|
if [ "x${do_searches}" = "xyes" ]; then
|
||||||
${pfctl} -sm 2> /dev/null | awk '
|
echo "searches.label Searches"
|
||||||
/states/ {print "states.warning "$4*0.9; print "states.critical "$4*0.95}
|
echo "searches.min 0"
|
||||||
'
|
echo "searches.type DERIVE"
|
||||||
if [ "x${do_searches}" = "xyes" ]; then
|
fi
|
||||||
cat <<EOF
|
echo "matches.label Matches"
|
||||||
searches.label Searches
|
echo "matches.min 0"
|
||||||
searches.min 0
|
echo "matches.type DERIVE"
|
||||||
searches.type DERIVE
|
echo "mismatches.label State mismatches"
|
||||||
EOF
|
echo "mismatches.min 0"
|
||||||
fi
|
echo "mismatches.type DERIVE"
|
||||||
cat <<EOF
|
echo "blocks.label Blocked packets"
|
||||||
matches.label Matches
|
echo "blocks.type DERIVE"
|
||||||
matches.min 0
|
echo "blocks.min 0"
|
||||||
matches.type DERIVE
|
${pfctl} -sl 2>/dev/null | awk '{
|
||||||
mismatches.label State mismatches
|
l="";
|
||||||
mismatches.min 0
|
for (i=1; i<NF-2; i=i+1) l=l" "$i;
|
||||||
mismatches.type DERIVE
|
sub(/^ /, "", l);
|
||||||
blocks.label Blocked packets
|
f=l;
|
||||||
blocks.type DERIVE
|
gsub(/[^a-z0-9A-Z]/, "_", f);
|
||||||
blocks.min 0
|
print f".label L: "l;
|
||||||
EOF
|
print f".type DERIVE"
|
||||||
pfctl -sl | awk '
|
print f".min 0"}'
|
||||||
{
|
exit 0
|
||||||
l="";
|
;;
|
||||||
for (i=1; i<NF-2; i=i+1) l=l" "$i;
|
|
||||||
sub(/^ /, "", l);
|
|
||||||
f=l;
|
|
||||||
gsub(/[^a-z0-9A-Z]/, "_", f);
|
|
||||||
print f".label L: "l;
|
|
||||||
print f".type DERIVE"
|
|
||||||
print f".min 0"}'
|
|
||||||
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
autoconf)
|
autoconf)
|
||||||
# FreeBSD
|
|
||||||
ostype=`uname -s`
|
ostype=`uname -s`
|
||||||
if [ ${ostype} = "FreeBSD" ]; then
|
# NetBSD
|
||||||
# enabled?
|
if [ ${ostype} = "NetBSD" ]; then
|
||||||
if [ `pfctl -si 2>/dev/null | awk '/^Status:/{print $2}'` != "Enabled" ]; then
|
# enabled?
|
||||||
echo "no (pf(4) is not enabled, consult pfctl(8)"
|
if [ `${pfctl} -si 2>/dev/null | awk '/^Status:/{print $2}'` != "Enabled" ]; then
|
||||||
exit 1
|
echo "no (pf(4) is not enabled, consult pfctl(8))"
|
||||||
fi
|
exit 1
|
||||||
|
fi
|
||||||
|
# FreeBSD
|
||||||
|
elif [ ${ostype} = "FreeBSD" ]; 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
|
||||||
# OpenBSD
|
# OpenBSD
|
||||||
elif [ ${ostype} = "OpenBSD" ]; then
|
elif [ ${ostype} = "OpenBSD" ]; then
|
||||||
# pf(4) module loaded?
|
# pf(4) module loaded?
|
||||||
if [ `kldstat -v | grep pf | wc -l` -eq 0 ]; then
|
if [ `kldstat -v | grep pf | wc -l` -eq 0 ]; then
|
||||||
echo "no (pf(4) is not loaded)"
|
echo "no (pf(4) is not loaded)"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
# enabled?
|
# enabled?
|
||||||
if [ `pfctl -si 2>/dev/null | awk '/^Status:/{print $2}'` != "Enabled" ]; then
|
if [ `${pfctl} -si 2>/dev/null | awk '/^Status:/{print $2}'` != "Enabled" ]; then
|
||||||
echo "no (pf(4) is not enabled, consult pfctl(8)"
|
echo "no (pf(4) is not enabled, consult pfctl(8))"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
# Other OSes
|
# Other OSes
|
||||||
else
|
else
|
||||||
echo "no (this plugin is not supported on your OS)"
|
echo "no (this plugin is not supported on your OS)"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo "yes"
|
echo "yes"
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
|
|
||||||
suggest)
|
suggest)
|
||||||
exit 0;
|
exit 0;
|
||||||
;;
|
;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
#
|
#
|
||||||
${pfctl} -si 2>/dev/null | awk '
|
${pfctl} -si 2>/dev/null | awk '
|
||||||
/current entries/{print "states.value",$3}
|
/current entries/{print "states.value",$3}
|
||||||
/searches/{if ( "'${do_searches}'" == "yes" ) print "searches.value",$2}
|
/searches/{if ( "'${do_searches}'" == "yes" ) print "searches.value",$2}
|
||||||
$1~/^match$/{print "matches.value",$2}
|
$1~/^match$/{print "matches.value",$2}
|
||||||
/state-mismatch/{print "mismatches.value",$2}'
|
/state-mismatch/{print "mismatches.value",$2}'
|
||||||
${pfctl} -vsr 2> /dev/null| grep -A 1 ^block | awk 'BEGIN {sum=0}/^[ \t]*\[/{sum=sum+$5} END {print "blocks.value",sum}'
|
${pfctl} -vsr 2> /dev/null| grep -A 1 ^block | awk 'BEGIN {sum=0}/^[ \t]*\[/{sum=sum+$5} END {print "blocks.value",sum}'
|
||||||
|
|
||||||
# the labeled ones
|
# the labeled ones
|
||||||
pfctl -sl | awk '
|
${pfctl} -sl 2>/dev/null | awk '
|
||||||
BEGIN {
|
BEGIN {
|
||||||
total=0
|
total=0
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
l="";
|
l="";
|
||||||
for (i=1; i<NF-2; i=i+1) l=l" "$i;
|
for (i=1; i<NF-2; i=i+1) l=l" "$i;
|
||||||
sub(/^ /, "", l);
|
sub(/^ /, "", l);
|
||||||
f=l;
|
f=l;
|
||||||
gsub(/[^a-z0-9A-Z]/, "_", f);
|
gsub(/[^a-z0-9A-Z]/, "_", f);
|
||||||
total=total+1;
|
total=total+1;
|
||||||
fields[f]=fields[f]+$(NF-i+2);
|
fields[f]=fields[f]+$(NF-i+2);
|
||||||
}
|
}
|
||||||
END {
|
END {
|
||||||
if ( total == 0 ) exit 0;
|
if ( total == 0 ) exit 0;
|
||||||
for ( k in fields ) print k".value "fields[k]
|
for ( k in fields ) print k".value "fields[k]
|
||||||
}'
|
}'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue