2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00

plugin for monitor ipvs

This commit is contained in:
rfrail3 2012-10-22 12:32:51 +02:00
parent 8410e921e1
commit 5e94465b62
4 changed files with 394 additions and 0 deletions

109
plugins/ipvs/ipvs_active Executable file
View File

@ -0,0 +1,109 @@
#!/bin/bash
# -*- bash -*-
: << =cut
=head1 NAME
ipvs_conn -Indicate the number of active servers in ipvs
=head1 CONFIGURATION
[ipvs_*]
user root
env.ips IP1 IP2
=head1 AUTHOR
Ricardo Fraile <rfrail3@yahoo.es>
=head1 LICENSE
GPLv2
=head1 MAGICK MARKERS
#%# family=auto
#%# capabilities=autoconf
=cut
. $MUNIN_LIBDIR/plugins/plugin.sh
IPLIST=$ips
if [ "$1" = "autoconf" ]; then
echo yes
exit 0
fi
if [ "$1" = "config" ]; then
echo 'graph_title Ipvs Active Servers'
echo 'graph_args --base 1000 -l 0 '
echo 'graph_vlabel Servers'
echo 'graph_scale no'
echo 'graph_category Ipvs'
echo 'graph_info Indicate the number of active servers in Ipvs.'
for IP in $IPLIST; do
NM=`echo $IP | md5sum | cut -d - -f1 | sed 's/ //g' | cut -b 5-9`
echo "a$NM.label $IP Active"
echo "a$NM.type GAUGE"
echo "a$NM.min 0"
done
exit 0
fi
# Get line number of match listen ip
function get_ip {
# Read the output
ipvsadm -l -n | nl | while read line; do
# If match the ip, print the line number
if ( echo $line | grep -e $IP > /dev/null ); then
MAT=`echo $line | cut -d " " -f 1`
echo $MAT
fi
done
}
for IP in $IPLIST; do
COUNT="0"
ACTCONCNT="0"
INACTCONCNT="0"
F1=`mktemp`
MATCH=`get_ip`
ipvsadm -l -n | nl > $F1
# Parse lines
while read line; do
# Get line numbers
N=`echo $line | cut -d " " -f 1`
# If line number match the line number of the match listen ip, print the line...
if [ "$N" -gt "$MATCH" ]; then
# ... except if the line contain TCP word (this start an other listen)
if ( echo $line | grep TCP > /dev/null ); then
break
fi
COUNT=`expr $COUNT + 1`
fi
done < $F1
# Print values
NM=`echo $IP | md5sum | cut -d - -f1 | sed 's/ //g' | cut -b 5-9`
echo a$NM.value $COUNT
# Remove temp file
rm -f $F1
done

87
plugins/ipvs/ipvs_bps Executable file
View File

@ -0,0 +1,87 @@
#!/bin/bash
# -*- bash -*-
: << =cut
=head1 NAME
ipvs_conn -Indicate the number of bytes per second in ipvs
=head1 CONFIGURATION
[ipvs_*]
user root
env.ips IP1 IP2
=head1 AUTHOR
Ricardo Fraile <rfrail3@yahoo.es>
=head1 LICENSE
GPLv2
=head1 MAGICK MARKERS
#%# family=auto
#%# capabilities=autoconf
=cut
. $MUNIN_LIBDIR/plugins/plugin.sh
IPLIST=$ips
if [ "$1" = "autoconf" ]; then
echo yes
exit 0
fi
if [ "$1" = "config" ]; then
echo 'graph_title Ipvs Traffic'
echo 'graph_args --base 1000 -l 0 '
echo 'graph_vlabel Bytes in (-) / out (+)'
echo 'graph_category Ipvs'
echo 'graph_info Indicate the ipvs traffic.'
for IP in $IPLIST; do
NM=`echo $IP | md5sum | cut -d - -f1 | sed 's/ //g' | cut -b 5-9`
echo "down$NM.label Bytes $IP"
echo "down$NM.type GAUGE"
echo "down$NM.graph no"
echo "down$NM.cdef down$NM,8,*"
echo "down$NM.min 0"
echo "up$NM.label Bytes $IP"
echo "up$NM.type GAUGE"
echo "up$NM.negative down$NM"
echo "up$NM.cdef up$NM,8,*"
echo "up$NM.info Bytes in $i"
echo "up$NM.min 0"
done
exit 0
fi
F1=`mktemp`
ipvsadm -l -n --rate| nl > $F1
for IP in $IPLIST; do
COUNT1=`cat $F1 | grep TCP | grep $IP | awk '{print $7}'`
COUNT2=`cat $F1 | grep TCP | grep $IP | awk '{print $8}'`
NM=`echo $IP | md5sum | cut -d - -f1 | sed 's/ //g' | cut -b 5-9`
echo down$NM.value $COUNT1
echo up$NM.value $COUNT2
done
# Remove temp file
rm -f $F1

