X-Git-Url: http://dxcluster.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=cmd%2Fmrtg.pl;h=7fd950d81873f2624aeb90f273c13f14da678463;hb=c4fc9fe526a8507baeeefa157386e62a1eafb229;hp=aeaab2e70e48245f2af473115c2e1604a4250762;hpb=7b8a8931b9fe531868777d5168b9a35baf37f0d9;p=spider.git diff --git a/cmd/mrtg.pl b/cmd/mrtg.pl index aeaab2e7..7fd950d8 100644 --- a/cmd/mrtg.pl +++ b/cmd/mrtg.pl @@ -28,6 +28,7 @@ # # # +use Time::HiRes qw( clock_gettime CLOCK_PROCESS_CPUTIME_ID ); sub handle { @@ -75,31 +76,14 @@ sub do_it } if (!$main::is_win && ($want{proc} || $want{all})) { - $ENV{COLUMNS} = 250; - my $secs; - my $f = new IO::File "top -b -o TIME+ -n 1 -c |"; - # dbg("$f"); - if ($f) { - while (<$f>) { - chomp; - my $l = $_; - dbg("mrtg: $l") if isdbg("mrtg"); - next unless $l =~ m{cluster\.pl$}; - next if $l =~ m{\d\s+su\s+}; - next if $l =~ m{\d\s+bash\s+}; - my @f = split /\s+/, $l; - my ($m, $s) = $f[10] =~ /\b(\d+):(\d\d\.\d\d)\b/; - $secs = ($m * 60) + $s; - dbg("mrtg: proc: $f[10] m: $m s: $s secs: $secs") if isdbg("mrtg"); - last; - } - $f->close; - - $mc->cfgprint('proc', [qw(noi unknaszero withzeroes perminute)], 5*60, - "Processor Usage", - 'Proc Secs/Min', 'Proc Secs', 'Proc Secs') unless $want{dataonly}; - $mc->data('proc', $secs, $secs, "Processor Usage") unless $want{cfgonly}; - } + my $secs = $main::clssecs + $main::cldsecs; + + dbg "mrtg: proc: cluster=$main::clssecs children=$main::cldsecs clock=$secs" if isdbg('mrtg'); + + $mc->cfgprint('proc', [qw(unknaszero withzeroes perminute)], 600, + "Processor Usage", + 'CPU 10th Secs/Min', 'Cluster Secs', 'Child Secs') unless $want{dataonly}; + $mc->data('proc', $main::clssecs*10, $main::cldsecs*10, "Processor Usage") unless $want{cfgonly}; } # do the users and nodes