Skip to content

Commit

Permalink
Adding error messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
edufolly committed Apr 25, 2024
1 parent 375c356 commit ac04c55
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ echo "SNMPv2c - Walk"
snmpwalk -v 2c -c public "$HOST:$PORT" "$WALK" >/dev/null 2>&1

if [ $? -ne 0 ]; then
echo "Error: SNMPv2c Walk"
CODE=10
fi

Expand All @@ -52,6 +53,7 @@ echo "SNMPv2c - Get"
RESULT=$(snmpget -v2c -c public -Ovq "$HOST:$PORT" "$GET")

if [ "$RESULT" != "At flying circus" ]; then
echo "Error: $RESULT"
CODE=11
fi

Expand All @@ -60,6 +62,7 @@ echo "SNMPv2c - GetNext"
RESULT=$(snmpgetnext -v2c -c public -Ovq "$HOST:$PORT" "$GET")

if [ "$RESULT" != "72" ]; then
echo "Error: $RESULT"
CODE=12
fi

Expand All @@ -69,6 +72,7 @@ snmpget -v3 -Ovq -u "$SNMP_V3_USER" -l noAuthNoPriv \
"$HOST:$PORT" "$GET" >/dev/null 2>&1

if [ $? -eq 0 ]; then
echo "Error: $RESULT"
CODE=13
fi

Expand Down Expand Up @@ -108,6 +112,7 @@ snmpwalk -v3 -On -u "$SNMP_V3_USER" \
"$HOST:$PORT" "$WALK" >/dev/null 2>&1

if [ $? -ne 0 ]; then
echo "Error: SNMPv3 Walk"
CODE=30
fi

Expand All @@ -120,6 +125,7 @@ RESULT=$(snmpget -v3 -Ovq -u "$SNMP_V3_USER" \
"$HOST:$PORT" "$GET")

if [ "$RESULT" != "At flying circus" ]; then
echo "Error: $RESULT"
CODE=31
fi

Expand All @@ -132,6 +138,7 @@ RESULT=$(snmpgetnext -v3 -Ovq -u "$SNMP_V3_USER" \
"$HOST:$PORT" "$GET")

if [ "$RESULT" != "72" ]; then
echo "Error: $RESULT"
CODE=32
fi

Expand Down Expand Up @@ -170,6 +177,7 @@ snmpwalk -v3 -On -u "$SNMP_V3_USER" \
"$HOST:$PORT" "$WALK" >/dev/null 2>&1

if [ $? -ne 0 ]; then
echo "Error: SNMPv3 Walk"
CODE=40
fi

Expand All @@ -184,6 +192,7 @@ RESULT=$(snmpget -v3 -Ovq -u "$SNMP_V3_USER" \
"$HOST:$PORT" "$GET")

if [ "$RESULT" != "At flying circus" ]; then
echo "Error: $RESULT"
CODE=41
fi

Expand All @@ -198,6 +207,7 @@ RESULT=$(snmpgetnext -v3 -Ovq -u "$SNMP_V3_USER" \
"$HOST:$PORT" "$GET")

if [ "$RESULT" != "72" ]; then
echo "Error: $RESULT"
CODE=42
fi

Expand Down

0 comments on commit ac04c55

Please sign in to comment.