1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-22 14:16:00 +00:00

Update script

This commit is contained in:
Guillaume Marsay 2017-01-05 08:26:00 +01:00 committed by GitHub
parent 0057c6607e
commit cdd3955588

View file

@ -1,11 +1,11 @@
#!/bin/bash #!/bin/sh
# -*- sh -*- # -*- sh -*-
: << =cut : << =cut
=head1 NAME =head1 NAME
chilli_ - Wildcard-plugin to monitor sessions state on Coova Chilli. chilli_sessions_ - Wildcard-plugin to monitor sessions state on Coova Chilli.
=head1 CONFIGURATION =head1 CONFIGURATION
@ -13,21 +13,21 @@ This plugin does not normally require configuration.
The plugin may need to run as root. This is configured like this: The plugin may need to run as root. This is configured like this:
[chilli_*] [chilli_sessions_*]
user root user root
This is a wildcard plugin. To monitor an instance, link This is a wildcard plugin. To monitor an instance, link
chilli_<instance> to this file. For example : chilli_sessions_<instance> to this file. For example :
ln -s /usr/share/munin/plugins/chilli_ \ ln -s /usr/share/munin/plugins/chilli_sessions_ \
/etc/munin/plugins/chilli_hotspot1 /etc/munin/plugins/chilli_sessions_hotspot1
will monitor hotspot1. will monitor hotspot1.
For monitor all instances use : For monitor all instances use :
ln -s /usr/share/munin/plugins/chilli_ \ ln -s /usr/share/munin/plugins/chilli_sessions_ \
/etc/munin/plugins/chilli_total /etc/munin/plugins/chilli_sessions_total
=head1 AUTHOR =head1 AUTHOR
@ -45,20 +45,20 @@ GPLv2
=cut =cut
INSTANCE=${0##*chilli_} INSTANCE="${0##*chilli_}"
CHILLI_PATH_BIN="/usr/sbin/chilli_query" CHILLI_PATH_BIN="/usr/sbin/chilli_query"
CHILLI_PATH_SOCK="/var/run" CHILLI_PATH_SOCK="/var/run"
case $1 in case "$1" in
autoconf) autoconf)
if [[ -r $CHILLI_PATH_BIN ]]; then if [ -r "$CHILLI_PATH_BIN" ]; then
if [[ $INSTANCE == "total" ]]; then if [ "$INSTANCE" = "total" ]; then
echo "yes" echo "yes"
exit 0 exit 0
else else
if [[ -r $CHILLI_PATH_SOCK/chilli_$INSTANCE.sock ]]; then if [ -r "$CHILLI_PATH_SOCK"/chilli_"$INSTANCE".sock ]; then
echo yes echo "yes"
exit 0 exit 0
else else
echo "no ($CHILLI_PATH_SOCK/chilli_$INSTANCE.sock not found)" echo "no ($CHILLI_PATH_SOCK/chilli_$INSTANCE.sock not found)"
@ -74,7 +74,7 @@ case $1 in
INSTANCES_LIST=$(ls /var/run/chilli_*.sock) INSTANCES_LIST=$(ls /var/run/chilli_*.sock)
for file in $INSTANCES_LIST; do for file in $INSTANCES_LIST; do
echo $(basename $file .sock | cut -d _ -f 2) basename "$file" .sock | cut -d _ -f 2
done done
echo "total" echo "total"
@ -102,15 +102,14 @@ case $1 in
;; ;;
esac esac
if [ "$INSTANCE" = "total" ]; then
if [[ $INSTANCE == "total" ]]; then STATE_PASS=$("$CHILLI_PATH_BIN" list | grep -wc "pass")
STATE_PASS=$($CHILLI_PATH_BIN list | grep "pass" | wc -l) STATE_DNAT=$("$CHILLI_PATH_BIN" list | grep -wc "dnat")
STATE_DNAT=$($CHILLI_PATH_BIN list | grep "dnat" | wc -l) STATE_NONE=$("$CHILLI_PATH_BIN" list | grep -wc "none")
STATE_NONE=$($CHILLI_PATH_BIN list | grep "none" | wc -l)
else else
STATE_PASS=$($CHILLI_PATH_BIN -s $CHILLI_PATH_SOCK/chilli_$INSTANCE.sock list | grep "pass" | wc -l) 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 "dnat" | wc -l) 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 "none" | wc -l) STATE_NONE=$("$CHILLI_PATH_BIN" -s "$CHILLI_PATH_SOCK"/chilli_"$INSTANCE".sock list | grep -wc "none")
fi fi
echo "pass.value $STATE_PASS" echo "pass.value $STATE_PASS"