122
plugins/ipvs/ipvs_conn Executable file
View File

@ -0,0 +1,122 @@
#!/bin/bash
# -*- bash -*-
: << =cut
=head1 NAME
ipvs_conn -Indicate the number of connections in ipvs
=head1 CONFIGURATION
[ipvs_*]
user root
env.ips IP1 IP2
=head1 AUTHOR
Ricardo Fraile <rfrail3@yahoo.es>
=head1 LICENSE
GPLv2
=head1 MAGICK MARKERS
#%# family=auto
#%# capabilities=autoconf
=cut
. $MUNIN_LIBDIR/plugins/plugin.sh
IPLIST=$ips
if [ "$1" = "autoconf" ]; then
echo yes
exit 0
fi
if [ "$1" = "config" ]; then
echo 'graph_title Ipvs Connections'
echo 'graph_args --base 1000 -l 0 '
echo 'graph_vlabel Connections'
echo 'graph_scale no'
echo 'graph_category Ipvs'
echo 'graph_info Indicate the number of active and inactive connections in Ipvs.'
for IP in $IPLIST; do
NM=`echo $IP | md5sum | cut -d - -f1 | sed 's/ //g' | cut -b 5-9`
echo "a$NM.label $IP ActiveConn"
echo "a$NM.type GAUGE"
echo "a$NM.min 0"
echo "i$NM.label $IP InActiveConn"
echo "i$NM.type GAUGE"
echo "i$NM.min 0"
done
exit 0
fi
# Get line number of match listen ip
function get_ip {
# Read the output
ipvsadm -l -n | nl | while read line; do
# If match the ip, print the line number
if ( echo $line | grep -e $IP > /dev/null ); then
MAT=`echo $line | cut -d " " -f 1`
echo $MAT
fi
done
}
for IP in $IPLIST; do
COUNT="0"
ACTCONCNT="0"
INACTCONCNT="0"
F1=`mktemp`
MATCH=`get_ip`
ipvsadm -l -n | nl > $F1
# Parse lines
while read line; do
# Get line numbers
N=`echo $line | cut -d " " -f 1`
# If line number match the line number of the match listen ip, print the line...
if [ "$N" -gt "$MATCH" ]; then
# ... except if the line contain TCP word (this start an other listen)
if ( echo $line | grep TCP > /dev/null ); then
break
fi
# Get ActiveConn number
NUM1=`echo $line | awk '{print $6}'`
# Sum it
ACTCONCNT=$(( ACTCONCNT + NUM1))
# Get InActConn number
NUM2=`echo $line | awk '{print $7}'`
# Sum it
INACTCONCNT=$(( INACTCONCNT + NUM2))
COUNT=`expr $COUNT + 1`
fi
done < $F1
# Print values
NM=`echo $IP | md5sum | cut -d - -f1 | sed 's/ //g' | cut -b 5-9`
echo a$NM.value $(( ACTCONCNT / COUNT ))
echo i$NM.value $(( INACTCONCNT / COUNT ))
# Remove temp file
rm -f $F1
done

76
plugins/ipvs/ipvs_cps Executable file
View File

@ -0,0 +1,76 @@
#!/bin/bash
# -*- bash -*-
: << =cut
=head1 NAME
ipvs_conn -Indicate the number of conectios per second
=head1 CONFIGURATION
[ipvs_*]
user root
env.ips IP1 IP2
=head1 AUTHOR
Ricardo Fraile <rfrail3@yahoo.es>
=head1 LICENSE
GPLv2
=head1 MAGICK MARKERS
#%# family=auto
#%# capabilities=autoconf
=cut
. $MUNIN_LIBDIR/plugins/plugin.sh
IPLIST=$ips
if [ "$1" = "autoconf" ]; then
echo yes
exit 0
fi
if [ "$1" = "config" ]; then
echo 'graph_title Ipvs connectios per second'
echo 'graph_args --base 1000 -l 0 '
echo 'graph_vlabel Connections'
echo 'graph_scale no'
echo 'graph_category Ipvs'
echo 'graph_info Indicate the number of connections per second.'
for IP in $IPLIST; do
NM=`echo $IP | md5sum | cut -d - -f1 | sed 's/ //g' | cut -b 5-9`
echo "a$NM.label $IP Connections"
echo "a$NM.type GAUGE"
echo "a$NM.min 0"
done
exit 0
fi
F1=`mktemp`
ipvsadm -l -n --rate| nl > $F1
for IP in $IPLIST; do
COUNT=`cat $F1 | grep TCP | grep $IP | awk '{print $4}'`
NM=`echo $IP | md5sum | cut -d - -f1 | sed 's/ //g' | cut -b 5-9`
echo a$NM.value $COUNT
done
# Remove temp file
rm -f $F1