Initial Commit

This commit is contained in:
bugmancx
2012-05-06 22:45:01 +01:00
parent 1d9d075835
commit 1c5520d978
13 changed files with 1306 additions and 0 deletions

65
plugins/hg612_attenuation Executable file
View File

@@ -0,0 +1,65 @@
#!/bin/sh
# -*- sh -*-
statsfile="/etc/munin/huawei/output.txt"
: << =cut
=head1 NAME
Line Stats - Plugin to get Huawei HG612 line stats
=head1 NOTES
Fetches Line Attenuation
=head1 AUTHOR
Adam Smith
=head1 LICENSE
GPL
=head1 MAGIC MARKERS
#%# family=auto
#%# capabilities=autoconf
=cut
if [ "$1" = "autoconf" ]; then
echo yes
exit 0
fi
if [ "$1" = "config" ]; then
echo "graph_title Line Attenuation (dB)"
echo 'graph_args --base 1000'
echo 'graph_vlabel Line Attenuation (dB)'
echo 'graph_category hg612'
echo 'graph_scale no'
# There are seven VDSL bands to monitor, so we want to get the band names
grep "VDSL Band Status" $statsfile | awk '{ print $4".label "$4"\n" $5".label "$5"\n" $6".label "$6"\n" $7".label "$7"\n" $8".label "$8"\n" $9".label "$9"\n" $10".label "$10}'
exit 0
fi;
# Fetch the values and display
for f in 4 5 6 7 8 9 10
do
echo -n $(grep "VDSL Band Status" $statsfile | awk '{ print $'$f' ".value " }')
echo " $(grep "Line Attenuation(dB)" $statsfile | sed -e 's/(/\ (/g' | awk '{ print $'$f' }')"
done
exit 0
fi

58
plugins/hg612_current_speed Executable file
View File

@@ -0,0 +1,58 @@
#!/bin/sh
# -*- sh -*-
statsfile="/etc/munin/huawei/output.txt"
: << =cut
=head1 NAME
Line Stats - Plugin to get Huawei HG612 line stats
=head1 NOTES
Fetches attainable line speed vs actual line speed
=head1 AUTHOR
Adam Smith
=head1 LICENSE
GPL
=head1 MAGIC MARKERS
#%# family=auto
#%# capabilities=autoconf
=cut
if [ "$1" = "autoconf" ]; then
echo yes
exit 0
fi
if [ "$1" = "config" ]; then
echo "graph_title Sync Speed"
echo 'graph_args --base 1000'
echo 'graph_vlabel Speed (bps)'
echo 'graph_category hg612'
echo 'graph_scale yes'
echo 'graph_order downstream upstream'
echo 'downstream.label Downstream'
echo 'downstream.draw AREA'
echo 'upstream.label Upstream'
echo 'upstream.draw AREA'
exit 0
fi;
echo -n "downstream.value "
echo $(grep Upstream $statsfile | grep Path | head -n 1 | awk '{ print $11 }')000
echo -n "upstream.value "
echo $(grep Upstream $statsfile | grep Path | head -n 1 | awk '{ print $6 }')000
exit 0
fi

82
plugins/hg612_errors Executable file
View File

@@ -0,0 +1,82 @@
#!/bin/sh
# -*- sh -*-
statsfile="/etc/munin/huawei/output.txt"
: << =cut
=head1 NAME
Line Stats - Plugin to get Huawei HG612 line stats
=head1 NOTES
Fetches Errors
=head1 AUTHOR
Adam Smith
=head1 LICENSE
GPL
=head1 MAGIC MARKERS
#%# family=auto
#%# capabilities=autoconf
=cut
if [ "$1" = "autoconf" ]; then
echo yes
exit 0
fi
if [ "$1" = "config" ]; then
echo "graph_title Errors"
echo "graph_args --base 1000"
echo "graph_vlabel errors down (-) / up (+) per ${graph_period}"
echo "graph_category hg612"
echo "graph_scale no"
echo "downcrc.label CRC errors"
echo "downcrc.type DERIVE"
echo "downcrc.graph no"
echo "upcrc.label CRC errors"
echo "upcrc.type DERIVE"
echo "upcrc.negative downcrc"
echo "upcrc.info Errors received"
echo "downfec.label FEC errors"
echo "downfec.type DERIVE"
echo "downfec.graph no"
echo "upfec.label FEC errors"
echo "upfec.type DERIVE"
echo "upfec.negative downfec"
echo "upfec.info Errors received"
echo "downhec.label HEC errors"
echo "downhec.type DERIVE"
echo "downhec.graph no"
echo "uphec.label HEC errors"
echo "uphec.type DERIVE"
echo "uphec.negative downhec"
echo "uphec.info Errors received"
exit 0
fi;
echo -n "downcrc.value " ; grep CRC $statsfile | tail -n 1 | awk '{ print $2 }'
echo -n "upcrc.value " ; grep CRC $statsfile | tail -n 1 | awk '{ print $3 }'
echo -n "downfec.value " ; grep FEC $statsfile | tail -n 1 | awk '{ print $2 }'
echo -n "upfec.value " ; grep FEC $statsfile | tail -n 1 | awk '{ print $3 }'
echo -n "downhec.value " ; grep HEC $statsfile | tail -n 1 | awk '{ print $2 }'
echo -n "uphec.value " ; grep HEC $statsfile | tail -n 1 | awk '{ print $3 }'
exit 0
fi

58
plugins/hg612_max_speed Executable file
View File

@@ -0,0 +1,58 @@
#!/bin/sh
# -*- sh -*-
statsfile="/etc/munin/huawei/output.txt"
: << =cut
=head1 NAME
Line Stats - Plugin to get Huawei HG612 line stats
=head1 NOTES
Fetches attainable line speed vs actual line speed
=head1 AUTHOR
Adam Smith
=head1 LICENSE
GPL
=head1 MAGIC MARKERS
#%# family=auto
#%# capabilities=autoconf
=cut
if [ "$1" = "autoconf" ]; then
echo yes
exit 0
fi
if [ "$1" = "config" ]; then
echo "graph_title Maximum Attainable Speed"
echo 'graph_args --base 1000'
echo 'graph_vlabel Max Speed (bps)'
echo 'graph_category hg612'
echo 'graph_scale yes'
echo 'graph_order downstream upstream'
echo 'downstream.label Downstream'
echo 'downstream.draw AREA'
echo 'upstream.label Upstream'
echo 'upstream.draw AREA'
exit 0
fi;
echo -n "downstream.value "
echo $(grep Upstream $statsfile | grep Max | head -n 1 | awk '{ print $10 }')000
echo -n "upstream.value "
echo $(grep Upstream $statsfile | grep Max | head -n 1 | awk '{ print $5 }')000
exit 0
fi

64
plugins/hg612_ptm1 Executable file
View File

@@ -0,0 +1,64 @@
#!/bin/sh
# -*- sh -*-
statsfile="/etc/munin/huawei/output.txt"
: << =cut
=head1 NAME
Line Stats - Plugin to get Huawei HG612 line stats
=head1 NOTES
Fetches WAN interface traffic
=head1 AUTHOR
Adam Smith
=head1 LICENSE
GPL
=head1 MAGIC MARKERS
#%# family=auto
#%# capabilities=autoconf
=cut
if [ "$1" = "autoconf" ]; then
echo yes
exit 0
fi
if [ "$1" = "config" ]; then
echo "graph_title ptm1 traffic"
echo "graph_args --base 1000"
echo "graph_vlabel bytes per ${graph_period}"
echo "graph_category hg612"
echo "down.label received"
echo "down.type DERIVE"
# echo "down.graph no"
echo "down.min 0"
# echo "down.max 1000000"
echo "down.cdef down,8,*"
echo "down.draw AREA"
echo "up.label sent"
echo "up.type DERIVE"
# echo "up.negative down"
echo "up.info Traffic of the ptm1 interface."
echo "up.min 0"
# echo "up.max 1000000"
echo "up.cdef up,8,*"
exit 0
fi;
echo -n "down.value " ; grep "RX bytes" $statsfile | sed -e 's/:/\ /g' | awk '{ print $3 }'
echo -n "up.value " ; grep "TX bytes" $statsfile | sed -e 's/:/\ /g' | awk '{ print $8 }'
exit 0
fi

101
plugins/hg612_ptm1_uptime Executable file
View File

@@ -0,0 +1,101 @@
#!/bin/sh
# -*- sh -*-
statsfile="/etc/munin/huawei/output.txt"
: << =cut
=head1 NAME
Line Stats - Plugin to get Huawei HG612 line stats
=head1 NOTES
Fetches Link Uptime
=head1 AUTHOR
Adam Smith
=head1 LICENSE
GPL
=head1 MAGIC MARKERS
#%# family=auto
#%# capabilities=autoconf
=cut
if [ "$1" = "autoconf" ]; then
echo yes
exit 0
fi
if [ "$1" = "config" ]; then
echo "graph_title ptm1 Uptime in days"
echo 'graph_args --base 1000 -l 0'
echo 'graph_vlabel VDSL Uptime in days'
echo 'graph_category hg612'
echo 'graph_scale no'
echo 'uptime.label Uptime in days'
echo 'uptime.draw AREA'
exit 0
fi;
echo -n "uptime.value "
# Value is presented in human-readbale format so we will have to do some maths to recalculate value to seconds
# WARNING - This code is awful!
# Get the uptime and split up the values
uptimefile=/tmp/uptimefile
grep "Since Link time" $statsfile | sed -e 's/Since\ Link\ time\ =\ //g' -e 's/days/days\n/g' -e 's/hours/hours\n/g' -e 's/min/min\n/g' > $uptimefile
# Work with each value, but sometimes there may be no value to work with due to sync drop etc.
#DAYS
days="$(grep days $uptimefile | awk '{ print $1 }')"
if [ -z "$days" ] ; then
days="0"
fi
days_sec=$(echo "$days * 86400" | bc);
#HOURS
hours="$(grep hours $uptimefile | awk '{ print $1 }')"
if [ -z "$hours" ] ; then
hours="0"
fi
hours_sec=$(echo "$hours * 3600" | bc);
#MIN
min="$(grep min $uptimefile | awk '{ print $1 }')"
if [ -z "$min" ] ; then
min="0"
fi
min_sec=$(echo "$min * 60" | bc);
#SEC
sec="$(grep sec $uptimefile | awk '{ print $1 }')"
if [ -z "$sec" ] ; then
sec="0"
fi
# Do the maths and return this to the output as decimal, in days
echo $(echo "$days_sec + $hours_sec + $min_sec + $sec" | bc) | awk '{ print $1/86400 }'
rm $uptimefile
exit 0
fi

