2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00
contrib-munin/plugins/chilli/chilli_sessions_

120 lines
2.8 KiB
Plaintext
Raw Normal View History

2017-01-05 08:26:00 +01:00
#!/bin/sh
2016-09-26 10:38:07 +02:00
# -*- sh -*-
: << =cut
=head1 NAME
2017-01-05 08:26:00 +01:00
chilli_sessions_ - Wildcard-plugin to monitor sessions state on Coova Chilli.
2016-09-26 10:38:07 +02:00
2017-01-10 08:50:08 +01:00
=head1 DESCRIPTION
2017-01-10 08:48:19 +01:00
This wildcard plugin is for monitor the number of device with state pass/dnat/none on Coova Chilli instances.
2016-09-26 10:38:07 +02:00
=head1 CONFIGURATION
This plugin does not normally require configuration.
The plugin may need to run as root. This is configured like this:
2017-01-05 08:26:00 +01:00
[chilli_sessions_*]
2016-09-26 10:38:07 +02:00
user root
This is a wildcard plugin. To monitor an instance, link
2017-01-05 08:26:00 +01:00
chilli_sessions_<instance> to this file. For example :
2016-09-26 10:38:07 +02:00
2017-01-05 08:26:00 +01:00
ln -s /usr/share/munin/plugins/chilli_sessions_ \
/etc/munin/plugins/chilli_sessions_hotspot1
2016-09-26 10:38:07 +02:00
will monitor hotspot1.
For monitor all instances use :
2017-01-05 08:26:00 +01:00
ln -s /usr/share/munin/plugins/chilli_sessions_ \
/etc/munin/plugins/chilli_sessions_total
2016-09-26 10:38:07 +02:00
=head1 AUTHOR
OPENevents - Guillaume Marsay <guillaume.marsay@openevents.fr>
=head1 LICENSE
GPLv2
=head1 MAGIC MARKERS
#%# family=auto
#%# capabilities=autoconf suggest
=cut
2017-01-05 08:26:00 +01:00
INSTANCE="${0##*chilli_}"
2016-09-26 10:38:07 +02:00
CHILLI_PATH_BIN="/usr/sbin/chilli_query"
CHILLI_PATH_SOCK="/var/run"
2017-01-05 08:26:00 +01:00
case "$1" in
2016-09-26 10:38:07 +02:00
autoconf)
2017-01-05 08:26:00 +01:00
if [ -r "$CHILLI_PATH_BIN" ]; then
if [ "$INSTANCE" = "total" ]; then
2016-09-26 10:38:07 +02:00
echo "yes"
exit 0
else
if [ -r $CHILLI_PATH_SOCK/chilli_"$INSTANCE".sock ]; then
2017-01-05 08:26:00 +01:00
echo "yes"
2016-09-26 10:38:07 +02:00
exit 0
else
echo "no ($CHILLI_PATH_SOCK/chilli_$INSTANCE.sock not found)"
exit 0
fi
fi
else
echo "no ($CHILLI_PATH_BIN not found)"
exit 0
fi
;;
suggest)
2017-01-10 08:48:19 +01:00
find "$CHILLI_PATH_SOCK/" -name "chilli_*.sock" | while read file; do
2017-01-05 08:26:00 +01:00
basename "$file" .sock | cut -d _ -f 2
2016-09-26 10:38:07 +02:00
done
echo "total"
2017-01-05 08:26:00 +01:00
2017-01-10 08:48:19 +01:00
exit 0
2016-09-26 10:38:07 +02:00
;;
config)
echo "graph_title Chilli $INSTANCE sessions"
echo "graph_args --base 1000 -l 0"
echo "graph_category chilli"
echo "none.label NONE"
echo "none.min 0"
echo "none.draw AREA"
echo "none.colour ff8000"
echo "dnat.label DNAT"
echo "dnat.min 0"
echo "dnat.draw STACK"
echo "dnat.colour 0066b3"
echo "pass.label PASS"
echo "pass.draw STACK"
echo "pass.min 0"
echo "pass.colour 00cc00"
exit 0
;;
esac
2017-01-05 08:26:00 +01:00
if [ "$INSTANCE" = "total" ]; then
STATE_PASS=$("$CHILLI_PATH_BIN" list | grep -wc "pass")
STATE_DNAT=$("$CHILLI_PATH_BIN" list | grep -wc "dnat")
STATE_NONE=$("$CHILLI_PATH_BIN" list | grep -wc "none")
2016-09-26 10:38:07 +02:00
else
2017-01-10 08:48:19 +01:00
STATE_PASS=$("$CHILLI_PATH_BIN" -s "$CHILLI_PATH_SOCK/chilli_$INSTANCE.sock" list | grep -wc "pass")
STATE_DNAT=$("$CHILLI_PATH_BIN" -s "$CHILLI_PATH_SOCK/chilli_$INSTANCE.sock" list | grep -wc "dnat")
STATE_NONE=$("$CHILLI_PATH_BIN" -s "$CHILLI_PATH_SOCK/chilli_$INSTANCE.sock" list | grep -wc "none")
2016-09-26 10:38:07 +02:00
fi
echo "pass.value $STATE_PASS"
echo "dnat.value $STATE_DNAT"
echo "none.value $STATE_NONE"