Projet

Général

Profil

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

root / plugins / router / dartybox @ 5061ef1d

Historique | Voir | Annoter | Télécharger (3,56 ko)

1
#! /bin/sh
2

    
3
: <<=cut
4

    
5
=head1 NAME
6

    
7
dartybox - parse router information
8

    
9

    
10
=head1 CONFIGURATION
11

    
12
The following default configuration is used:
13

    
14
 [dartybox]
15
 env.IP 192.168.1.254
16

    
17

    
18
=head1 AUTHORS
19

    
20
Copyright (C) 2013 Steve Schnepp <steve.schnepp@pwkf.org>
21

    
22

    
23
=head1 LICENSE
24

    
25
GNU Library General Public License v2 only
26

    
27
SPDX-License-Identifier: GPL-2.0-only
28

    
29
=cut
30

    
31

    
32
. $MUNIN_LIBDIR/plugins/plugin.sh
33

    
34
is_multigraph
35

    
36
# fail on error
37
set -e
38

    
39
IP=${IP:-"192.168.1.254"}
40

    
41
if [ "$1" = "config" ]
42
then
43
	echo multigraph dbox_adsl_bw
44
	echo graph_title DartyBox Adsl Bandwidth
45
	echo graph_category network
46
	echo up.label UpStream
47
	echo down.label DownStream
48
	echo multigraph dbox_adsl_att
49
	echo graph_title DartyBox Adsl Attenuation
50
	echo graph_category network
51
	echo up.label UpStream
52
	echo down.label DownStream
53
	echo multigraph dbox_adsl_snr
54
	echo graph_title DartyBox Adsl SignalNoise Ratio
55
	echo graph_category network
56
	echo up.label UpStream
57
	echo down.label DownStream
58
	echo multigraph dbox_adsl_pkt
59
	echo graph_title DartyBox Adsl Packets
60
	echo graph_category network
61
	echo up.label UpStream
62
	echo down.label DownStream
63
	echo up_c.label UpStream "(Correctable)"
64
	echo down_c.label DownStream "(Correctable)"
65
	echo up_u.label UpStream "(Uncorrectable)"
66
	echo down_u.label DownStream "(Uncorrectable)"
67
	echo up.type DERIVE
68
	echo down.type DERIVE
69
	echo up_c.type DERIVE
70
	echo down_c.type DERIVE
71
	echo up_u.type DERIVE
72
	echo down_u.type DERIVE
73
	echo up.min 0
74
	echo down.min 0
75
	echo up_c.min 0
76
	echo down_c.min 0
77
	echo up_u.min 0
78
	echo down_u.min 0
79
	echo multigraph dbox_adsl_uptime
80
	echo graph_title DartyBox Adsl Uptime
81
	echo graph_category network
82
	echo graph_vlabel days
83
	echo uptime.label Uptime
84

    
85
	exit 0
86
fi
87

    
88
TMPFILE=$(mktemp)
89
trap 'rm -f $TMPFILE' EXIT
90

    
91
wget -qO "$TMPFILE" http://$IP/adslstats.html
92

    
93
[ "$MUNIN_DEBUG" = 1 ] && cat "$TMPFILE"
94

    
95
get() {
96
	PATTERN=$1
97
	gawk "match(\$0, /var $PATTERN\s+=\s+\"([^\"]+)\"/, a) { print a[1] }" $TMPFILE
98
}
99

    
100
getDays() {
101
	# Convert "20 jours 2 heures 2 mn" in a number of days
102
	echo "$@" | gawk "match(\$0, /([0-9.]+) jours ([0-9.]+) heures ([0-9.]+) mn/, a) { print a[1] + a[2]/24 + a[3]/1440 }"
103
}
104

    
105
echo multigraph dbox_adsl_bw
106
echo up.value $(get UpStream)
107
echo down.value $(get DownStream)
108
echo multigraph dbox_adsl_att
109
echo up.value $(get AttNear)
110
echo down.value $(get AttFar)
111
echo multigraph dbox_adsl_snr
112
echo up.value $(get SNRNear)
113
echo down.value $(get SNRFar)
114
echo multigraph dbox_adsl_pkt
115
echo up.value $(get RSWORDSNear)
116
echo down.value $(get RSWORDSFar)
117
echo up_c.value $(get RSCORRERRORNear)
118
echo down_c.value $(get RSCORRERRORFar)
119
echo up_u.value $(get RSUNCORRERRORNear)
120
echo down_u.value $(get RSUNCORRERRORFar)
121
echo multigraph dbox_adsl_uptime
122
echo uptime.value $(getDays $(get AdslUpTime))
123

    
124
exit 0
125

    
126
:<<'EOF'
127
var ADSLLineStatus = "Etabli";
128
var ADSLMode    = "G992_1_A  (G.DMT)   ";
129
var UpStream    = "704";
130
var DownStream  = "7616";
131
var AttNear     = "33.5";
132
var AttFar      = "16.5";
133
var SNRNear     = "11.0";
134
var SNRFar      = "15.0";
135
var HECCountNear= "4836";
136
var HECCountFar= "6";
137
var AdslVer1    = "0x81ef5379";
138
var AdslVer2    = "0x6397bde2";
139
var CmvVer1         = "0x6f249e71";
140
var CmvVer2         = "0xa703362e";
141
var ES15CntNear = "0";
142
var ES15CntFar  = "0";
143
var CRCErrorsNear = "641";
144
var CRCErrorsFar = "7";
145
var ES1CNTNear  = "8";
146
var ES1CNTFar   = "0";
147

    
148
var ESTOTCNTFar = "5";
149
var ESTOTCNTNear = "452";
150
var RSWORDSNear = "1802451823";
151
var RSWORDSFar  = "2881437753";
152
var RSCORRERRORNear  = "57293";
153
var RSCORRERRORFar  = "301";
154
var RSUNCORRERRORNear  = "641";
155
var RSUNCORRERRORFar  = "7";
156
var RSRatioNear  = "0";
157
var RSRatioFar  = "0";
158
var AdslUpTime = "20 jours 2 heures 2 mn";
159
EOF