From f637dc37d96a1715634734c5ef9d7d5ecd13a447 Mon Sep 17 00:00:00 2001 From: mh Date: Wed, 30 Jan 2008 21:37:34 +0000 Subject: rearranged some stuff git-svn-id: https://svn/ipuppet/trunk/modules/munin@607 d66ca3ae-40d7-4aa7-90d4-87d79ca94279 --- files/plugins/xen_vbd | 109 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100755 files/plugins/xen_vbd (limited to 'files/plugins/xen_vbd') diff --git a/files/plugins/xen_vbd b/files/plugins/xen_vbd new file mode 100755 index 0000000..238bf08 --- /dev/null +++ b/files/plugins/xen_vbd @@ -0,0 +1,109 @@ +#!/usr/bin/perl +# +# 2007-06-01 Zoltan HERPAI +# +# Credits goes for: +# Adam Crews for his xen_cpu plugin +# Mario Manno for his xen_traffic_all plugin +# +# Script to monitor the I/O usage of Xen domains +# Version 0.1 +# +#%# family=auto +#%# capabilities=autoconf + +# Location of xm tools +$XM = '/usr/sbin/xm'; +$XMTOP = '/usr/sbin/xentop'; + +# ah, parameters coming in +if ( defined($ARGV[0])) +{ + if ($ARGV[0] eq 'config') { $arg = 'config'; } + if ($ARGV[0] eq 'autoconf') { $arg = 'autoconf'; } + + if ( $arg eq 'autoconf' ) + { + if ( -e $XM && -e $XMTOP ) + { + print "yes\n"; + exit 0; + } + else + { + print "no ($XM and/or $XMTOP not found\n"; + exit 0; + } + } + + if ( $arg eq 'config' ) + { + %cnf = ( + 'graph_title' => 'Xen Domain I/O usage', + 'graph_args' => '--base 1024 -l 0', + 'graph_vlabel' => 'read (-), write (+)', + 'graph_category' => 'xen', + 'graph_info' => 'Display the I/O operations for each domain', + ); + + @domains = `$XM list`; + shift(@domains); # we don't need the header line + + foreach $domain ( @domains ) + { + ($dom, undef) = split(/\s/, $domain); + $dom =~ s/[-.]/_/g; + + $cnf{ $dom.'RD' . '.label' } = 'read'; + $cnf{ $dom.'RD' . '.type' } = 'COUNTER'; + $cnf{ $dom.'RD' . '.graph' } = 'no'; + $cnf{ $dom.'RD' . '.cdef' } = $dom.'RD,8,*'; + + $cnf{ $dom.'WR' . '.label' } = $dom; + $cnf{ $dom.'WR' . '.type' } = 'COUNTER'; + $cnf{ $dom.'WR' . '.negative' } = $dom.'RD'; + $cnf{ $dom.'WR' . '.cdef' } = $dom.'WR,8,*'; + + if ( "$cnt" == "0" ) + { + $cnf { "$dom" . '.draw' } = 'AREA'; + } + $cnt++; + } + + foreach $key ( sort(keys(%cnf)) ) + { + print "$key $cnf{$key}\n"; + } + exit 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(){ + chomp; + s/^\s*//g; + @tmp=split(/\s+/, $_); + next if $tmp[0] eq "NAME"; + + $domname = $tmp[0]; + $domname =~ s/[-.]/_/g; + $vbdrd = $tmp[14]; + $vbdwr = $tmp[15]; + + $vals{$domname."RD"}{'value'} = $vbdrd; + $vals{$domname."WR"}{'value'} = $vbdwr; +} + +foreach $key ( sort(keys(%vals)) ) +{ + print "$key.value " . ($vals{$key}{'value'}) . "\n"; +} + -- cgit v1.2.3