X-Git-Url: http://dxcluster.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=cmd%2Fmrtg.pl;h=c88d5c7cf2ec367fc46a76f02cfc763a3cf24eea;hb=4b3a266a60049cbadb409a936e0888759b9b1fb6;hp=dba856e5b4495d429e78c6750255a4a9b8d8c791;hpb=cd03052d795bdb1b7127dc3d365ed7008db30cf7;p=spider.git diff --git a/cmd/mrtg.pl b/cmd/mrtg.pl index dba856e5..c88d5c7c 100644 --- a/cmd/mrtg.pl +++ b/cmd/mrtg.pl @@ -7,8 +7,6 @@ # you will need perl 5.6 (probably) to be able to run this command # -sub cfgprint($$@$$$$$); - my ($self, $line) = @_; # create the arg list @@ -17,42 +15,13 @@ for (split /\s+/, $line) { $want{lc $_} = 1}; return (1, "MRTG not installed") unless $want{test} || -e '/usr/bin/mrtg' || -e '/usr/local/bin/mrtg'; -my $dir = "$main::root/mrtg"; -my $html = "$main::root/html/mrtg"; -my $cfg = "$dir/mrtg.cfg"; - -my $mc = new IO::File ">$cfg" or return(1, "cannot open $cfg for mrtg writing"); - -# print out the header -print $mc <<"EOF"; -### Global Defaults - -# to get bits instead of bytes and graphs growing to the right -# Options[_]: growright, bits - -Htmldir: $html -Imagedir: $html -Logdir: $dir -Options[_]: growright - -## -## - -EOF - - -#dbg "$dir\n$html\n"; +my $mc = new Mrtg or return (1, "cannot initialise Mrtg $!"); # do the users and nodes my $users = DXChannel::get_all_users(); my $nodes = DXChannel::get_all_nodes(); -my $uptime = main::uptime(); -#dbg "$users $nodes $uptime\n"; -if (my $m = new IO::File ">$dir/users") { - print $m "$users\n$nodes\n$uptime\nUsers and Nodes\n"; - close $m; -} -cfgprint($mc, 'users', [qw(gauge)], 500, + +$mc->cfgprint('users', $users, $nodes, [qw(gauge)], 500, "Users and Nodes on $main::mycall", 'Users / Nodes', 'Users', 'Nodes'); @@ -60,73 +29,41 @@ cfgprint($mc, 'users', [qw(gauge)], 500, if ($want{totalusers} || $want{all}) { $nodes = Route::Node::count(); $users = Route::User::count(); - #dbg "$users $nodes $uptime\n"; - if (my $m = new IO::File ">$dir/totalusers") { - print $m "$users\n$nodes\n$uptime\nTotal Users and Nodes\n"; - close $m; - } - cfgprint($mc, 'totalusers', [qw(gauge)], 10000, + $mc->cfgprint('totalusers', $users, $nodes, [qw(gauge)], 10000, 'Total Users and Nodes in the Visible Cluster Network', 'Users / Nodes', 'Users', 'Nodes'); } # do the total spots if ($want{totalspots} || $want{all}) { - if (my $m = new IO::File ">$dir/totalspots") { - print $m "$Spot::totalspots\n$Spot::totalspots\n$uptime\nTotal Spots\n"; - close $m; - } - $Spot::totalspots = 0; - cfgprint($mc, 'totalspots', [qw(unknaszero gauge noi)], 1000, 'Total Spots', + $mc->cfgprint('totalspots', $Spot::totalspots, $Spot::totalspots, [qw(unknaszero gauge noi)], 1000, 'Total Spots', 'Spots', 'Spots', 'Spots'); + $Spot::totalspots = 0; } # do the HF and VHF spots if ($want{hfvhf} || $want{all}) { - if (my $m = new IO::File ">$dir/hfspots") { - print $m "$Spot::hfspots\n$Spot::vhfspots\n$uptime\nHF and VHF+ Spots\n"; - close $m; - } - $Spot::hfspots = $Spot::vhfspots = 0; - cfgprint($mc, 'hfspots', [qw(unknaszero gauge)], 1000, 'HF and VHF+ Spots', + $mc->cfgprint('hfspots', $Spot::hfspots, $Spot::vhfspots, [qw(unknaszero gauge)], 1000, 'HF and VHF+ Spots', 'Spots', 'HF', 'VHF'); + $Spot::hfspots = $Spot::vhfspots = 0; +} + +# wwv stuff +if ($want{wwv} || $want{all}) { + $mc->cfgprint('wwvsfi', ($Geomag::r || $WCY::r), ($Geomag::sfi || $WCY::sfi), [qw(gauge)], 1000, 'WWV SFI and R', + 'SFI / R', 'SFI', 'R'); + $mc->cfgprint('wwvka', $Geomag::a, $Geomag::k, [qw(gauge)], 1000, 'WWV A and K', + 'A / K', 'A', 'K'); +} + +# WCY stuff +if ($want{wcy} || $want{all}) { + $mc->cfgprint('wcyka', $WCY::a, $WCY::k, [qw(gauge)], 1000, 'WCY A and K', + 'A / K', 'A', 'K'); } # # do the mrtg thing # -close $mc; -my @out = `mrtg $cfg`; +my @out = $mc->run unless $want{test}; return (1, @out); - -sub cfgprint -{ - my ($mc, $name, $options, $max, $title, $legend, $iname, $oname) = @_; - my $opt = join ', ', @$options, qw(withzeroes gauge growright nopercent integer); - - print $mc <<"EOF"; - -# -# $title -# - -Target[$name]: `cat /spider/mrtg/$name` -MaxBytes[$name]: $max -Title[$name]: $title -Options[$name]: $opt -YLegend[$name]: $legend -YTicsFactor[$name]: 1 -ShortLegend[$name]: \  -Legend1[$name]:Maximum No of $iname -Legend2[$name]:Maximum No of $oname -LegendI[$name]:$iname -LegendO[$name]:$oname -PageTop[$name]:

$title

- - - - -
System: $main::mycall
Maintainer: $main::myemail
Description:$title
-EOF - -}