root / plugins / chilli / chilli_sessions_ @ 17f78427
Historique | Voir | Annoter | Télécharger (2,77 ko)
| 1 |
#!/bin/sh |
|---|---|
| 2 |
# -*- sh -*- |
| 3 |
|
| 4 |
: << =cut |
| 5 |
|
| 6 |
=head1 NAME |
| 7 |
|
| 8 |
chilli_sessions_ - Wildcard-plugin to monitor sessions state on Coova Chilli. |
| 9 |
|
| 10 |
=head1 DESCRIPTION |
| 11 |
|
| 12 |
This wildcard plugin is for monitor the number of device with state pass/dnat/none on Coova Chilli instances. |
| 13 |
|
| 14 |
=head1 CONFIGURATION |
| 15 |
|
| 16 |
This plugin does not normally require configuration. |
| 17 |
|
| 18 |
The plugin may need to run as root. This is configured like this: |
| 19 |
|
| 20 |
[chilli_sessions_*] |
| 21 |
user root |
| 22 |
|
| 23 |
This is a wildcard plugin. To monitor an instance, link |
| 24 |
chilli_sessions_<instance> to this file. For example : |
| 25 |
|
| 26 |
ln -s /usr/share/munin/plugins/chilli_sessions_ \ |
| 27 |
/etc/munin/plugins/chilli_sessions_hotspot1 |
| 28 |
|
| 29 |
will monitor hotspot1. |
| 30 |
|
| 31 |
For monitor all instances use : |
| 32 |
|
| 33 |
ln -s /usr/share/munin/plugins/chilli_sessions_ \ |
| 34 |
/etc/munin/plugins/chilli_sessions_total |
| 35 |
|
| 36 |
=head1 AUTHOR |
| 37 |
|
| 38 |
OPENevents - Guillaume Marsay <guillaume.marsay@openevents.fr> |
| 39 |
|
| 40 |
=head1 LICENSE |
| 41 |
|
| 42 |
GPLv2 |
| 43 |
|
| 44 |
=head1 MAGIC MARKERS |
| 45 |
|
| 46 |
#%# family=auto |
| 47 |
#%# capabilities=autoconf suggest |
| 48 |
|
| 49 |
=cut |
| 50 |
|
| 51 |
|
| 52 |
INSTANCE="${0##*chilli_}"
|
| 53 |
CHILLI_PATH_BIN="/usr/sbin/chilli_query" |
| 54 |
CHILLI_PATH_SOCK="/var/run" |
| 55 |
|
| 56 |
|
| 57 |
case "$1" in |
| 58 |
autoconf) |
| 59 |
if [ -r "$CHILLI_PATH_BIN" ]; then |
| 60 |
if [ "$INSTANCE" = "total" ]; then |
| 61 |
echo "yes" |
| 62 |
exit 0 |
| 63 |
else |
| 64 |
if [ -r $CHILLI_PATH_SOCK/chilli_"$INSTANCE".sock ]; then |
| 65 |
echo "yes" |
| 66 |
exit 0 |
| 67 |
else |
| 68 |
echo "no ($CHILLI_PATH_SOCK/chilli_$INSTANCE.sock not found)" |
| 69 |
exit 0 |
| 70 |
fi |
| 71 |
fi |
| 72 |
else |
| 73 |
echo "no ($CHILLI_PATH_BIN not found)" |
| 74 |
exit 0 |
| 75 |
fi |
| 76 |
;; |
| 77 |
suggest) |
| 78 |
find "$CHILLI_PATH_SOCK/" -name "chilli_*.sock" | while read file; do |
| 79 |
basename "$file" .sock | cut -d _ -f 2 |
| 80 |
done |
| 81 |
|
| 82 |
echo "total" |
| 83 |
|
| 84 |
exit 0 |
| 85 |
;; |
| 86 |
config) |
| 87 |
echo "graph_title Chilli $INSTANCE sessions" |
| 88 |
echo "graph_args --base 1000 -l 0" |
| 89 |
echo "graph_category wireless" |
| 90 |
echo "none.label NONE" |
| 91 |
echo "none.min 0" |
| 92 |
echo "none.draw AREA" |
| 93 |
echo "none.colour ff8000" |
| 94 |
echo "dnat.label DNAT" |
| 95 |
echo "dnat.min 0" |
| 96 |
echo "dnat.draw STACK" |
| 97 |
echo "dnat.colour 0066b3" |
| 98 |
echo "pass.label PASS" |
| 99 |
echo "pass.draw STACK" |
| 100 |
echo "pass.min 0" |
| 101 |
echo "pass.colour 00cc00" |
| 102 |
|
| 103 |
exit 0 |
| 104 |
;; |
| 105 |
esac |
| 106 |
|
| 107 |
if [ "$INSTANCE" = "total" ]; then |
| 108 |
STATE_PASS=$("$CHILLI_PATH_BIN" list | grep -wc "pass")
|
| 109 |
STATE_DNAT=$("$CHILLI_PATH_BIN" list | grep -wc "dnat")
|
| 110 |
STATE_NONE=$("$CHILLI_PATH_BIN" list | grep -wc "none")
|
| 111 |
else |
| 112 |
STATE_PASS=$("$CHILLI_PATH_BIN" -s "$CHILLI_PATH_SOCK/chilli_$INSTANCE.sock" list | grep -wc "pass")
|
| 113 |
STATE_DNAT=$("$CHILLI_PATH_BIN" -s "$CHILLI_PATH_SOCK/chilli_$INSTANCE.sock" list | grep -wc "dnat")
|
| 114 |
STATE_NONE=$("$CHILLI_PATH_BIN" -s "$CHILLI_PATH_SOCK/chilli_$INSTANCE.sock" list | grep -wc "none")
|
| 115 |
fi |
| 116 |
|
| 117 |
echo "pass.value $STATE_PASS" |
| 118 |
echo "dnat.value $STATE_DNAT" |
| 119 |
echo "none.value $STATE_NONE" |
