Projet

Général

Profil

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

root / plugins / chilli / chilli_sessions_ @ 17f78427

Historique | Voir | Annoter | Télécharger (2,77 ko)

1 cdd39555 Guillaume Marsay
#!/bin/sh
2 0057c660 Guillaume Marsay
# -*- sh -*-
3
4
: << =cut
5
6
=head1 NAME
7
8 cdd39555 Guillaume Marsay
chilli_sessions_ - Wildcard-plugin to monitor sessions state on Coova Chilli.
9 0057c660 Guillaume Marsay
10 5ee71111 Guillaume Marsay
=head1 DESCRIPTION
11 1ded68fc Guillaume Marsay
12
This wildcard plugin is for monitor the number of device with state pass/dnat/none on Coova Chilli instances.
13
14 0057c660 Guillaume Marsay
=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 cdd39555 Guillaume Marsay
  [chilli_sessions_*]
21 0057c660 Guillaume Marsay
      user root
22
23
This is a wildcard plugin. To monitor an instance, link
24 cdd39555 Guillaume Marsay
chilli_sessions_<instance> to this file. For example :
25 0057c660 Guillaume Marsay
26 cdd39555 Guillaume Marsay
  ln -s /usr/share/munin/plugins/chilli_sessions_ \
27
        /etc/munin/plugins/chilli_sessions_hotspot1
28 0057c660 Guillaume Marsay
29
will monitor hotspot1.
30
31
For monitor all instances use :
32
33 cdd39555 Guillaume Marsay
  ln -s /usr/share/munin/plugins/chilli_sessions_ \
34
        /etc/munin/plugins/chilli_sessions_total
35 0057c660 Guillaume Marsay
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 cdd39555 Guillaume Marsay
INSTANCE="${0##*chilli_}"
53 0057c660 Guillaume Marsay
CHILLI_PATH_BIN="/usr/sbin/chilli_query"
54
CHILLI_PATH_SOCK="/var/run"
55
56
57 cdd39555 Guillaume Marsay
case "$1" in
58 0057c660 Guillaume Marsay
  autoconf)
59 cdd39555 Guillaume Marsay
    if [ -r "$CHILLI_PATH_BIN" ]; then
60
      if [ "$INSTANCE" = "total" ]; then
61 0057c660 Guillaume Marsay
        echo "yes"
62
        exit 0
63
      else
64 7f3c3007 Guillaume Marsay
        if [ -r $CHILLI_PATH_SOCK/chilli_"$INSTANCE".sock ]; then
65 cdd39555 Guillaume Marsay
          echo "yes"
66 0057c660 Guillaume Marsay
          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 1ded68fc Guillaume Marsay
      find "$CHILLI_PATH_SOCK/" -name "chilli_*.sock" | while read file; do
79 cdd39555 Guillaume Marsay
        basename "$file" .sock | cut -d _ -f 2
80 0057c660 Guillaume Marsay
      done
81
82
      echo "total"
83 17f78427 Lars Kruse
84 1ded68fc Guillaume Marsay
      exit 0
85 0057c660 Guillaume Marsay
    ;;
86
  config)
87
    echo "graph_title Chilli $INSTANCE sessions"
88
    echo "graph_args --base 1000 -l 0"
89 212768ed dipohl
    echo "graph_category wireless"
90 0057c660 Guillaume Marsay
    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 cdd39555 Guillaume Marsay
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 0057c660 Guillaume Marsay
else
112 1ded68fc Guillaume Marsay
  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 0057c660 Guillaume Marsay
fi
116
117
echo "pass.value $STATE_PASS"
118
echo "dnat.value $STATE_DNAT"
119
echo "none.value $STATE_NONE"