From 0a1faadbc2cee1d5aa3690ed7fa32dd7443ed83d Mon Sep 17 00:00:00 2001 From: Dirk Koopman Date: Thu, 17 Nov 2016 16:10:39 +0000 Subject: [PATCH] more mrtg, store in 10ths and display to 0.1 sec --- cmd/mrtg.pl | 4 +- perl/DXChannel.pm | 4 +- perl/Mrtg.pm | 5 +- perl/cluster.pl | 171 +++++++++++++++++++++++++++------------------- 4 files changed, 107 insertions(+), 77 deletions(-) diff --git a/cmd/mrtg.pl b/cmd/mrtg.pl index 9339f0fc..ce1d1020 100644 --- a/cmd/mrtg.pl +++ b/cmd/mrtg.pl @@ -80,8 +80,8 @@ sub do_it dbg "mrtg: proc: cluster=$main::clssecs children=$main::cldsecs clock=$secs" if isdbg('mrtg'); $mc->cfgprint('proc', [qw(unknaszero withzeroes perminute)], 600, - "CPU Usage of node and its children in 10th of secs", - '10th Secs/min', 'Cluster Secs*10', 'Child Secs*10') unless $want{dataonly}; + "CPU Usage of node and its children in seconds", + 'CPU Secs/min', 'Node Secs 10ths', 'Child Secs 10ths', 0.1) unless $want{dataonly}; $mc->data('proc', int($main::clssecs*10+0.5), int($main::cldsecs*10+0.5), "Processor Usage") unless $want{cfgonly}; } diff --git a/perl/DXChannel.pm b/perl/DXChannel.pm index 7526099e..91900e4b 100644 --- a/perl/DXChannel.pm +++ b/perl/DXChannel.pm @@ -19,7 +19,7 @@ # firstly and OO about ninthly (if you don't like the design and you can't # improve it with better OO and thus make it smaller and more efficient, then tough). # -# Copyright (c) 1998-2000 - Dirk Koopman G1TLH +# Copyright (c) 1998-2016 - Dirk Koopman G1TLH # # # @@ -171,7 +171,7 @@ sub alloc if (@dxcc > 0) { $self->{dxcc} = $dxcc[1]->dxcc; $self->{itu} = $dxcc[1]->itu; - $self->{cq} = $dxcc[1]->cq; + $self->{cq} = $dxcc[1]->cq; } $self->{inqueue} = []; diff --git a/perl/Mrtg.pm b/perl/Mrtg.pm index 29e1259a..d95c41cb 100644 --- a/perl/Mrtg.pm +++ b/perl/Mrtg.pm @@ -68,8 +68,9 @@ sub data sub cfgprint { - my ($self, $name, $options, $max, $title, $legend, $iname, $oname) = @_; + my ($self, $name, $options, $max, $title, $legend, $iname, $oname, $yticsfactor) = @_; my $opt = join ', ', @$options, qw(withzeroes growright nopercent integer); + $yticsfactor ||= 1; $self->{mc}->print(<<"EOF"); @@ -82,7 +83,7 @@ MaxBytes[$name]: $max Title[$name]: $title Options[$name]: $opt YLegend[$name]: $legend -YTicsFactor[$name]: 1 +YTicsFactor[$name]: $yticsfactor ShortLegend[$name]: \  Legend1[$name]:Maximum No of $iname Legend2[$name]:Maximum No of $oname diff --git a/perl/cluster.pl b/perl/cluster.pl index 1419e318..4222132c 100755 --- a/perl/cluster.pl +++ b/perl/cluster.pl @@ -352,77 +352,6 @@ sub AGWrestart AGWMsg::init(\&new_channel); } -our $io_disconnected; - -sub idle_loop -{ - my $timenow = time; - - BPQMsg::process(); -# DXChannel::process(); - - # $DB::trace = 0; - - # do timed stuff, ongoing processing happens one a second - if ($timenow != $systime) { - reap() if $zombies; - $systime = $timenow; - my $days = int ($systime / 86400); - if ($systime_days != $days) { - $systime_days = $days; - $systime_daystart = $days * 86400; - } - IsoTime::update($systime); - DXCron::process(); # do cron jobs - DXCommandmode::process(); # process ongoing command mode stuff - DXXml::process(); - DXProt::process(); # process ongoing ak1a pcxx stuff - DXConnect::process(); - DXMsg::process(); - DXDb::process(); - DXUser::process(); - DXDupe::process(); - DXCron::process(); # do cron jobs - IsoTime::update($systime); - DXProt::process(); # process ongoing ak1a pcxx stuff - DXConnect::process(); - DXUser::process(); - AGWMsg::process(); - - Timer::handler(); - DXLog::flushall(); - } - - if (defined &Local::process) { - eval { - Local::process(); # do any localised processing - }; - dbg("Local::process error $@") if $@; - } - - while ($ending) { - my $dxchan; - - dbg("DXSpider Ending $ending"); - - unless ($io_disconnected++) { - - # disconnect users - foreach $dxchan (DXChannel::get_all_users) { - $dxchan->disconnect; - } - - # disconnect nodes - foreach $dxchan (DXChannel::get_all_nodes) { - next if $dxchan == $main::me; - $dxchan->disconnect(2); - } - $main::me->disconnect; - } - - Mojo::IOLoop->stop if --$ending <= 0; - } -} sub setup_start { @@ -648,12 +577,112 @@ sub setup_start #open(DB::OUT, "|tee /tmp/aa"); } +our $io_disconnected; + +sub idle_loop +{ + BPQMsg::process(); + + if (defined &Local::process) { + eval { + Local::process(); # do any localised processing + }; + dbg("Local::process error $@") if $@; + } + + while ($ending) { + my $dxchan; + + dbg("DXSpider Ending $ending"); + + unless ($io_disconnected++) { + + # disconnect users + foreach $dxchan (DXChannel::get_all_users) { + $dxchan->disconnect; + } + + # disconnect nodes + foreach $dxchan (DXChannel::get_all_nodes) { + next if $dxchan == $main::me; + $dxchan->disconnect(2); + } + $main::me->disconnect; + } + + Mojo::IOLoop->stop if --$ending <= 0; + } +} + +sub per_sec +{ + my $timenow = time; + + reap() if $zombies; + $systime = $timenow; + my $days = int ($systime / 86400); + if ($systime_days != $days) { + $systime_days = $days; + $systime_daystart = $days * 86400; + } + IsoTime::update($systime); + DXCron::process(); # do cron jobs + DXCommandmode::process(); # process ongoing command mode stuff + DXXml::process(); + DXProt::process(); # process ongoing ak1a pcxx stuff + DXConnect::process(); + DXMsg::process(); + DXDb::process(); + DXUser::process(); + DXDupe::process(); + DXCron::process(); # do cron jobs + IsoTime::update($systime); + DXProt::process(); # process ongoing ak1a pcxx stuff + DXConnect::process(); + DXUser::process(); + AGWMsg::process(); + + Timer::handler(); + DXLog::flushall(); +} + +sub per_10_sec +{ + +} + + +sub per_minute +{ + +} + +sub per_10_minute +{ + +} + +sub per_hour +{ + +} + +sub per_day +{ + +} setup_start(); my $main_loop = Mojo::IOLoop->recurring($idle_interval => \&idle_loop); my $log_flush_loop = Mojo::IOLoop->recurring($log_flush_interval => \&DXLog::flushall); my $cpusecs_loop = Mojo::IOLoop->recurring(5 => sub {my @t = times; $clssecs = $t[0]+$t[1]; $cldsecs = $t[2]+$t[3]}); +my $persec = Mojo::IOLoop->recurring(1 => \&per_sec); +my $per10sec = Mojo::IOLoop->recurring(10 => \&per_10_sec); +my $permin = Mojo::IOLoop->recurring(60 => \&per_minute); +my $per10min = Mojo::IOLoop->recurring(600 => \&per_10_minute); +my $perhour = Mojo::IOLoop->recurring(3600 => \&per_hour); +my $perday = Mojo::IOLoop->recurring(86400 => \&per_day); Web::start_node(); -- 2.43.0