I am writing a Nagios plugin and I have a "command not found" when I run it. What is wrong? Why 127.0.0.1 (or localhost as well) is not recognized? When I run just the snmp request - I have a simple number as an output - so everything works perfectly.
Here is the script
#!/bin/bash
answer=snmpget 127.0.0.1 -v 2c -c public .1.3.6.1.4.1.2021.11.9.0 | grep -Eo
'[0-9]+$'
case $answer in
[1-2]*)
echo "OK"
exit 0
;;
[3-50]*)
echo "WARNING"
exit 1
;;
[51-100]*)
echo "CRITICAL"
exit 2
;;
*)
echo "UNKNOWN"
exit 3
;;
esac