Projet

Général

Profil

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

root / plugins / router / cisco-epc3010_ @ 3e83f451

Historique | Voir | Annoter | Télécharger (4,82 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
#  1.0.1 : More secure handling of tempfiles
36
#
37
###############################################
38
#
39

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

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

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

    
117

    
118
FILENAME=$(mktemp -q) || exit 1
119
trap 'rm -f "$FILENAME"' EXIT
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 $(awk -F'[<>]' '/ ch_snr/{print $3}' "$FILENAME") )
127
PWR_ARRAY=( 0 $(awk -F'[<>]' '/ ch_pwr/{print $3}' "$FILENAME") )
128
UP_PWR_ARRAY=( 0 $(awk -F'[<>]' '/ up_pwr/{print $3}' "$FILENAME") )
129

    
130

    
131
#
132
# Downstream info - Modem outputs both Power Levels and Signal to Noise Ratio
133
#
134

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

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

    
150

    
151
#
152
# Upstream info - Modem outputs Power Levels
153
#
154

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