I have a bash script that starts like this:
#!/bin/bash
systemStateGlobalSystemState=.1.3.6.1.4.1.674.10909.1.200.10.1.2
systemStateChassisStatus=.1.3.6.1.4.1.674.10909.1.200.10.1.4
systemStateVoltageStatusCombined=.1.3.6.1.4.1.674.10909.1.200.10.1.12
systemStateTemperatureStatusCombined=.1.3.6.1.4.1.674.10909.1.200.10.1.24
systemStateMemoryDeviceStatusCombined=.1.3.6.1.4.1.674.10909.1.200.10.1.27
systemStateChassisIntrusionStatusCombined=.1.3.6.1.4.1.674.10909.1.200.10.1.30
operatingSystemMemoryStatus=.1.3.6.1.4.1.674.10909.1.400.20.1.4
RESULT=$(/usr/local/nagios/libexec/check_snmp -H $1 -o $2 -c $3)
CODE=$(echo $RESULT | awk '{print $4}')
What I am trying to do is if someone for $2 command line parameter enters operatingSystemMemoryStatus how do I select the predefined value for it in the script? So where $2 above is referenced in RESULT, how do I get that command to use the .1.3.6.1.4.1.674.10909.1.400.20.1.4 value?
So if I entered
check_snmp 192.168.0.1 operatingSystemMemoryStatus public script
would do:
/usr/local/nagios/libexec/check_snmp -H 192.168.0.1 -o .1.3.6.1.4.1.674.10909.1.400.20.1.4 -c public
How can I accomplish this?