change source of proc secs in cmd/mrtg.pl
authorDirk Koopman <djk@tobit.co.uk>
Wed, 16 Nov 2016 12:53:39 +0000 (12:53 +0000)
committerDirk Koopman <djk@tobit.co.uk>
Wed, 16 Nov 2016 12:53:39 +0000 (12:53 +0000)
Changes
cmd/mrtg.pl
perl/Web.pm

diff --git a/Changes b/Changes
index d27204dbbe3d9d9dcfa0d8908f29df93279b6315..b118fc01e9b4b2ff041802bf08d1d5963b3d053a 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,3 +1,5 @@
+16Nov16=======================================================================
+1. Change method of get processor seconds in cmd/mrtg.pl
 18Aug16=======================================================================
 1. Add CTY-2610
 2. put back msg total in & total out for mrtg and background mrtg
index aeaab2e70e48245f2af473115c2e1604a4250762..4a872d6172810942393cc967357689a2b90110ad 100644 (file)
@@ -28,6 +28,7 @@
 #
 #
 #
+use Time::HiRes qw( clock_gettime CLOCK_PROCESS_CPUTIME_ID );
 
 sub handle
 {
@@ -77,29 +78,13 @@ 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};
-               }
+
+               $secs = clock_gettime(CLOCK_PROCESS_CPUTIME_ID);
+               
+               $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};
        }
 
        # do the users and nodes
index e690f89a3b00c6aa73626fec925f330772bc881c..fbba02f652d27ebebf118c55e9da89aa4d647f0b 100644 (file)
@@ -14,9 +14,11 @@ use DXDebug;
 
 sub start_node
 {
+       dbg("Before Web::start_node");
+
        Mojo::IOLoop->start unless Mojo::IOLoop->is_running;
 
-       dbg("After Mojo::IOLoop");
+       dbg("After Web::start_node");
 }