I am fond of and very comfortable with powercli when doing activities on vsphere environment, but this time I thought let’s try vsphere cli for as a automation tool. My monitoring team asked to configure SNMP on all esxi servers in my organization, I generally follow vmware kb http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1008065 and found I will require to use vsphere cli for the same (It is possible to configure SNMP from Powercli as well I have posted the script in the end)
What is SNMP - is a standard protocol for network monitoring and network devices management. Almost all active network devices support SNMP. Moreover, SNMP is supported by the majority of operational systems and by many network applications.
I downloaded and installed vsphere cli from http://my.vmware.com
Once you open the command prompt for vsphere cli, change the directory to bin, if you dir you will find Perl scripts.
Below command shows current SNMP configuration on the esxi server
Vicfg-snmp.pl --server 192.168.33.21 –username root –password Computer@1 --show
This will set snmp server settings on the esxi server
Vicfg-snmp.pl --server 192.168.33.21 –username root –password Computer@1 –t 192.168.33.40@161/vcloud -c vcloud -E
Final show command to view the configured settings.
How do you quick test SNMP whether setting or working or not?
Here I have downloaded snmpwalk tool from http://www.snmpsoft.com/freetools/snmpwalk.html and extracted to one of windows server in the network
Open command prompt on the server and run the utility with parameters. Good help is available about the tool.
snmpWalk.exe –r:192.168.33.21 –c:vcloud
-r:192.168.33.21 = esxi server where settings are configured
-c:vcloud = Community string.
If everything is fine it will get response from the esxi server.(In the case you are using linux run command snmpwalk -v2c -c rageesx 192.168.33.21)
On the esxi server you can verify connection success
Configuring SNMP on esxi host with powercli
Run get-vmhostsnmp to fetch information
If you have lots of esxi server and want to automate it (esxi server with same password), you can use below script to automate on all esxi servers.