VMware Cloud Community
nyvirt
Contributor
Contributor

SNMP configuration on the ESXi hosts(200)

Hi People

I'm looking for a script to enable and update snmp configuration on close to 200 esxi 5.5/5.0/4.1/4.0 hosts altogether


I have the snmp server name, community string and port number to update.


As i am new to powercli appreciate your help in advance


Thnks

sree

0 Kudos
10 Replies
rcporto
Leadership
Leadership

Take a look at this one: PowerCLI Collection – Adding SNMP settings to ESXi hosts | Pascal's Wereld

---

Richardson Porto
Senior Infrastructure Specialist
LinkedIn: http://linkedin.com/in/richardsonporto
0 Kudos
LucD
Leadership
Leadership

Be aware that the SNMP setup changed between vSphere 4 and 5, so you will probably need a different script for vSphere 4.


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

0 Kudos
466kdl1
Enthusiast
Enthusiast

Hi Team,

I wanted to run the script to configure the SNMP settings the list of esxi hosts which are saved in the txt file.

 

I able to run it 6.5 but NOT 6.7 . can you help me if any changes need to change. Here is script:

 

********************

$esx_list = Get-Content -Path "C:\\servers.txt"

foreach ($item in $esx_list) {
Connect-VIServer -Server $item -User root -Password "i88888888888888888888888n"
Get-VMHostSnmp | Set-VMHostSnmp -Enabled:$true -TargetCommunity "******" -TargetHost "10.******" -AddTarget
Disconnect-VIServer -Server $item -Confirm:$false

0 Kudos
LucD
Leadership
Leadership

Are you getting any errors?


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

0 Kudos
466kdl1
Enthusiast
Enthusiast

Yes getting's some errors

 

466kdl1_0-1607533003709.png

 

Tags (1)
0 Kudos
LucD
Leadership
Leadership

Looks like the Disconnect-VIServer can't find the server.
Did the Connect-VIServer complete correctly?


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

0 Kudos
466kdl1
Enthusiast
Enthusiast

Yes I have disconnected server correctly.

Even when I closed and tried its not working.

 

I am able to write the 6.7 host as well with above script. but Just I wanted to make change in the community string. but its not happening with script.

Desired resuts in the esxi hosts

[root@e****:~] esxcli system snmp get
Authentication:
Communities: nosaltandesgrp
Enable: true
Engineid: 00000063000000a100000000434354121
Hwsrc: indications
Largestorage: true
Loglevel: info
Notraps:
Port: 161
Privacy:
Remoteusers:
Syscontact:
Syslocation:
Targets:
Users:
V3targets:

 

0 Kudos
LucD
Leadership
Leadership

You are showing that you get errors on the Disconnect-VIServer.
I just wanted to know if the Connect-VIServer works.
That part your screenshot doesn't show.


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

0 Kudos
466kdl1
Enthusiast
Enthusiast

 Please find the screenshot of connection VIServer.

466kdl1_0-1607539709610.png

 

Now able to run this script vis powercli 12.0 but unable update communiti only.

0 Kudos
LucD
Leadership
Leadership

Ok, that confirms that your Connect-VIServer doesn't work.

That can have many reasons.
To list just a few: bad certificate, FW rules prohibit you to reach the VCSA, the FQDN of the VCSA can not be resolved...
You will first have to solve that issue.


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

0 Kudos