mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-22 14:16:00 +00:00
Changed how tempory filename is created and handled. Now follows example in mktemp documentation.
This commit is contained in:
parent
b25acb9a2d
commit
678fb563f1
1 changed files with 14 additions and 22 deletions
|
@ -115,19 +115,21 @@ config)
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
||||||
# Location and name of tempfile to parse
|
FILENAME=$(mktemp -q) && {
|
||||||
FILENAME=$(mktemp /tmp/cisco_epc3010-XXXX.dump) || exit 1
|
# Safe to use $FILENAME only within this block. Use quotes,
|
||||||
|
# since $TMPDIR, and thus $FILENAME, may contain whitespace.
|
||||||
|
|
||||||
|
# Get statuspage from the modem
|
||||||
|
curl -s -o $FILENAME http://192.168.100.1/Docsis_system.asp
|
||||||
|
|
||||||
|
|
||||||
# Get statuspage from the modem
|
# Bash arrays starts on index 0, we 0-pad the first index. It makes it easier later on..
|
||||||
curl -s -o $FILENAME http://192.168.100.1/Docsis_system.asp
|
SNR_ARRAY=( 0 $(awk -F'[<>]' '/ ch_snr/{print $3}' $FILENAME) )
|
||||||
|
PWR_ARRAY=( 0 $(awk -F'[<>]' '/ ch_pwr/{print $3}' $FILENAME) )
|
||||||
|
UP_PWR_ARRAY=( 0 $(awk -F'[<>]' '/ up_pwr/{print $3}' $FILENAME) )
|
||||||
# Bash arrays starts on index 0, we 0-pad the first index. It makes it easier later on..
|
|
||||||
SNR_ARRAY=( 0 $(awk -F'[<>]' '/ ch_snr/{print $3}' $FILENAME) )
|
|
||||||
PWR_ARRAY=( 0 $(awk -F'[<>]' '/ ch_pwr/{print $3}' $FILENAME) )
|
|
||||||
UP_PWR_ARRAY=( 0 $(awk -F'[<>]' '/ up_pwr/{print $3}' $FILENAME) )
|
|
||||||
|
|
||||||
|
rm -f "$FILENAME"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -138,7 +140,7 @@ if [ "$DIRECTION" == "downstream" ]; then
|
||||||
total=${#PWR_ARRAY[*]}
|
total=${#PWR_ARRAY[*]}
|
||||||
for (( index=1; index<$(( $total )); index++ ))
|
for (( index=1; index<$(( $total )); index++ ))
|
||||||
do
|
do
|
||||||
printf "channel_%d_pwr.value %s\n" $index ${PWR_ARRAY[$index]}
|
printf "channel_%d_pwr.value %s\n" $index ${PWR_ARRAY[$index]}
|
||||||
done
|
done
|
||||||
|
|
||||||
total=${#SNR_ARRAY[*]}
|
total=${#SNR_ARRAY[*]}
|
||||||
|
@ -146,12 +148,10 @@ if [ "$DIRECTION" == "downstream" ]; then
|
||||||
do
|
do
|
||||||
printf "channel_%d_snr.value %s\n" $index ${SNR_ARRAY[$index]}
|
printf "channel_%d_snr.value %s\n" $index ${SNR_ARRAY[$index]}
|
||||||
done
|
done
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Upstream info - Modem outputs Power Levels
|
# Upstream info - Modem outputs Power Levels
|
||||||
#
|
#
|
||||||
|
@ -160,15 +160,7 @@ if [ "$DIRECTION" == "upstream" ]; then
|
||||||
total=${#UP_PWR_ARRAY[*]}
|
total=${#UP_PWR_ARRAY[*]}
|
||||||
for (( index=1; index<$(( $total )); index++ ))
|
for (( index=1; index<$(( $total )); index++ ))
|
||||||
do
|
do
|
||||||
printf "channel_%d_pwr.value %s\n" $index ${UP_PWR_ARRAY[$index]}
|
printf "channel_%d_pwr.value %s\n" $index ${UP_PWR_ARRAY[$index]}
|
||||||
done
|
done
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Remove tempory file, used for parsing data
|
|
||||||
#
|
|
||||||
trap "rm -rf $FILENAME" EXIT
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue