mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-09-19 09:03:20 +00:00
CPU graph now graphs cpu time used over the 5 min period, not the instantaneous CPU usage at the moment when munin runs. It no longer requires a 2 iteration run of xentop.
This commit is contained in:
parent
f8264132d3
commit
1e301c2d8e
1 changed files with 28 additions and 32 deletions
|
@ -74,6 +74,7 @@ GPLv2
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
|
use Munin::Plugin;
|
||||||
|
|
||||||
# autoconf - quite simple
|
# autoconf - quite simple
|
||||||
if ($ARGV[0] eq "autoconf") {
|
if ($ARGV[0] eq "autoconf") {
|
||||||
|
@ -116,39 +117,32 @@ sub trim_label {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Global variables
|
# Global variables
|
||||||
my (%domains,@xentop,$domain,$munindomain,$cpusec,$cpupercent,$memk,$mempercent,$maxmemk,$maxmempercent,$nettxk,$netrxk,$vbdrd,$vbdwr);
|
my (%domains,$domain,$munindomain,$cpusecs,$memk,$nettxk,$netrxk,$vbdrd,$vbdwr);
|
||||||
|
|
||||||
# We run xentop with two iterations (the first one always returns 0 for CPU %)
|
open (XENTOP,"xentop -b -f -i1 |") or die "Could not execute xentop, $!";
|
||||||
open (XENTOP,"xentop -b -f -i2 |") or die "Could not execute xentop, $!";
|
|
||||||
|
|
||||||
# We parse the output backwards to process only the last iteration
|
|
||||||
@xentop = reverse(<XENTOP>); close(XENTOP);
|
|
||||||
|
|
||||||
# Now we build a hash of hashes to store information
|
# Now we build a hash of hashes to store information
|
||||||
foreach (@xentop) {
|
while (<XENTOP>) {
|
||||||
# Some cleaning first
|
# Some cleaning first
|
||||||
s/^\s+//; chomp;
|
s/^\s+//; chomp;
|
||||||
# We stop processing at the headers
|
# Skip the headers
|
||||||
if (/^NAME/) { last; } else {
|
next if /^NAME/;
|
||||||
|
|
||||||
# We define only what we need
|
# We define only what we need
|
||||||
($domain,undef,undef,$cpupercent,$memk,undef,undef,undef,undef,undef,$nettxk,$netrxk,undef,undef,$vbdrd,$vbdwr,undef,undef,undef) = split(/\s+/);
|
($domain,undef,$cpusecs,undef,$memk,undef,undef,undef,undef,undef,$nettxk,$netrxk,undef,undef,$vbdrd,$vbdwr,undef,undef,undef) = split(/\s+/);
|
||||||
|
|
||||||
# We have to store the domain name in a separate variable
|
# We have to store the sanitised domain name in a separate variable
|
||||||
# in which we replace - and . by _
|
$domains{$domain}{'munindomain'} = clean_fieldname($domain);
|
||||||
$domains{$domain}{'munindomain'} = $domain;
|
|
||||||
$domains{$domain}{'munindomain'} =~ s/[-.]/_/g;
|
|
||||||
|
|
||||||
# We need the remaining data only for a normal run
|
# We need the remaining data only for a normal run
|
||||||
if ($ARGV[0] eq "") {
|
if ($ARGV[0] eq "") {
|
||||||
$domains{$domain}{'cpupercent'} = $cpupercent;
|
$domains{$domain}{'cpusecs'} = $cpusecs;
|
||||||
$domains{$domain}{'mem'} = $memk;
|
$domains{$domain}{'mem'} = $memk;
|
||||||
$domains{$domain}{'nettx'} = $nettxk;
|
$domains{$domain}{'nettx'} = $nettxk;
|
||||||
$domains{$domain}{'netrx'} = $netrxk;
|
$domains{$domain}{'netrx'} = $netrxk;
|
||||||
$domains{$domain}{'vbdrd'} = $vbdrd;
|
$domains{$domain}{'vbdrd'} = $vbdrd;
|
||||||
$domains{$domain}{'vbdwr'} = $vbdwr;
|
$domains{$domain}{'vbdwr'} = $vbdwr;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -157,16 +151,18 @@ foreach (@xentop) {
|
||||||
#
|
#
|
||||||
|
|
||||||
if ($ARGV[0] eq "config") {
|
if ($ARGV[0] eq "config") {
|
||||||
print "multigraph xen_cpu\n";
|
print "multigraph xen_cpu_time\n";
|
||||||
print "graph_title Xen domains CPU usage\n";
|
print "graph_title Xen domains CPU time\n";
|
||||||
print "graph_args --base 1000 -l 0 --upper-limit 100\n";
|
print "graph_args --base 1000 -l 0\n";
|
||||||
print "graph_vlabel %\n";
|
print "graph_vlabel %\n";
|
||||||
print "graph_scale no\n";
|
print "graph_scale no\n";
|
||||||
print "graph_category xen\n";
|
print "graph_category xen\n";
|
||||||
print "graph_info This graph shows CPU usage for each Xen domain.\n";
|
print "graph_info This graph shows CPU time for each Xen domain.\n";
|
||||||
for $domain (sort(keys(%domains))) {
|
for $domain (sort(keys(%domains))) {
|
||||||
print "$domains{$domain}{'munindomain'}_cpu.label ".trim_label('pos',$domain)."\n";
|
print "$domains{$domain}{'munindomain'}_cpu_time.label ".trim_label('pos',$domain)."\n";
|
||||||
print "$domains{$domain}{'munindomain'}_cpu.draw AREASTACK\n";
|
print "$domains{$domain}{'munindomain'}_cpu_time.type COUNTER\n";
|
||||||
|
print "$domains{$domain}{'munindomain'}_cpu_time.cdef $domains{$domain}{'munindomain'}_cpu_time,100,*\n";
|
||||||
|
print "$domains{$domain}{'munindomain'}_cpu_time.draw AREASTACK\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
print "\nmultigraph xen_mem\n";
|
print "\nmultigraph xen_mem\n";
|
||||||
|
@ -223,9 +219,9 @@ if ($ARGV[0] eq "config") {
|
||||||
# Normal run
|
# Normal run
|
||||||
#
|
#
|
||||||
|
|
||||||
print "multigraph xen_cpu\n";
|
print "multigraph xen_cpu_time\n";
|
||||||
for $domain (sort(keys(%domains))) {
|
for $domain (sort(keys(%domains))) {
|
||||||
print "$domains{$domain}{'munindomain'}_cpu.value $domains{$domain}{'cpupercent'}\n";
|
print "$domains{$domain}{'munindomain'}_cpu_time.value $domains{$domain}{'cpusecs'}\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
print "\nmultigraph xen_mem\n";
|
print "\nmultigraph xen_mem\n";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue