commit file state with "switch : port port" in message
authorDobrica Pavlinusic <dpavlin@rot13.org>
Fri, 29 Jun 2018 08:18:25 +0000 (10:18 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Fri, 29 Jun 2018 08:18:25 +0000 (10:18 +0200)
snmp-port-status.sh

index 57fd4c5..de3cfbc 100755 (executable)
@@ -53,3 +53,7 @@ for PORT in `seq 1 $numports`; do
        echo "$sw $PORT "`$snmp IF-MIB::ifName.$PORT IF-MIB::ifHighSpeed.$PORT IF-MIB::ifOperStatus.$PORT IF-MIB::ifType.$PORT IF-MIB::ifAlias.$PORT` | grep -v 'No Such Instance currently exists at this OID' | sed 's/\(ethernetCsmacd\) \(..*\)$/\1 [\2]/' | tee -a $log/$sw
 done
 
+ports_changed=`cd $log && git diff $sw | grep '^-' | awk '{ print $3 }' | tr '\n' ' '`
+if [ ! -z "$ports_changed" ] ; then
+       cd $log && git commit -m "$sw : $ports_changed" $log/$sw
+fi