I am running a nagios server on opensuse linux linking via snmp to an esx 3.5 server
I am trying to get snmpwalk to return an array but it only returns a single value.
On the esx box I ahve the following shell to find the sizes of all of the snapshots-
/usr/bin/find /vmfs/volumes/ -name '*delta*.vmdk' -printf %f' '%s'\n'
This returns the following when ran on the esx box-
[root@localhost root]# /bin/sh /etc/snmp/snmp_snapshots.sh
testnag01-000001-delta.vmdk 16840704
testnag01-000002-delta.vmdk 167835648
testnag01-000003-delta.vmdk 151058432
On the nagios box I have the following shell-
declare -a RESULT=$(/usr/bin/snmpwalk -v 2c -c public 10.10.0.20 .1.3.6.1.4.1.6876.57.101.2 | grep vmdk | awk {' print $4,$5 '} | sed 's/ /_size:/g' | sed 's/\"//g')
echo "snapshot 1" ${RESULT[0]}
echo "snapshot 2" ${RESULT[1]}
This only returns a single value, (the second one on the list)-
snapshot 1 testnag01-000002-delta.vmdk:167835648
snapshot 2
When I run the command on its own-
/usr/bin/snmpwalk -v 2c -c public 10.10.0.20 .1.3.6.1.4.1.6876.57.101.2
I get the following return-
SNMPv2-SMI::enterprises.6876.57.101.2 = STRING: "testnag01-000002-delta.vmdk 167835648"
So it looks like the command itself is failing to return more than one result?
I'm a noob here so I could very well be missing something obvious...
Thanks in advance
I got the answer elsewhere but thought I'd post it here in case someone else has the same issue-
the last number in the OID returns the record number- so .2 returns the second value
Once I removed this .2 and used this command-
/usr/bin/snmpwalk -v 2c -c public 10.10.0.20 .1.3.6.1.4.1.6876.57.101
it worked fine!