Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / plugins / router / modem-nvg510 @ 6a79efee

Historique | Voir | Annoter | Télécharger (5,08 ko)

1 98afc91e Samuel Smith
#! /usr/bin/env perl
2
3
4
=head1 NAME
5
6 ab215a54 Samuel Smith
modem-nvg510 - Plugin to monitor Motorola/Arris NVG510 DSL modem stats (AT&T ADSL2+)
7 98afc91e Samuel Smith
8
=head1 CONFIGURATION
9
10
	[modem-nvg510]
11
	env.url http://192.168.1.254/cgi-bin/dslstatistics.ha
12
13 ab215a54 Samuel Smith
=head1 MAGIC MARKERS
14
15
	#%# family=auto
16
	#%# capabilities=autoconf
17
18 98afc91e Samuel Smith
=head1 AUTHOR
19
20
Samuel Smith <esaym (snail) cpan.org>
21
22
=cut
23
24
use strict;
25
use warnings;
26
use HTTP::Tiny;
27
28
29
30
use constant {
31 0602fba8 Samuel Smith
	down_rate => 2,
32
	up_rate => 3,
33
	sn_down => 23,
34
	sn_up => 24,
35
	line_attn_down => 25,
36
	line_attn_up => 26,
37
	power_down => 27,
38
	power_up => 28,
39
	err_sec_down => 29,
40
	err_sec_up => 30,
41
	los_down => 31,
42
	los_up => 32,
43
	lof_down => 33,
44
	lof_up => 34,
45
	fec_down => 35,
46
	fec_up => 36,
47
	crc_down => 37,
48
	crc_up => 38,
49 98afc91e Samuel Smith
};
50
51 ab215a54 Samuel Smith
52 98afc91e Samuel Smith
if(defined $ARGV[0] and $ARGV[0] eq 'autoconf'){
53 ab215a54 Samuel Smith
	my $url = $ENV{url} || "http://192.168.1.254/cgi-bin/dslstatistics.ha";
54 6eeb457f Samuel Smith
	my $html = HTTP::Tiny->new(timeout => 30 )->get($url);
55 ab215a54 Samuel Smith
56
	if($html->{success} && $html->{content} =~ m{Broadband Status}){
57
		print "yes\n";
58
	}
59
	else{
60
		print "no\n";
61
	}
62
63
	exit 0;
64 98afc91e Samuel Smith
}
65
66
if(defined $ARGV[0] and $ARGV[0] eq "config"){
67
	print q|multigraph nvg510_speed
68
graph_args --base 1000
69
graph_category network
70
graph_info This graph show modem upload and download speeds in kilo bits per second
71
graph_title Modem Link Speed
72
graph_vlabel Kbits per ${graph_period}
73
down_rate.label downstream kbps
74
down_rate.info Link downstream speed (kbits/second)
75
down_rate.type GAUGE
76
up_rate.label upstream kbps
77
up_rate.info Link upload speed (kbits/second)
78
up_rate.type GAUGE
79
80
multigraph nvg510_line_quality
81
graph_args --base 1000
82
graph_category network
83
graph_info This graph shows modem line quality statistics like attenuation and noise ratios.
84
graph_title Modem Line Quality
85
graph_vlabel Line Statistics
86
sn_down.label sn_down
87
sn_down.info Downstream signal to noise margin, in decibels (dB)
88
sn_down.type GAUGE
89
sn_up.label sn_up
90
sn_up.info Upstream signal to noise margin, in decibels (dB)
91
sn_up.type GAUGE
92
line_attn_down.label line_attn_down
93
line_attn_down.info Downstream reduction in signal strength, in decibels (dB)
94
line_attn_down.type GAUGE
95
line_attn_up.label line_attn_up
96
line_attn_up.info Upstream reduction in signal strength, in decibels (dB)
97
line_attn_up.type GAUGE
98
power_down.label power_down
99
power_down.info Downstream power output to one milliwatt (dBm)
100
power_down.type GAUGE
101
power_up.label power_up
102
power_up.info Upstream power output to one milliwatt (dBm)
103
power_up.type GAUGE
104
105
multigraph nvg510_error_counts
106
graph_args --base 1000
107
graph_category network
108
graph_info This graph shows internal error counters of the modem.
109
graph_title Modem Errors
110
graph_vlabel Modem Errors per ${graph_period}
111
fec_down.label fec_down
112
fec_down.info Downstream Forwarded Error Correction: Number of times received errored packets were fixed without a retry.
113
fec_down.type DERIVE
114
fec_down.min 0
115
fec_up.label fec_up
116
fec_up.info Upstream Forwarded Error Correction: Number of times received errored packets were fixed without a retry.
117
fec_up.type DERIVE
118
fec_up.min 0
119
crc_down.label crc_down
120
crc_down.info Downstream number of times data packets have had to be resent due to errors
121
crc_down.type DERIVE
122
crc_down.min 0
123
crc_up.label crc_up
124
crc_up.info Upstream number of times data packets have had to be resent due to errors
125
crc_up.type DERIVE
126
crc_up.min 0
127
err_sec_down.label err_sec_down
128
err_sec_down.info The number of unconnected seconds after being down for seven consecutive seconds
129
err_sec_down.type DERIVE
130
err_sec_down.min 0
131
err_sec_up.label err_sec_up
132
err_sec_up.info The number of unconnected seconds after being down for seven consecutive seconds
133
err_sec_up.type DERIVE
134
err_sec_up.min 0
135
los_down.label los_down
136
los_down.info Loss of signal: Number of times for any reason, the signal is lost
137
los_down.type DERIVE
138
los_down.min 0
139
los_up.label los_up
140
los_up.info Loss of signal: Number of times for any reason, the signal is lost
141
los_up.type DERIVE
142
los_up.min 0
143
lof_down.label lof_down
144
lof_down.info Loss of frame: Number of times the signal is detected, but cannot sync
145
lof_down.type DERIVE
146
lof_down.min 0
147
lof_up.label lof_up
148
lof_up.info Loss of frame: Number of times the signal is detected, but cannot sync
149
lof_up.type DERIVE
150
lof_up.min 0
151
|;
152
153 ab215a54 Samuel Smith
	exit 0;
154 98afc91e Samuel Smith
}
155
156
157
158
159
##########################  MAIN  #############################
160
161
my $url = $ENV{url} || "http://192.168.1.254/cgi-bin/dslstatistics.ha";
162 6eeb457f Samuel Smith
my $html = HTTP::Tiny->new(timeout => 30 )->get($url);
163 98afc91e Samuel Smith
die "Couldn't fetch $url" unless $html->{success};
164 0602fba8 Samuel Smith
my @stats = $html->{content} =~ m{<td class="col2">(.*?)</td>}sg;
165 98afc91e Samuel Smith
166 0602fba8 Samuel Smith
chomp(@stats);
167 98afc91e Samuel Smith
168
print qq|multigraph nvg510_speed
169
down_rate.value $stats[down_rate]
170
up_rate.value $stats[up_rate]
171
172
multigraph nvg510_line_quality
173
sn_down.value $stats[sn_down]
174
sn_up.value $stats[sn_up]
175
line_attn_down.value $stats[line_attn_down]
176
line_attn_up.value $stats[line_attn_up]
177
power_down.value $stats[power_down]
178
power_up.value $stats[power_up]
179
180
multigraph nvg510_error_counts
181
fec_down.value $stats[fec_down]
182
fec_up.value $stats[fec_up]
183
crc_down.value $stats[crc_down]
184
crc_up.value $stats[crc_up]
185
err_sec_down.value $stats[err_sec_down]
186
err_sec_up.value $stats[err_sec_up]
187
los_down.value $stats[los_down]
188
los_up.value $stats[los_up]
189
lof_down.value $stats[lof_down]
190
lof_up.value $stats[lof_up]
191
192
|;
193