Created
May 17, 2014 12:03
-
-
Save hggh/814c47dd889494a3406c to your computer and use it in GitHub Desktop.
haproxy curconns with instance support
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
# haproxy_curconn_l1 symlink in etc/munin/plugins | |
use strict; | |
use IO::Socket::UNIX; | |
my $ha_name; | |
if ($0 =~m /haproxy_maxconn_(.*)/ ) { | |
$ha_name = $1; | |
} | |
my $socket = exists $ENV{'socket'} ? $ENV{'socket'} : "/var/run/haproxy.socket"; | |
my $name = exists $ENV{'name'} ? $ENV{'name'} : $ha_name; | |
if ( exists $ARGV[0] and $ARGV[0] eq "config" ) { | |
print "graph_title haproxy curconns $name\n"; | |
print "graph_vlabel connections\n"; | |
print "graph_category haproxy\n"; | |
print "curconns.label current connections\n"; | |
print "graph_args -l 0\n"; | |
} | |
else { | |
my $currconns = "U"; | |
if ( -S $socket) { | |
my $sock = IO::Socket::UNIX->new( | |
Peer => $socket, | |
); | |
print $sock "show info\n"; | |
while (my $line = <$sock>) { | |
last if $line =~ /^\n/; | |
chomp($line); | |
if ($line =~m /CurrConns: (.*)/) { | |
$currconns = $1; | |
} | |
} | |
} | |
print "curconns.value $currconns\n"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/munin/plugin-conf.d/haproxy_curconn_l1.conf | |
[haproxy_curconn_l1] | |
user root | |
env.socket /var/run/haproxy-l1.socket |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment