Menu

Virtual Geek

Tales from real IT system administrators world and non-production environment

POWERCLI : ESXI SERVER SNMP CONFIGURATION USING ESXCLI COMMANDS

VMWARE VSPHERE POWERCLI INSTALLATION AND CONFIGURATION STEP BY STEP

I was configuring SNMP on multiple ESXi servers and I wanted to use only VMWare Powercli for this instead of Esxi SSH or vCLI commands, (I wanted avoid enabling SSH service and port on Esxi and didn't want to install vCLI tools, As I already have Powercli on my laptop, I can automate this task using PowerShell), In this blog I will show how to use one liner commands to configure SNMP. First thing open VMWare vSphere Powercli. and connect to vCenter server using Connect-VIServer vCenterserver Next create a connection to ESXi host using $esxcli =  Get-VMHost EsxiServer | Get-Esxcli. This connection info is stored in $esxcli variable.

Connect-VIServer Get-Esxcli Get-VMHost esxcli

Now while configuring different version of ESXi I found there is a slight syntax difference between different Esxi Version. Below screenshot is for ESXi 5.1. First Command is $esxcli.system.snmp.get(), It shows the current SNMP configuration on that particular ESXi host we connected. In next esxcli command we will set SNMP server information on server.  
$esxcli.system.snmp.set($null,'public',$true,$null,$null,$null,$null,'162',$null,$null,$null,$null,$null,'172.25.8.202/public',$null,$null)
There are 16 parameters in ESXi Version 5.1 and definition can be viewed using command $esxcli.system.snmp.set.Value.

string authentication - $null,
string communities - 'public',
boolean enable - $true,
string engineid - $null,
string hwsrc - $null,
string loglevel - $null,
string notraps - $null,
long port - '162',
string privacy - $null,
string remoteusers - $null,
boolean reset - $null,
string syscontact - $null,
string syslocation - $null,
string targets - '172.25.8.202/public',
string users - $null,
string v3targets - $null,

Next fire once again $esxcli.system.snmp.get() to view modified configuration.esxcli configure snmp using powercli 5.1

If you are using ESXi 5.5 version. There is one addition value (Total count is 17).
$esxcli.system.snmp.set($null,'public',$true,$null,$null,$null,$null,$null,'162',$null,$null,$null,$null,$null,'172.25.8.202/public',$null,$null) 

Setting up snmp server in esxi esxcli powercli

I didn't check the same on ESXi version 6 but soon will post here.

Go Back



Comment

Blog Search

Page Views

11275441

Follow me on Blogarama