3
# Plugin to monitor connections per second, for LVS loadbalancers.
13
# cps_mail.foo.boo_smtp
18
# Parameters understood:
21
# autoconf (optional - used by munin-config)
22
# suggest (optional - used by munin-config)
25
# Revision 1.1 2004/01/02 18:50:01 jimmyo
26
# Renamed occurrances of lrrd -> munin
28
# Revision 1.1.1.1 2004/01/02 15:18:07 jimmyo
29
# Import of LRRD CVS tree after renaming to Munin
31
# Revision 1.4 2003/11/07 17:43:16 jimmyo
32
# Cleanups and log entries
36
# Magic markers - optional - used by installation scripts and munin-config:
39
#%# capabilities=autoconf suggest
44
my $HOSTNAME="aibo.runbox.com";
46
if ( defined $ARGV[0] and $ARGV[0] eq "autoconf" )
50
if ( defined $ARGV[0] and $ARGV[0] eq "suggest" )
53
$sipvs = &ipvs (".", ".", $sipvs);
54
exit 0 if $sipvs == undef;
58
unless ($0 =~ /cps(?:_([^_]+)|)_(.+)\s*$/)
60
die "Could not parse name $0.\n";
66
#print "Name: $0\nPort: $port\nVip : $vip\n";
70
$ipvs = &ipvs ($vip, $port, $ipvs);
72
if ( defined $ARGV[0] and $ARGV[0] eq "config" )
74
&config ($vip, $port, $ipvs);
78
if (exists ($ipvs->{$vip}) and exists ($ipvs->{$vip}->{$port}))
80
foreach my $host (sort keys %{$ipvs->{$vip}->{$port}})
82
(my $fname = $host) =~ s/[.-]/_/g;
83
print "$fname.value ", $ipvs->{$vip}->{$port}->{$host}, "\n";;
89
system ("/sbin/ipvsadm -L --stats >/dev/null 2>/dev/null");
98
print "no (permission denied)\n";
103
print "no (ipvsadm not found)\n";
117
foreach my $vip (sort keys %{$ipvs})
119
foreach my $port (sort keys %{$ipvs->{$vip}})
121
print "cps_${vip}_$port\n";
133
print "host_name $HOSTNAME\n";
134
print "graph_title Loadbalanced ",($vip?$vip:"*"),"->",$port," connections\n";
135
print "graph_args -l 0\n";
136
print "graph_total total\n";
137
print "graph_vlabel connections / second\n";
140
if (exists ($ipvs->{$vip}) and exists ($ipvs->{$vip}->{$port}))
142
foreach my $host (sort keys %{$ipvs->{$vip}->{$port}})
144
(my $fname = $host) =~ s/[.-]/_/g;
147
print "$fname.draw AREA\n";
152
print "$fname.draw STACK\n";
154
print "$fname.type COUNTER\n";
156
print "$fname.label $host\n";
157
print "$fname.max 1000\n";
168
open (IPVS, "/sbin/ipvsadm -L --stats 2>/dev/null|") or return undef;
173
next if /^IP Virtual Server/;
174
next if /^Prot\s+LocalAddress/;
175
if (/^(\w+)\s+([\w\.-]+):([\w\d]+)\s+(\d+)\s+/)
177
$cvip = ($vip?$2:"");
180
elsif (/^\s+->\s+([^:]+):(\S+)\s+(\d+)\s+/)
182
$ipvs->{$cvip}->{$cport}->{$1} += $3;
185
close (IPVS) or return undef;