more mrtg, store in 10ths and display to 0.1 sec

This commit is contained in:
Dirk Koopman 2016-11-17 16:10:39 +00:00
parent 84a3c37a6d
commit 0a1faadbc2
4 changed files with 107 additions and 77 deletions

View File

@ -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 <font color=#00cc00>node</font> and its <font color=#0000ff>children</font> in 10th of secs",
'10th Secs/min', 'Cluster Secs*10', 'Child Secs*10') unless $want{dataonly};
"CPU Usage of <font color=#00cc00>node</font> and its <font color=#0000ff>children</font> 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};
}

View File

@ -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} = [];

View File

@ -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]: \&nbsp;
Legend1[$name]:Maximum No of $iname
Legend2[$name]:Maximum No of $oname

View File

@ -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();