mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-21 18:41:03 +00:00
Whitespace cleanup
* remove trailing whitespace * remove empty lines at the end of files
This commit is contained in:
parent
ef851f0c34
commit
17f784270a
604 changed files with 2927 additions and 2945 deletions
|
@ -3,7 +3,7 @@
|
|||
# Script to minitor the cpu usage of Xen domains
|
||||
#
|
||||
# Author: Adam Crews <doo <at> shroom <dot> com>
|
||||
#
|
||||
#
|
||||
# License: GPL
|
||||
# Based on the original xen script from Matthias Pfafferodt, syntron at web.de
|
||||
#
|
||||
|
@ -55,7 +55,7 @@ if (defined($ARGV[0])) {
|
|||
'graph_vlabel' => 'Percent (%)',
|
||||
'graph_category' => 'virtualization',
|
||||
'graph_info' => 'Display the % of CPU Usage for each domain',
|
||||
);
|
||||
);
|
||||
|
||||
my @domains = `$XM list`;
|
||||
shift(@domains); # we dont need the header line
|
||||
|
@ -75,7 +75,7 @@ if (defined($ARGV[0])) {
|
|||
if ( "$cnt" == "0") { $cnf{$dom.'.draw'} = 'AREA'; }
|
||||
$cnt++;
|
||||
}
|
||||
|
||||
|
||||
foreach my $key (sort(keys(%cnf))) {
|
||||
print "$key $cnf{$key}\n";
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ if (defined($ARGV[0])) {
|
|||
|
||||
my @chunks; undef(@chunks);
|
||||
|
||||
{
|
||||
{
|
||||
# run the xentop command a few times because the first reading is not always accurate
|
||||
local $/ = undef;
|
||||
@chunks = split(/^xentop - .*$/m, `$XMTOP -b -i2 -d2`);
|
||||
|
@ -97,10 +97,10 @@ my @chunks; undef(@chunks);
|
|||
my @stats = split (/\n/,pop(@chunks));
|
||||
|
||||
# remove the first 4 items that are junk that we don't need.
|
||||
shift(@stats);
|
||||
shift(@stats);
|
||||
shift(@stats);
|
||||
shift(@stats);
|
||||
shift(@stats);
|
||||
shift(@stats);
|
||||
shift(@stats);
|
||||
shift(@stats);
|
||||
|
||||
my %vals; undef(%vals);
|
||||
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
# Based loosely on Adam Crews' xen_cpu script
|
||||
#
|
||||
# This script tries to measure the CPU usage of the Xen guests
|
||||
# accurately.
|
||||
# The problem with the current monitoring script is that these
|
||||
# accurately.
|
||||
# The problem with the current monitoring script is that these
|
||||
# scripts use the CPU output of xentop or xm list, which might be
|
||||
# inaccurate due to the resources used up at the time of the query by
|
||||
# the xm or xentop command.
|
||||
|
@ -50,7 +50,7 @@ if ( defined($ARGV[0]) )
|
|||
{
|
||||
$arg = 'autoconf';
|
||||
}
|
||||
|
||||
|
||||
if ( $arg eq 'autoconf')
|
||||
{
|
||||
if ( -e $XM && -e $XMTOP )
|
||||
|
@ -102,7 +102,7 @@ if ( defined($ARGV[0]) )
|
|||
exit 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
my @xmlist = `$XM list`;
|
||||
shift (@xmlist);
|
||||
|
||||
|
@ -124,7 +124,7 @@ if ( -e $TEMPFILE )
|
|||
$_ =~ /(\S+)\s+\S+\s+\S+\s+\d+\s+\S+\s+(\S+)/;
|
||||
$dom{$1}->{'oldtime'} = $2;
|
||||
}
|
||||
|
||||
|
||||
close FH;
|
||||
}
|
||||
|
||||
|
@ -137,14 +137,14 @@ foreach my $domain ( @xmlist )
|
|||
|
||||
$diff = $dom{$1}->{'newtime'} - $dom{$1}->{'oldtime'};
|
||||
$diff = sprintf("%.2f", $diff);
|
||||
|
||||
|
||||
# Calc the diff between old and new cputime, or reset the counter
|
||||
if ( $diff < 0 )
|
||||
{
|
||||
$diff = $dom{$1}->{'newtime'};
|
||||
}
|
||||
$dom{$1}->{'diff'} = $diff;
|
||||
|
||||
|
||||
# Calc a sum CPU usage
|
||||
$cpusum = $cpusum + $diff;
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ while (($key, $value) = each %dom)
|
|||
my $tmp = 0;
|
||||
$tmp = ( $dom{$key}->{'diff'} / $cpusum ) * 100;
|
||||
$dom{$key}->{'pc_time'} = sprintf("%.2f", $tmp);
|
||||
|
||||
|
||||
# Calc a percentage based on the _total_ available CPU time
|
||||
$tmp = 0;
|
||||
if ($tcpuavail != 0) {
|
||||
|
@ -177,7 +177,7 @@ while (($key, $value) = each %dom)
|
|||
} else {
|
||||
$dom{$key}->{'pc_tcpu'} = "U";
|
||||
}
|
||||
|
||||
|
||||
if ( $debug )
|
||||
{
|
||||
print "$key newtime: ".$dom{$key}->{'newtime'}.", oldtime: ".$dom{$key}->{'oldtime'}.", diff: ".$dom{$key}->{'diff'}.", pc_bytime ".$dom{$key}->{'pc_time'}.", pc_bytcpu ".$dom{$key}->{'pc_tcpu'}."\n";
|
||||
|
@ -190,4 +190,4 @@ open(FH, ">", $TEMPFILE) or die $!;
|
|||
print FH $curtime."\n";
|
||||
print FH @xmlist;
|
||||
close FH;
|
||||
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ if [ "$1" = "config" ]; then
|
|||
name=$( echo "$dom" | tr .- __ )
|
||||
#echo $name"UP.label $name"
|
||||
#echo $name"DOWN.label $name"
|
||||
|
||||
|
||||
echo "${name}Down.label received"
|
||||
echo "${name}Down.type COUNTER"
|
||||
echo "${name}Down.graph no"
|
||||
|
|
|
@ -16,13 +16,13 @@
|
|||
$XM = '/usr/sbin/xm';
|
||||
$XMTOP = '/usr/sbin/xentop';
|
||||
|
||||
# ah, parameters coming in
|
||||
# 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 ( $arg eq 'autoconf' )
|
||||
{
|
||||
if ( -e $XM && -e $XMTOP )
|
||||
{
|
||||
|
@ -35,7 +35,7 @@ if ( defined($ARGV[0]))
|
|||
exit 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( $arg eq 'config' )
|
||||
{
|
||||
%cnf = (
|
||||
|
@ -45,38 +45,38 @@ if ( defined($ARGV[0]))
|
|||
'graph_category' => 'virtualization',
|
||||
'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;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -98,12 +98,12 @@ foreach $domain (@stats)
|
|||
{
|
||||
$domain =~ s/^\s+//;
|
||||
@tmp = split(/\s+/, $domain);
|
||||
|
||||
|
||||
$domname = $tmp[0];
|
||||
$domname =~ s/[-.]/_/g;
|
||||
$vbdrd = $tmp[14];
|
||||
$vbdwr = $tmp[15];
|
||||
|
||||
|
||||
$vals{$domname."RD"}{'value'} = $vbdrd;
|
||||
$vals{$domname."WR"}{'value'} = $vbdwr;
|
||||
}
|
||||
|
@ -112,4 +112,4 @@ foreach $key ( sort(keys(%vals)) )
|
|||
{
|
||||
print "$key.value " . ($vals{$key}{'value'}) . "\n";
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue