Projet

Général

Profil

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

root / plugins / modem / cisco-epc3010_ @ 31f5cc79

Historique | Voir | Annoter | Télécharger (4,93 ko)

1
#!/bin/bash
2
# -*- sh -*-
3

    
4
: << =cut
5

    
6
=head1 NAME
7

    
8
epc3010_ - munin-plugin to monitor Upstream/Downstream Power Levels and Signal to Noise Ratio on Cisco EPC3010 EuroDocsis 3.0 Data Modem 
9

    
10
=head1 CONFIGURATION
11

    
12
This plugin does not require configuration.
13
Create two links called epc3010_downstream and epc3010_upstream in order to use this script.
14

    
15
=head1 AUTHOR
16

    
17
Finn Andersen - xiphias256@gmail.com
18

    
19
=head1 LICENSE
20

    
21
GPLv2
22

    
23
=head1 MAGIC MARKERS
24

    
25
 #%# family=contrib
26
 #%# capabilities=autoconf
27

    
28
=cut
29

    
30
#
31
###############################################
32
#
33
# HISTORY
34
# v1.0   : Initial release
35
#
36
###############################################
37
#
38

    
39
# Decide if you want upstream og downstream info
40
DIRECTION=${0##*epc3010_}
41

    
42
# Check if argument is autoconfig or config
43
case "$1" in
44

    
45
autoconfig) 
46
  # Does your network have a Cisco EPC3010?
47
  curl -s http://192.168.100.1/Docsis_system.asp | grep -q "Cisco EPC3010" 
48
  if [ $? -eq 0 ]; then
49
    echo "yes"
50
    exit 0
51
  else
52
    echo "Can't find Cisco EPC3010 modem in your network"
53
    exit 1
54
  fi
55
  ;;
56
config) 
57
  if [ $DIRECTION == "downstream" ]; then
58
    printf "graph_title Cisco EPC3010 Downstream measurements\n";
59
    printf "graph_args -l 0 --base 1000\n"
60
    printf "graph_category other\n"
61
    printf "graph_vlabel Small number is Power Level, large number is SNR\n"
62
    printf "graph_info Downstream Signal to Noise Ratio (dB) and Power Level (dBmV) from Cisco EPC3010 modem. Info is scraped from statuspage on the modem (http://192.168.100.1)\n"
63
    printf "channel_1_pwr.label Channel 1 (dBmV)\n"
64
    printf "channel_1_pwr.type GAUGE\n"
65
    printf "channel_2_pwr.label Channel 2 (dBmV)\n"
66
    printf "channel_2_pwr.type GAUGE\n"
67
    printf "channel_3_pwr.label Channel 3 (dBmV)\n"
68
    printf "channel_3_pwr.type GAUGE\n"
69
    printf "channel_4_pwr.label Channel 4 (dBmV)\n"
70
    printf "channel_4_pwr.type GAUGE\n"
71
    printf "channel_5_pwr.label Channel 5 (dBmV)\n"
72
    printf "channel_5_pwr.type GAUGE\n"
73
    printf "channel_6_pwr.label Channel 6 (dBmV)\n"
74
    printf "channel_6_pwr.type GAUGE\n"
75
    printf "channel_7_pwr.label Channel 7 (dBmV)\n"
76
    printf "channel_7_pwr.type GAUGE\n"
77
    printf "channel_8_pwr.label Channel 8 (dBmV)\n"
78
    printf "channel_8_pwr.type GAUGE\n"
79
    printf "channel_1_snr.label Channel 1 (dB)\n"
80
    printf "channel_1_snr.type GAUGE\n"
81
    printf "channel_2_snr.label Channel 2 (dB)\n"
82
    printf "channel_2_snr.type GAUGE\n"
83
    printf "channel_3_snr.label Channel 3 (dB)\n"
84
    printf "channel_3_snr.type GAUGE\n"
85
    printf "channel_4_snr.label Channel 4 (dB)\n"
86
    printf "channel_4_snr.type GAUGE\n"
87
    printf "channel_5_snr.label Channel 5 (dB)\n"
88
    printf "channel_5_snr.type GAUGE\n"
89
    printf "channel_6_snr.label Channel 6 (dB)\n"
90
    printf "channel_6_snr.type GAUGE\n"
91
    printf "channel_7_snr.label Channel 7 (dB)\n"
92
    printf "channel_7_snr.type GAUGE\n"
93
    printf "channel_8_snr.label Channel 8 (dB)\n"
94
    printf "channel_8_snr.type GAUGE\n"
95
    exit 0
96
  fi
97
  if [ "$DIRECTION" == "upstream" ]; then
98
    printf "graph_title Cisco EPC3010 Upstream measurements\n"
99
    printf "graph_args -l 30 --base 1000\n"
100
    printf "graph_category other\n"
101
    printf "graph_vlabel Power level in dBmV\n"
102
    printf "graph_info Upstream Power Levels from Cisco EPC3010 modem,scraped from its statuspage (http://192.168.100.1)\n"
103
    printf "channel_1_pwr.label Channel 1 (dBmV)\n"
104
    printf "channel_1_pwr.type GAUGE\n"
105
    printf "channel_2_pwr.label Channel 2 (dBmV)\n"
106
    printf "channel_2_pwr.type GAUGE\n"
107
    printf "channel_3_pwr.label Channel 3 (dBmV)\n"
108
    printf "channel_3_pwr.type GAUGE\n"
109
    printf "channel_4_pwr.label Channel 4 (dBmV)\n"
110
    printf "channel_4_pwr.type GAUGE\n"
111
    exit 0
112
  fi
113
  ;;
114
esac
115

    
116

    
117
# Location and name of tempfile to parse
118
FILENAME=/tmp/cisco_epc3010.dump
119

    
120

    
121
# Get statuspage from the modem
122
curl -s -o $FILENAME http://192.168.100.1/Docsis_system.asp
123

    
124

    
125
# Bash arrays starts on index 0, we 0-pad the first index. It makes it easier later on..
126
SNR_ARRAY=( 0 $(cat $FILENAME | grep " ch_snr" | awk -F "nowrap>| <script" ' {print $2 }') )
127
PWR_ARRAY=( 0 $(cat $FILENAME | grep " ch_pwr" | awk -F "nowrap> | <script" ' {print $2 }') )
128
UP_PWR_ARRAY=( 0 $(cat $FILENAME | grep " up_pwr" | awk -F "nowrap>| <script" ' {print $2 }') )
129

    
130

    
131

    
132
#
133
# Downstream info - Modem outputs both PowerLevels and Signal to Noise Ratio
134
#
135

    
136
if [ "$DIRECTION" == "downstream" ]; then
137
  total=${#PWR_ARRAY[*]}
138
  for (( index=1; index<$(( $total )); index++ ))
139
  do
140
      printf "channel_%d_pwr.value %s\n" $index ${PWR_ARRAY[$index]}
141
  done
142

    
143
  total=${#SNR_ARRAY[*]}
144
  for (( index=1; index<$(( $total )); index++ ))
145
  do
146
      printf "channel_%d_snr.value %s\n" $index ${SNR_ARRAY[$index]}
147
  done
148

    
149
  exit 0
150
fi
151

    
152

    
153

    
154
#
155
# Upstream info - Modem outputs PowerLevels
156
#
157

    
158
if [ "$DIRECTION" == "upstream" ]; then
159
  total=${#UP_PWR_ARRAY[*]}
160
  for (( index=1; index<$(( $total )); index++ ))
161
  do
162
      printf "channel_%d_pwr.value %s\n" $index ${UP_PWR_ARRAY[$index]}
163
  done
164
  exit 0
165
fi
166

    
167

    
168
#
169
# Remove tempory file, used for parsing data
170
#
171
rm -f $FILENAME