Projet

Général

Profil

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

root / plugins / chilli / chilli_sessions_ @ cdd39555

Historique | Voir | Annoter | Télécharger (2,67 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 CONFIGURATION
11

    
12
This plugin does not normally require configuration.
13

    
14
The plugin may need to run as root. This is configured like this:
15

    
16
  [chilli_sessions_*]
17
      user root
18

    
19
This is a wildcard plugin. To monitor an instance, link
20
chilli_sessions_<instance> to this file. For example :
21

    
22
  ln -s /usr/share/munin/plugins/chilli_sessions_ \
23
        /etc/munin/plugins/chilli_sessions_hotspot1
24

    
25
will monitor hotspot1.
26

    
27
For monitor all instances use :
28

    
29
  ln -s /usr/share/munin/plugins/chilli_sessions_ \
30
        /etc/munin/plugins/chilli_sessions_total
31

    
32
=head1 AUTHOR
33

    
34
OPENevents - Guillaume Marsay <guillaume.marsay@openevents.fr>
35

    
36
=head1 LICENSE
37

    
38
GPLv2
39

    
40
=head1 MAGIC MARKERS
41

    
42
 #%# family=auto
43
 #%# capabilities=autoconf suggest
44

    
45
=cut
46

    
47

    
48
INSTANCE="${0##*chilli_}"
49
CHILLI_PATH_BIN="/usr/sbin/chilli_query"
50
CHILLI_PATH_SOCK="/var/run"
51

    
52

    
53
case "$1" in
54
  autoconf)
55
    if [ -r "$CHILLI_PATH_BIN" ]; then
56
      if [ "$INSTANCE" = "total" ]; then
57
        echo "yes"
58
        exit 0
59
      else
60
        if [ -r "$CHILLI_PATH_SOCK"/chilli_"$INSTANCE".sock ]; then
61
          echo "yes"
62
          exit 0
63
        else
64
          echo "no ($CHILLI_PATH_SOCK/chilli_$INSTANCE.sock not found)"
65
          exit 0
66
        fi
67
      fi
68
    else
69
      echo "no ($CHILLI_PATH_BIN not found)"
70
      exit 0
71
    fi
72
    ;;
73
  suggest)
74
      INSTANCES_LIST=$(ls /var/run/chilli_*.sock)
75

    
76
      for file in $INSTANCES_LIST; do
77
        basename "$file" .sock | cut -d _ -f 2
78
      done
79

    
80
      echo "total"
81
      
82
            exit 0
83
    ;;
84
  config)
85
    echo "graph_title Chilli $INSTANCE sessions"
86
    echo "graph_args --base 1000 -l 0"
87
    echo "graph_category chilli"
88
    echo "none.label NONE"
89
    echo "none.min 0"
90
    echo "none.draw AREA"
91
    echo "none.colour ff8000"
92
    echo "dnat.label DNAT"
93
    echo "dnat.min 0"
94
    echo "dnat.draw STACK"
95
    echo "dnat.colour 0066b3"
96
    echo "pass.label PASS"
97
    echo "pass.draw STACK"
98
    echo "pass.min 0"
99
    echo "pass.colour 00cc00"
100

    
101
    exit 0
102
    ;;
103
esac
104

    
105
if [ "$INSTANCE" = "total" ]; then
106
  STATE_PASS=$("$CHILLI_PATH_BIN" list | grep -wc "pass")
107
  STATE_DNAT=$("$CHILLI_PATH_BIN" list | grep -wc "dnat")
108
  STATE_NONE=$("$CHILLI_PATH_BIN" list | grep -wc "none")
109
else
110
  STATE_PASS=$("$CHILLI_PATH_BIN" -s "$CHILLI_PATH_SOCK"/chilli_"$INSTANCE".sock list | grep -wc "pass")
111
  STATE_DNAT=$("$CHILLI_PATH_BIN" -s "$CHILLI_PATH_SOCK"/chilli_"$INSTANCE".sock list | grep -wc "dnat")
112
  STATE_NONE=$("$CHILLI_PATH_BIN" -s "$CHILLI_PATH_SOCK"/chilli_"$INSTANCE".sock list | grep -wc "none")
113
fi
114

    
115
echo "pass.value $STATE_PASS"
116
echo "dnat.value $STATE_DNAT"
117
echo "none.value $STATE_NONE"