Hello PowerCLI Experts,
I have been tasked to change the snmp.conf file for about 100 HP ESX Hosts. I need to replace an old IP with a new IP. below is snip from my snmp.conf file.
The old config is:
dlmod cmaX /usr/lib/libcmaX.so
rwcommunity Sc0rp10 127.0.0.1
rocommunity Or10n 127.0.0.1
rwcommunity Sc0rp10 10.64.3.160
rocommunity Or10n 10.64.3.160
trapcommunity Or10n
trapsink 10.64.3.160 Or10n
New config needs to be:
dlmod cmaX /usr/lib/libcmaX.so
rwcommunity Sc0rp10 127.0.0.1
rocommunity Or10n 127.0.0.1
rwcommunity Sc0rp10 10.65.49.106
rocommunity Or10n 10.65.49.106
trapcommunity Or10n
trapsink 10.65.49.106 Or10n
Is the Set-VMHostSnmp cmdlet the way to go? I also would like to restart the snmpd service on each host after the change.
Enviornment:
ESX 3.5.0 U4
vCenter 2.5.0U5
Thanks in advance!
Yes, you can use the Set-VMHostSnmp cmdlet to configure snmp on the ESX host.
Just remember you need to connect to the ESX host not to the vCenter.
For some examples have a look at Setting SNMP configuration in VMWare using Powershell
The Start-VMHostService cmdlet unfortunately can not be used to restart the snmpd daemon.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yes, you can use the Set-VMHostSnmp cmdlet to configure snmp on the ESX host.
Just remember you need to connect to the ESX host not to the vCenter.
For some examples have a look at Setting SNMP configuration in VMWare using Powershell
The Start-VMHostService cmdlet unfortunately can not be used to restart the snmpd daemon.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Wait a sec, I'm just testing a SDK method that could be used.
Let me get back to you.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
That would be great. I really don't want to have to do them 1 at a time.
Thank you!
This is a possible solution but it will require the use of plink and sudo should be configured on the ESX hosts.
Something like this
$User = <account> $Pswd = <password> $Computer = <ESX-hostname> $plink = <Putty-directory>\plink.exe" $plinkoptions = " -v -batch -pw $Pswd" $cmd1 = 'service snmpd restart' $remoteCommand = '"' + $cmd1 + '"' $command = $plink + " " + $plinkoptions + " " + $User + "@" + $computer + " " + $remoteCommand $msg = Invoke-Expression -command $command
Not sure if this will save time if you first have to set up sudo though
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
very helpful indeed. Since we use root for everything (not best practice, but...) it will be even better.
Luc,
Should I take this to mean there is no vSphere API for restarting SNMP? If so I assume you would have posted that approach. This seems a bit nuts to me.
=====
Carter Shanklin
Read the PowerCLI Blog
[Follow me on Twitter|http://twitter.com/cshanklin]
I'm assuming Luc looked at restartService but it doesn't support snmp service unfortunately and reconfiguring SNMP doesn't auto-start the service if it isn't already running
=========================================================================
William Lam
VMware vExpert 2009
VMware ESX/ESXi scripts and resources at:
VMware Code Central - Scripts/Sample code for Developers and Administrators
If you find this information useful, please award points for "correct" or "helpful".
William is correct. The RestartService method only accepts the same services the Start-VMHostService cmdlet accepts.
Which makes sense since the cmdlet is most probably based on that method.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Should I take this to mean there is no vSphere API for restarting SNMP? If so I assume you would have posted that approach. This seems a bit nuts to me.
would be a nice to have.....
Agreed. For any ESX/ESXi service.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference