-
Notifications
You must be signed in to change notification settings - Fork 2
/
prtg-cmuptime-sb8200.pl
62 lines (54 loc) · 1.99 KB
/
prtg-cmuptime-sb8200.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# Returns XML formatted data from a motorola cable modem for PRTG
# Skylar Gasai / https://github.com/YandereSkylar/cabletools
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Updated by John Walshaw 7-15-2018 for SB8200 in DOCSIC 3.1 mode
use LWP::Simple;
use Math::Round;
use List::Util qw(sum);
use List::Util qw( min max );
use List::MoreUtils qw( minmax );
my @dpw;
my @snr;
my @upw;
print '<?xml version="1.0" encoding="Windows-1252" ?>' . "\n";
print "<prtg>\n";
my $ua = LWP::UserAgent->new;
my $content = $ua->get("http://192.168.100.1/cmswinfo.html");
$content->decoded_content =~ m/Up Time<\/strong><\/td>\n <td width="40%">(.+)s.00<\/td><\/tr>/;
my $uptime = $1;
#print "<text> Up " . $uptime . "s</text>\n";
#$uptime =~ s/:/ /;
#$uptime .= "s";
$uptime =~ m/(\d+) days (\d+)h:(\d+)m:(\d+)/;
my $updays = $1;
my $uphours = $2;
my $upmins = $3;
my $upsecs = $4;
#print "Up $updays d $uphours h $upmins m $upsecs s\n";
$uptime = $upsecs + ($upmins * 60) + ($uphours * 3600) + ($updays * 86400);
#print "<text> Up " . $uptime . "s</text>\n";
print "<result>\n";
print "<channel>System Uptime</channel>\n";
print "<unit>TimeSeconds</unit>\n";
print "<LimitMode>1</LimitMode>\n";
print "<LimitMinWarning>86400</LimitMinWarning>\n";
print "<LimitWarningMsg>Uptime is less than 1 day</LimitWarningMsg>\n";
print "<value>" . $uptime . "</value>\n";
print "</result>\n";
print "</prtg>";
sub mean {
return sum(@_)/@_;
}