Created
September 19, 2019 20:40
-
-
Save davidc/ac573b62d6e9a9a9b6046b0142996fed to your computer and use it in GitHub Desktop.
check_mikrotik_sw_fw updates
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# diff -u check_mikrotik_sw_fw check_mikrotik_sw_fw.new | |
--- check_mikrotik_sw_fw 2019-09-05 16:12:12.843534466 +0200 | |
+++ check_mikrotik_sw_fw.new 2019-09-19 22:38:11.560855856 +0200 | |
@@ -24,8 +24,19 @@ | |
;; | |
esac | |
done | |
-FW=$(snmpwalk -Ov -On -Oq -Cc -c $COMMUNITY -v $VERSION $HOST .1.3.6.1.4.1.14988.1.1.7.4.0) | |
-SW=$(snmpwalk -Ov -On -Oq -Cc -c $COMMUNITY -v $VERSION $HOST .1.3.6.1.4.1.14988.1.1.4.4.0) | |
+ | |
+FW=$(snmpget -Ov -Oq -c $COMMUNITY -v $VERSION $HOST .1.3.6.1.4.1.14988.1.1.7.4.0 2>&1) | |
+if [ $? -ne 0 ]; then | |
+ echo "UNKNOWN: ${FW}" | |
+ exit 3 | |
+fi | |
+ | |
+SW=$(snmpget -Ov -Oq -c $COMMUNITY -v $VERSION $HOST .1.3.6.1.4.1.14988.1.1.4.4.0 2>&1) | |
+if [ $? -ne 0 ]; then | |
+ echo "UNKNOWN: ${SW}" | |
+ exit 3 | |
+fi | |
+ | |
if [ "$FW" == "$SW" ]; then | |
echo "OK: Software and firmware versions match ($SW)" | |
exit 0 |
Author
davidc
commented
Sep 19, 2019
•
- check exit status from snmp command and return "UNKNOWN" if it failed
- use snmpget instead of snmpwalk since a specific OID is being queried, we don't need to walk anything
- don't use -On, unnecessary since OID is being suppressed anyway by -Ov
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment