diff options
author | Micah Anderson <micah@riseup.net> | 2011-03-25 00:25:28 -0400 |
---|---|---|
committer | Micah Anderson <micah@riseup.net> | 2011-03-25 00:25:28 -0400 |
commit | 4b0487fbea9e4fb828e618182215df0318b7ed1e (patch) | |
tree | ebc06f3da869c9ffa83b5ea929e6ddfa82245c14 /files/plugins/xen_vbd | |
parent | d4ca996f8e6d28d7c8f8ad2c922d6205c6b94dcb (diff) | |
parent | 17df63f17e1aab4c15584b41fbe7fe925503e054 (diff) |
Merge remote-tracking branch 'immerda/master'
Conflicts:
manifests/host.pp
manifests/host/cgi.pp
manifests/plugin.pp
manifests/plugin/deploy.pp
manifests/plugins/apache.pp
manifests/plugins/base.pp
manifests/plugins/dom0.pp
manifests/plugins/gentoo.pp
manifests/plugins/interfaces.pp
manifests/plugins/linux.pp
manifests/plugins/openbsd.pp
manifests/plugins/physical.pp
manifests/plugins/selinux.pp
manifests/plugins/vserver.pp
Diffstat (limited to 'files/plugins/xen_vbd')
-rwxr-xr-x | files/plugins/xen_vbd | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/files/plugins/xen_vbd b/files/plugins/xen_vbd index 238bf08..4eca5a6 100755 --- a/files/plugins/xen_vbd +++ b/files/plugins/xen_vbd @@ -16,6 +16,10 @@ $XM = '/usr/sbin/xm'; $XMTOP = '/usr/sbin/xentop'; +# we cache xm list for 5 min for perfomance reasons +system('((find /var/lib/munin/plugin-state/xm_list.state -mmin -5 2>&1 | grep -qE \'^\/var\/lib\/munin\/plugin-state\/xm_list\.state$\') && [ `cat /var/lib/munin/plugin-state/xm_list.state | wc -l` -gt 1 ]) || /usr/sbin/xm list | grep -v "^Name .* Console$" > /var/lib/munin/plugin-state/xm_list.state'); +system('((find /var/lib/munin/plugin-state/xm_top.state -mmin -5 2>&1 | grep -qE \'^\/var\/lib\/munin\/plugin-state\/xm_top\.state$\') && [ `cat /var/lib/munin/plugin-state/xm_top.state | wc -l` -gt 1 ]) || /usr/sbin/xentop -b -i1 > /var/lib/munin/plugin-state/xm_top.state'); + # ah, parameters coming in if ( defined($ARGV[0])) { @@ -46,7 +50,7 @@ if ( defined($ARGV[0])) 'graph_info' => 'Display the I/O operations for each domain', ); - @domains = `$XM list`; + @domains = `cat /var/lib/munin/plugin-state/xm_list.state`; shift(@domains); # we don't need the header line foreach $domain ( @domains ) @@ -82,16 +86,24 @@ if ( defined($ARGV[0])) # No args, get rolling -# NAME STATE CPU(sec) CPU(%) MEM(k) MEM(%) MAXMEM(k) MAXMEM(%) VCPUS NETS NETTX(k) NETRX(k) VBDS VBD_OO VBD_RD VBD_WR SSID -$tmpfile = "/tmp/munin_xen_vbd_tmp"; - -system("$XMTOP -b -i1 > $tmpfile"); -open(I,"$tmpfile"); -while(<I>){ - chomp; - s/^\s*//g; - @tmp=split(/\s+/, $_); - next if $tmp[0] eq "NAME"; +my @stats = `cat /var/lib/munin/plugin-state/xm_top.state`; + +# remove the first 4 items that are junk that we don't need. +shift(@stats); +shift(@stats); +shift(@stats); +shift(@stats); + +my %vals; undef(%vals); + +foreach my $domain (@stats) { + # trim the leading whitespace + $domain =~ s/^\s+//; + my @tmp = split(/\s+/, $domain); + + # we need to change - and . to _ or things get weird with the graphs + # some decent quoting would probably fix this, but this works for now + $tmp[0] =~ s/[-.]/_/g; $domname = $tmp[0]; $domname =~ s/[-.]/_/g; |