Files
scripts-conlxsyslog03/rancid/STP_changes.sh
conetadm 5718e70f15 init
2024-11-14 21:11:06 +01:00

45 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
pushd /opt/observium/rrd/ > /dev/null
echo "<html>
<head>
<meta http-equiv='refresh' content='60; URL=STP_changes.html'>
</head>
<body>
<!-- rancid@conlxsyslog03:/scripts/rancid/STP_changes.sh -->
Table sorted by 'Timeticks ago'. Most recent top. <br><br>
<table border=1>"
perl -e 'printf "<tr><td> %-30s </td><td> %-13s </td><td> %-20s </td><td> %-20s </td><td> %s </td></tr>\n", "Devices", "Changes total", "Timeticks ago", "Hours ago", "last change at"'
for I in `ls | grep switch`
do
RET1=`snmpget -LE 0 -r2 -t0.1 -v2c -ccon $I .1.3.6.1.2.1.17.2.4.0 2>&1`
if [[ "$RET1" =~ "Counter" ]]
then
perl -e 'printf "<tr><td> %-30s </td>", $ARGV[0]' $I
CHG=`echo -n $RET1 | awk -F= '{print $2}' | awk -F':' '{print $2}' | tr -d '\n' | tr -d " "`
perl -e 'printf "<td> %-13s </td>", $ARGV[0]' $CHG
RET2=`snmpget -LE 0 -r2 -t0.1 -v2c -ccon $I .1.3.6.1.2.1.17.2.3.0 2>&1`
TT=`echo -n $RET2 | awk -F= '{print $2}' | awk -F' ' '{print $2}' | tr -d '\n' | tr -d '() '`
perl -e 'printf "<td> %-20s </td>", $ARGV[0]' $TT
TTC=`perl -e 'printf "%.2f", $ARGV[0] / 100 / 3600' $TT`
perl -e 'printf "<td> %-20s </td>", $ARGV[0]' $TTC
TTC=`perl -e 'printf "%d", $ARGV[0] / 100' $TT`
TS=`date -d "now - $TTC sec"`
echo "<td> $TS </td></tr>"
fi
done | sort -n --key 6,6
echo "</table>
</body>
</html>
"
popd > /dev/null