Saturday, November 30, 2013

Monitoring ESXi CPU/Memory via SNMP

I didn't find a particularly good resource for configuring and monitoring ESXi via SNMP, so here's what I did to get it to work. These instructions assume you want to use SNMPv3. You'll also need a host with vmcli installed on it.

1. create a local user on the esxi server by connecting directly to the esxi host using vsphere and going to the local users and groups tab. Right click somewhere in the user list and hit add
login: cacti (my poller)
password: somepassword

2. From the vCLI host, issue the following commands
esxcli -s esxiserverhostnameorip -u root -p rootpassword system snmp set --authentication [none,SHA1,MD5]
optional - to configure privacy do
esxcli -s esxiserverhostnameorip -u root -p rootpassword system snmp set --privacy [none,AES128]

3. Configure users by issuing the following commands
esxcli -s esxiserverhostnameorip -u root -p rootpassword system snmp hash --raw-secret --auth-hash yourdesiredsnmpv3authpass
optionally add --priv-hash yourprivsecret if using privacy
Hashes will be generated and displayed on screen, then do:
esxcli -s esxiserverhostnameorip -u root -p rootpassword system snmp set --users userid/authhash/privhash/security
where userid is the user in step 1, authhash is the authentication hash, privhash is the privacy hash (or use a single dash "-" if not using privacy) and security is either none, auth, or priv

4. Test the user by executing the following:
esxcli -s esxiserverhostnameorip -u root -p rootpassword system snmp test --user username --raw-secret --auth-hash desiredsnmpv3authpass (also include --priv-hash if you're using privacy)

5. enable SNMP by executing:
esxcli -s esxiserverhostnameorip -u root -p rootpassword system snmp set --enable yes

Now you can monitor your ESXi host via SNMP, some useful OIDs

1.3.6.1.2.1.25.2 - hrStorage
Not only contains information about datastores, but one of the entries is "Real Memory" which contains information about memory usage.

1.3.6.1.2.1.25.3.3 - hrProcessorTable
Contains CPU usage values for each core on the system

.1.3.6.1.2.1.2 - Interfaces MIB
Information on various network interfaces defined on the host

VMware documentation on configuring SNMP: https://pubs.vmware.com/vsphere-51/index.jsp?topic=%2Fcom.vmware.vsphere.monitoring.doc%2FGUID-2E4B0F2A-11D8-4649-AC6C-99F89CE93026.html

3 comments:

  1. This doesnt allow us to poll USED or FREE memory.

    ReplyDelete
    Replies
    1. Correct, hrStorage has an entry pointing to amount of RAM installed (max usable) on the system but nothing for "Free" or "Used" memory.

      Delete
  2. Harrah's Resort Southern California - MapYRO
    Harrah's Resort Southern California. Stateline: 777 Harrah's Rincon 양주 출장샵 Way, Funner, CA 92082. 양주 출장마사지 Phone: (760) 972-5133. Call 경산 출장샵 Now · More 여주 출장마사지 Info. 문경 출장안마 Hours, Accepts Credit Cards, Parking.

    ReplyDelete