Projet

Général

Profil

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

root / plugins / ipvs / ipvs_cps @ 8589c6df

Historique | Voir | Annoter | Télécharger (1,21 ko)

1
#!/bin/bash
2
# -*- bash -*-
3

    
4
: << =cut
5

    
6
=head1 NAME
7

    
8
ipvs_conn -Indicate the number of connections per second
9

    
10
=head1 CONFIGURATION
11

    
12
[ipvs_*]
13
user root
14
env.ips IP1 IP2
15

    
16
=head1 AUTHOR
17

    
18
Ricardo Fraile <rfrail3@yahoo.es>
19

    
20
=head1 LICENSE
21

    
22
GPLv2
23

    
24
=head1 MAGICK MARKERS
25

    
26
 #%# family=auto
27
 #%# capabilities=autoconf
28

    
29
=cut
30

    
31
. $MUNIN_LIBDIR/plugins/plugin.sh
32

    
33

    
34
IPLIST=$ips
35

    
36

    
37
if [ "$1" = "autoconf" ]; then
38
        echo yes 
39
        exit 0
40
fi
41

    
42
if [ "$1" = "config" ]; then
43

    
44
        echo 'graph_title Ipvs connections per second'
45
        echo 'graph_args --base 1000 -l 0 '
46
        echo 'graph_vlabel Connections'
47
        echo 'graph_scale no'
48
        echo 'graph_category loadbalancer'
49
        echo 'graph_info Indicate the number of connections per second.'
50

    
51
	for IP in $IPLIST; do
52
		NM=`echo $IP | md5sum | cut -d - -f1 | sed 's/ //g' | cut -b 5-9`
53
	        echo "a$NM.label $IP Connections"
54
        	echo "a$NM.type GAUGE"
55
	        echo "a$NM.min 0"
56
	done
57

    
58
        exit 0
59
fi
60

    
61

    
62

    
63

    
64
F1=`mktemp`
65
ipvsadm -l -n  --rate| nl > $F1
66

    
67
for IP in $IPLIST; do
68

    
69
	COUNT=`cat $F1 | grep -e TCP -e UDP | grep $IP  | awk '{print $4}'`
70
	NM=`echo $IP | md5sum | cut -d - -f1 | sed 's/ //g' | cut -b 5-9`
71
	echo a$NM.value $COUNT
72

    
73
done
74

    
75
# Remove temp file
76
rm -f $F1