Projet

Général

Profil

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

root / plugins / dhcpd-pools @ bd2944f8

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

1
#!/bin/bash
2
#    This program is free software; you can redistribute it and/or modify
3
#    it under the terms of the GNU General Public License as published by
4
#    the Free Software Foundation; either version 2 of the License, or
5
#    (at your option) any later version.
6
#
7
#    This program is distributed in the hope that it will be useful,
8
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
9
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
#    GNU General Public License for more details.
11
#
12
#    You should have received a copy of the GNU General Public License
13
#    along with this program; if not, write to the Free Software
14
#    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
15
#
16
# Written by Daniele Albrizio <daniele@albrizio.it> march 2014
17
# Requires dhcpd-pools - ISC dhcpd pools usage analysis http://dhcpd-pools.sourceforge.net/
18
#
19
####
20
#%# family=manual
21
#%# capabilities=autoconf,multigraph
22

    
23
export WARN=85
24
export CRIT=98
25
DHCPD_POOLS_BIN=/usr/local/bin/dhcpd-pools
26
DHCPDCONF=/etc/dhcp3/dhcpd.conf
27

    
28

    
29
if [ "$1" = "autoconf" ]; then
30
        echo yes
31
        exit 0
32
fi
33

    
34
$DHCPD_POOLS_BIN -c $DHCPDCONF --minsize=15 --limit=01 -fc  | grep -v "^$" | sort | sed 's/","/\t/g' | sed 's/"//g' |\
35
while read SCOPENAME IPSTART IPSTOP POOLMAX POOLCUR PERCENT TOUCH TC TCPERCENT BU BUPERCENT
36
do
37
    IPSTARTUS=`echo $IPSTART | sed 's/\./_/g'`
38
    let POOLWARN=${POOLMAX}*${WARN}/100
39
    let POOLCRIT=${POOLMAX}*${CRIT}/100
40
    let GRAPHTOP=${POOLMAX}*110/100
41
    if [ "$1" = "config" ]; then
42
        echo "multigraph ${SCOPENAME}_$IPSTARTUS"
43
        echo "graph_title $SCOPENAME $IPSTART -> $IPSTOP (${POOLMAX})"
44
        echo "graph_args --base 1000 -l 0 --upper-limit $GRAPHTOP"
45
        echo "graph_vlabel Active Leases"
46
        echo "graph_scale no"
47
        echo "graph_category DhcpPools"
48

    
49
        echo "pool.label $SCOPENAME Active Leases"
50
        echo "pool.info Pool utilization"
51
        echo "pool.type GAUGE"
52
        echo "pool.min 0"
53
        echo "pool.max $POOLMAX"
54
        echo "pool.colour 00ff00"
55
        echo "pool.draw AREA"
56
        echo "pool.warning $POOLWARN"
57
        echo "pool.line $POOLWARN:ffc000:$WARN%"
58
        echo "pool.critical $POOLCRIT"
59
        echo "pool_fover.label Peer available leases"
60
        echo "pool_fover.colour aaaaaa"
61
        echo "pool_fover.draw LINESTACK1"
62
        echo "pool_fover.type GAUGE"
63
        echo "pool_fover.line $POOLCRIT:ff0000:$CRIT%"
64
        echo "#"
65
    else
66
        echo "multigraph ${SCOPENAME}_$IPSTARTUS"
67
        echo "pool.value $POOLCUR"
68
        echo "pool_fover.value $BU"
69
    fi
70
done