2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00
contrib-munin/plugins/modem/cisco-epc3010_

188 lines
5.3 KiB
Bash
Executable File

#!/bin/bash
# -*- sh -*-
: << =cut
=head1 NAME
epc3010_ - munin-plugin to monitor Upstream/Downstream Power Levels and Signal to Noise Ratio on Cisco EPC3010 EuroDocsis 3.0 Data Modem
=head1 CONFIGURATION
This plugin does not require configuration.
Create two links called epc3010_downstream and epc3010_upstream in order to use this script.
=head1 AUTHOR
Finn Andersen - xiphias256@gmail.com
=head1 LICENSE
GPLv2
=head1 MAGIC MARKERS
#%# family=contrib
#%# capabilities=autoconf
=cut
#
###############################################
#
# HISTORY
# v1.0 : Initial release
#
###############################################
#
# Decide if you want upstream og downstream info
DIRECTION=${0##*epc3010_}
# Check if argument is autoconfig or config
case "$1" in
autoconfig)
# Does your network have a Cisco EPC3010?
curl -s http://192.168.100.1/Docsis_system.asp | grep -q "Cisco EPC3010"
if [ $? -eq 0 ]; then
echo "yes"
exit 0
else
echo "Can't find Cisco EPC3010 modem in your network"
exit 1
fi
;;
config)
if [ $DIRECTION == "downstream" ]; then
echo "graph_title Cisco EPC3010 Downstream measurements";
echo "graph_args -l 0 --base 1000"
echo "graph_category network"
echo "graph_vlabel (-) is Power Level (+) is SNR"
echo "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)"
echo "channel_1_pwr.label Channel 1 (dBmV)"
echo "channel_1_pwr.type GAUGE"
echo "channel_1_pwr.max 50"
echo "channel_2_pwr.label Channel 2 (dBmV)"
echo "channel_2_pwr.type GAUGE"
echo "channel_2_pwr.max 50"
echo "channel_3_pwr.label Channel 3 (dBmV)"
echo "channel_3_pwr.type GAUGE"
echo "channel_3_pwr.max 50"
echo "channel_4_pwr.label Channel 4 (dBmV)"
echo "channel_4_pwr.type GAUGE"
echo "channel_4_pwr.max 50"
echo "channel_5_pwr.label Channel 5 (dBmV)"
echo "channel_5_pwr.type GAUGE"
echo "channel_5_pwr.max 50"
echo "channel_6_pwr.label Channel 6 (dBmV)"
echo "channel_6_pwr.type GAUGE"
echo "channel_6_pwr.max 50"
echo "channel_7_pwr.label Channel 7 (dBmV)"
echo "channel_7_pwr.type GAUGE"
echo "channel_7_pwr.max 50"
echo "channel_8_pwr.label Channel 8 (dBmV)"
echo "channel_8_pwr.type GAUGE"
echo "channel_8_pwr.max 50"
echo "channel_1_snr.label Channel 1 (dB)"
echo "channel_1_snr.type GAUGE"
echo "channel_1_snr.max 50"
echo "channel_2_snr.label Channel 2 (dB)"
echo "channel_2_snr.type GAUGE"
echo "channel_2_snr.max 50"
echo "channel_3_snr.label Channel 3 (dB)"
echo "channel_3_snr.type GAUGE"
echo "channel_3_snr.max 50"
echo "channel_4_snr.label Channel 4 (dB)"
echo "channel_4_snr.type GAUGE"
echo "channel_4_snr.max 50"
echo "channel_5_snr.label Channel 5 (dB)"
echo "channel_5_snr.type GAUGE"
echo "channel_5_snr.max 50"
echo "channel_6_snr.label Channel 6 (dB)"
echo "channel_6_snr.type GAUGE"
echo "channel_6_snr.max 50"
echo "channel_7_snr.label Channel 7 (dB)"
echo "channel_7_snr.type GAUGE"
echo "channel_7_snr.max 50"
echo "channel_8_snr.label Channel 8 (dB)"
echo "channel_8_snr.type GAUGE"
echo "channel_8_snr.max 50"
exit 0
fi
if [ "$DIRECTION" == "upstream" ]; then
echo "graph_title Cisco EPC3010 Upstream measurements";
echo "graph_args -l 30 --base 1000"
echo "graph_category network"
echo "graph_vlabel Powerlevvel in dBmV"
echo "graph_info Upstream Power Levels from Cisco EPC3010 modem,scraped from it's statuspage (http://192.168.100.1)"
echo "channel_1_pwr.label Channel 1 (dBmV)"
echo "channel_1_pwr.type GAUGE"
echo "channel_1_pwr.max 60"
echo "channel_2_pwr.label Channel 2 (dBmV)"
echo "channel_2_pwr.type GAUGE"
echo "channel_2_pwr.max 60"
echo "channel_3_pwr.label Channel 3 (dBmV)"
echo "channel_3_pwr.type GAUGE"
echo "channel_3_pwr.max 60"
echo "channel_4_pwr.label Channel 4 (dBmV)"
echo "channel_4_pwr.type GAUGE"
echo "channel_4_pwr.max 60"
exit 0
fi
;;
esac
# Location and name of tempfile to parse
FILENAME=/tmp/cisco_epc3010.dump
# Get statuspage from the modem
curl -s -o $FILENAME http://192.168.100.1/Docsis_system.asp
# Bash arrays starts on index 0, we 0-pad the first index. It makes it easier later on..
SNR_ARRAY=( 0 $(cat $FILENAME | grep " ch_snr" | awk -F "nowrap>| <script" ' {print $2 }') )
PWR_ARRAY=( 0 $(cat $FILENAME | grep " ch_pwr" | awk -F "nowrap> | <script" ' {print $2 }') )
UP_PWR_ARRAY=( 0 $(cat $FILENAME | grep " up_pwr" | awk -F "nowrap>| <script" ' {print $2 }') )
#
# Downstream info - Modem outputs both PowerLevels and Signal to Noise Ratio
#
if [ "$DIRECTION" == "downstream" ]; then
total=${#PWR_ARRAY[*]}
for (( index=1; index<$(( $total )); index++ ))
do
printf "channel_%d_pwr.value %s\n" $index ${PWR_ARRAY[$index]}
done
total=${#SNR_ARRAY[*]}
for (( index=1; index<$(( $total )); index++ ))
do
printf "channel_%d_snr.value %s\n" $index ${SNR_ARRAY[$index]}
done
exit 0
fi
#
# Upstream info - Modem outputs PowerLevels
#
if [ "$DIRECTION" == "upstream" ]; then
total=${#UP_PWR_ARRAY[*]}
for (( index=1; index<$(( $total )); index++ ))
do
printf "channel_%d_pwr.value %s\n" $index ${UP_PWR_ARRAY[$index]}
done
exit 0
fi
# rm -f $FILENAME