2 # This is a local command to generate the various statistics that
3 # can then be displayed on an MRTG plot
5 # Your mrtg binary must live in one of the standard places
7 # The arguments (keywords) to the mrtg command are these
9 # a) content (you always get the node users and nodes)
10 # totalspots - all spots
11 # hfvhf - all spots split into HF and VHF
12 # wwv - two graphs of WWV, one SFI and R other A and K
14 # all - all of the above
17 # test - do everything except check for and run mrtg
18 # nomrtg - ditto (better name)
19 # dataonly - only generate the data files for mrtg
20 # cfgonly - only generate the mrtg.cfg file (like cfgmaker)
21 # runmrtg - run mrtg, this is probably used with dataonly
22 # - together with a home rolled mrtg.cfg
24 # Copyright (c) 2002 Dirk Koopman G1TLH
29 my ($self, $line) = @_;
33 for (split /\s+/, $line) { $want{lc $_} = 1};
34 $want{nomrtg} = 1 if $want{cfgonly} || $want{test};
36 return (1, "MRTG not installed") unless $want{nomrtg} || -e '/usr/bin/mrtg' || -e '/usr/local/bin/mrtg';
38 my $mc = new Mrtg or return (1, "cannot initialise Mrtg $!");
40 # do the users and nodes
41 my $users = DXChannel::get_all_users();
42 my $nodes = DXChannel::get_all_nodes();
44 $mc->cfgprint('users', [qw(unknaszero gauge)], 500,
45 "Users and Nodes on $main::mycall",
46 'Users / Nodes', 'Users', 'Nodes') unless $want{dataonly};
47 $mc->data('users', $users, $nodes, 'Users / Nodes') unless $want{cfgonly};
49 # do the total users and nodes
50 if ($want{totalusers} || $want{all}) {
51 $nodes = Route::Node::count();
52 $users = Route::User::count();
53 $mc->cfgprint('totalusers', [qw(unknaszero gauge)], 10000,
54 'Total Users and Nodes in the Visible Cluster Network',
55 'Users / Nodes', 'Users', 'Nodes') unless $want{dataonly};
56 $mc->data('totalusers', $users, $nodes, 'Total Users and Nodes in the Visible Cluster Network') unless $want{cfgonly};
60 if ($want{totalspots} || $want{all}) {
61 $mc->cfgprint('totalspots', [qw(unknaszero gauge noi)], 1000, 'Total Spots',
62 'Spots', 'Spots', 'Spots') unless $want{dataonly};
63 $mc->data('totalspots', $Spot::totalspots, $Spot::totalspots, 'Total Spots') unless $want{cfgonly};
64 $Spot::totalspots = 0;
67 # do the HF and VHF spots
68 if ($want{hfvhf} || $want{all}) {
69 $mc->cfgprint('hfspots', [qw(unknaszero gauge)], 1000, 'HF and VHF+ Spots',
70 'Spots', 'HF', 'VHF') unless $want{dataonly};
71 $mc->data('hfspots', $Spot::hfspots, $Spot::vhfspots, 'HF and VHF+ Spots') unless $want{cfgonly};
72 $Spot::hfspots = $Spot::vhfspots = 0;
76 if ($want{wwv} || $want{all}) {
77 $mc->cfgprint('wwvsfi', [qw(gauge)], 1000, 'WWV SFI and R',
78 'SFI / R', 'SFI', 'R') unless $want{dataonly};
79 $mc->data('wwvsfi', ($Geomag::r || $WCY::r), ($Geomag::sfi || $WCY::sfi), 'WWV SFI and R') unless $want{cfgonly};
80 $mc->cfgprint('wwvka', [qw(gauge)], 1000, 'WWV A and K',
81 'A / K', 'A', 'K') unless $want{dataonly};
82 $mc->data('wwvka', $Geomag::a, $Geomag::k, 'WWV A and K') unless $want{cfgonly};
86 if ($want{wcy} || $want{all}) {
87 $mc->cfgprint('wcyka', [qw(gauge)], 1000, 'WCY A and K',
88 'A / K', 'A', 'K') unless $want{dataonly};
89 $mc->data('wcyka', $WCY::a, $WCY::k, 'WCY A and K') unless $want{cfgonly};
95 my @out = $mc->run unless $want{nomrtg};