vSphere 5.5 – Enable SNMP

I am going through setting up Solarwinds Virtual Manager and needed to enable SNMP on my vSphere 5.5 hosts. So the service set to automatically start but it will not start without generating an error when attempting to start the service as seen below.


So in case you run into the same thing it is as simple as running the following commands on your individual hosts from a console session. Replace YOUR_STRING with the community string that you would like to use. The last command sets the firewall to allow all to poll SNMP.

esxcli system snmp set --communities YOUR_STRING
esxcli system snmp set --enable true
esxcli network firewall ruleset set --ruleset-id snmp --allowed-all true
esxcli network firewall ruleset set --ruleset-id snmp --enabled true
/etc/init.d/snmpd restart

You can change the firewall rule to only allow a specific subnet or host if you would like to.

esxcli network firewall ruleset set --ruleset-id snmp --allowed-all false
esxcli network firewall ruleset allowedip add --ruleset-id snmp --ip-address
esxcli network firewall ruleset set --ruleset-id snmp --enabled true
/etc/init.d/snmpd restart

So you are thinking well that is great but I have more than just a few hosts and would like to run this using PowerCLI. So here you go, a bit of PowerCLI to set your SNMP up on each of your hosts in vCenter.

# PowerCLI Script for adding syslogserver to hosts
# @mrlesmithjr
# EverythingShouldBeVirtual.com
# Change the following to match your environment
# vi_server is your vCenter
$vi_server = “vcenterservername”
$vcuser = "vcenterserverusername"
$vcpass = "vcenterserverpassword"
$communities = "public"
$syslocation = "Atlanta"

Connect-VIServer -Server $vi_server -User $vcuser -Password $vcpass

# Setup variable to use in script for all hosts in vCenter
$vmhosts = @(Get-VMHost)

# Configure syslog on each host in vCenter
foreach ($vmhost in $vmhosts) {
Write-Host ‘$vmhost = ‘ $vmhost
$esxcli = Get-EsxCli -VMHost $vmhost

Disconnect-VIServer * -Confirm:$false

So there you have it. You are good to go now. Have fun SNMP’ing away!

11 thoughts on “vSphere 5.5 – Enable SNMP

  1. Yes it does.

    But if you have vicfg installed, you can also run a command like this.

    vicfg-snmp –server HOST-IP –username USERNAME-ROOT -c public -E

    If you get an error, try to run this first: (self signed certificates on hosts)


  2. Nice. But the location is actually written in the field "contact".

    the bad line is:

    the good one i suggest is:

    Diff betwen the lines is only ",$null" added before "$syslocation".

  3. and now, i really suggest you change your comment plugin to let users write lines more longer or automaticaly wrap-line.

    test comment to work around bad wordpress plugins:

    the bad line is:
    $esxcli.system.snmp.set($null,$communities,"true",$null,$null,$null,$null, '

    the good one i suggest is:
    $esxcli.system.snmp.set($null,$communities,"true",$null,$null,$null,$null, '

    Diff betwen the lines is only ",$null" added before "$syslocation".

  4. Change the line
    $vmhosts = @(Get-VMHost)
    $vmhosts = @(Get-VMHost -location $clustername)
    and specify the variable $clustername at the beginning so you can selectively target your cluster

  5. So do I need to modify the /etc/vmware/snmp.xml file to have it provide the IP contact, location, etc information? Further, it has an false… located in there. Should I change that as well?

  6. Just run two commands, it worked for me
    1) esxcli system snmp set –targets target_address@port/community
    #Target_address = Solarwinds Server IP, Port-161,Commnunity=public ot any customized string you are using in Solarwinds
    2) esxcli system snmp set –enable true

  7. Pingback: ESXi 5x SNMP Config - PersonNET

  8. The rule of thumb is one dash and no equals for for letter switches and two dashes and equals for word switches. So since you are missing your target above…
    esxcli system snmp set -t solar-wind.lab.local@161/public
    esxcli system snmp set –targets=solar-wind.lab.local@161/public

  9. Pingback: VMware Enable SNMP | blogtsarev

Leave a Reply

Your email address will not be published. Required fields are marked *