57
plugins/hg612_pwr Executable file
View File

@@ -0,0 +1,57 @@
#!/bin/sh
# -*- sh -*-
statsfile="/etc/munin/huawei/output.txt"
: << =cut
=head1 NAME
Line Stats - Plugin to get Huawei HG612 line stats
=head1 NOTES
Fetches current Power
=head1 AUTHOR
Adam Smith
=head1 LICENSE
GPL
=head1 MAGIC MARKERS
#%# family=auto
#%# capabilities=autoconf
=cut
if [ "$1" = "autoconf" ]; then
echo yes
exit 0
fi
if [ "$1" = "config" ]; then
echo "graph_title Aggregate Tx Power"
echo 'graph_args --base 1000'
echo 'graph_vlabel Actual Aggregate Tx Power (dBm)'
echo 'graph_category hg612'
echo 'graph_scale no'
echo 'downstream.label Downstream'
echo 'downstream.draw LINE'
echo 'upstream.label Upstream'
echo 'upstream.draw LINE'
exit 0
fi;
echo -n "downstream.value "
echo $(grep Pwr $statsfile | head -n 1 | awk '{ print $2 }')
echo -n "upstream.value "
echo $(grep Pwr $statsfile | head -n 1 | awk '{ print $3 }')
exit 0
fi

58
plugins/hg612_snr Executable file
View File

@@ -0,0 +1,58 @@
#!/bin/sh
# -*- sh -*-
statsfile="/etc/munin/huawei/output.txt"
: << =cut
=head1 NAME
Line Stats - Plugin to get Huawei HG612 line stats
=head1 NOTES
Fetches current SNR
=head1 AUTHOR
Adam Smith
=head1 LICENSE
GPL
=head1 MAGIC MARKERS
#%# family=auto
#%# capabilities=autoconf
=cut
if [ "$1" = "autoconf" ]; then
echo yes
exit 0
fi
if [ "$1" = "config" ]; then
echo 'graph_title SNR Margin (dB)'
echo 'graph_args --base 1000'
echo 'graph_vlabel SNR Margin (dB)'
echo 'graph_category hg612'
echo 'graph_scale no'
echo 'graph_order upstream downstream'
echo 'downstream.label Downstream'
echo 'downstream.draw LINE'
echo 'upstream.label Upstream'
echo 'upstream.draw LINE'
exit 0
fi;
echo -n "upstream.value "
echo $(grep SNR $statsfile | head -n 1 | awk '{ print $4 }')
echo -n "downstream.value "
echo $(grep SNR $statsfile | head -n 1 | awk '{ print $3 }')
exit 0
fi

72
plugins/hg612_sync_speed Executable file
View File

@@ -0,0 +1,72 @@
#!/bin/sh
# -*- sh -*-
statsfile="/etc/munin/huawei/output.txt"
: << =cut
=head1 NAME
Line Stats - Plugin to get Huawei HG612 line stats
=head1 NOTES
Fetches current sync
=head1 AUTHOR
Adam Smith
=head1 LICENSE
GPL
=head1 MAGIC MARKERS
#%# family=auto
#%# capabilities=autoconf
=cut
if [ "$1" = "autoconf" ]; then
echo yes
exit 0
fi
if [ "$1" = "config" ]; then
echo "graph_title Attainable vs Current Sync Speed"
echo 'graph_args --base 1000'
echo 'graph_vlabel Sync Rate Actual (-) Attainable (+)'
echo 'graph_category hg612'
echo 'graph_scale yes'
echo 'downstream.label Downstream'
echo 'downstream.draw LINE'
echo 'downstream.graph no'
echo 'upstream.label Upstream'
echo 'upstream.draw LINE'
echo 'upstream.graph no'
echo 'maxdownstream.label Downstream'
echo 'maxdownstream.draw AREA'
echo 'maxdownstream.negative downstream'
echo 'maxupstream.label Upstream'
echo 'maxupstream.draw AREA'
echo 'maxupstream.negative upstream'
exit 0
fi;
echo -n "maxdownstream.value "
echo $(grep Upstream $statsfile | grep Max | head -n 1 | awk '{ print $10 }')000
echo -n "downstream.value "
echo $(grep Upstream $statsfile | grep Path | head -n 1 | awk '{ print $11 }')000
echo -n "maxupstream.value "
echo $(grep Upstream $statsfile | grep Max | head -n 1 | awk '{ print $5 }')000
echo -n "upstream.value "
echo $(grep Upstream $statsfile | grep Path | head -n 1 | awk '{ print $6 }')000
exit 0
fi