VMware Cloud Community
Troy_Clavell
Immortal
Immortal
Jump to solution

Set-VMHostSnmp

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!

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

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

View solution in original post

Reply
0 Kudos
11 Replies
LucD
Leadership
Leadership
Jump to solution

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

Reply
0 Kudos
Troy_Clavell
Immortal
Immortal
Jump to solution

Thanks ! Bummer I can't restart the snmp daemon as well.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

Reply
0 Kudos
Troy_Clavell
Immortal
Immortal
Jump to solution

That would be great. I really don't want to have to do them 1 at a time.

Thank you!

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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 Smiley Wink


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Troy_Clavell
Immortal
Immortal
Jump to solution

very helpful indeed. Since we use root for everything (not best practice, but...) it will be even better.

Reply
0 Kudos
admin
Immortal
Immortal
Jump to solution

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]

Reply
0 Kudos
lamw
Community Manager
Community Manager
Jump to solution

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:

Twitter: @lamw

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Comuunity

If you find this information useful, please award points for "correct" or "helpful".

LucD
Leadership
Leadership
Jump to solution

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

Reply
0 Kudos
Troy_Clavell
Immortal
Immortal
Jump to solution

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.....

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Agreed. For any ESX/ESXi service.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos