Link to home
Start Free TrialLog in
Avatar of Jay Thomas
Jay ThomasFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Set snmp on ESXi version 4.1, 5.1 and 5.5

Hi all,
I've been looking on the web for an answer to how to setup SNMP on 3 different versions of ESXi that I have.
My questions are from a console.
1. How do i check that the SNMP service is running on an ESXi host?
2. How do I start it and set it to automatic?
3. How do I set the community and trap destinations?

Any help appreciated.
Avatar of Andrew Hancock (VMware vExpert PRO / EE Fellow/British Beekeeper)
Andrew Hancock (VMware vExpert PRO / EE Fellow/British Beekeeper)
Flag of United Kingdom of Great Britain and Northern Ireland image

this is the bible on setting SNMP for ESXi 4.1, 5.1 and 5.5

VMware KB: Configuring SNMP Traps in ESXi/ESX

the VMware vSphere CLI command is used to configure

vicfg-snmp.pl

the command

vicfg-snmp.pl --server hostname --username username --password password --show

will show existing configuration.

The same command, can be used to test and enable SNMP.
Avatar of Jay Thomas

ASKER

Hi Andrew, when i run:
vicfg-snmp.pl --server hostname --username username --password password --show
With correct credentials i receive an error "vicfg.snmp.pl: not found". I get this on a ESXi 4.1 and a 5.5 host.
Hi again, I am running the following commands on ESX5.5:

esxcli system snmp set --enable true
esxcli system snmp set --communities MyName
esxcli system snmp set --targets MyIPAddress/MyCommunity.

And all works very well. I am able to test alert on my monitoring system and all is well however when I run the command on 4.1 I get an error "Unknown Namespace System". Clearly the command isn't supported but would you know what the command is that I should be using?
Hi Andrew. Yes, I looked at the link you sent and have successfully deployed SNMP on 5x versions. Just 4.1 outstanding.
it could be the version of vCLI you are using for 4.1.

what version of vCLI are you using ?

what command are you using ?

vicfg-snmp.pl --server host.example.com --username root --password password -t target.example.com@162 -c public
HI, I ran the command and the output I get is:
vicfg-snmp.pl: not found

These are 4.1 hosts that haven't been looked after properly IMO. I'm not even sure vcli is installed, is there any way for me to tell whether it has and if so what version it is?
My miss-understanding.
So that I am clear. vCLI is used to administer vSphere server or ESXi hosts? The 5.5 ESXi hosts are all individual, not clustered and so I ran the commands after connecting to the console using SSH program. If the 4.1 hosts are part of a cluster do I specify the SNMP through vSphere then?
vCLI are remote tools, that connect to an ESXi Host (or vSphere Server!)

so you connect via vCLI to host.
Almost there. From a server with vCLI installed I run
1. vicfg-snmp.pl --server yServerName --username root --enable
Enter password:
Enabling agent...
Complete.
2. I then run vicfg-snmp.pl --server MyServerName --username root --show
Enter password:
Current SNMP agent settings:
Enabled  : 1
UDP port : 161

Looks good, I then add a community and trap destinations, but I get an error(please see below) and I can't make out what or why the error comes up.
3.bin>vicfg-snmp.pl --server MyServerName --username root -t MySNMPManagerServerName -c MyCommunityString
Enter password:
Changing community list to: MyCommunityString...
Complete.
Changing notification(trap) targets list to: MyServerName...
target "MyServerName" must specify destination/community and optionally
 a port
Failed.
Complete.
From a SSH connection to a ESXi host:

1.- Set the "public" community, enable SNMP and set a target for traps:

esxcli system snmp set --communities public --enable yes --targets=192.168.130.1/public

esxcli system snmp set -c public -e yes -t=192.168.130.1/public

2.- Review the config

esxcli system snmp get

3.- Test the actual config

esxcli system snmp test

4.- Review the msg sent by the ESXi host on the target server.
5.- Done!
Hi Carlos. From SSH I get error unknown namespace system when I run esxcli command.

So using power client from my machine I have run:
1. vicfg-snmp.pl --MyServerName --username root -t TargetServerName -c MyCommunityName
2. I run the show command and I get the following output -
Current SNMP agent settings:
Enabled  : 1
UDP port : 161
Communities :
MyCommunityName
public

Notification targets :
(I do not see any notification targets and so when I do a SNMP test it tell me:
Sending test nofication(trap) to all configured targets...
Failed : A general system error occurred: No destinations have been configured t
o send notifications to

It would appear I can set the community because that does show up I'm just having trouble with the syntax of the command to set the target. Any help appreciated.
Yes, because he's not quite correct esxcli is ESXi 5.x! not 4.x!

the correct command is vicfg-snmp.pl

the syntax is

--targets | -t <hostname[@port]> </community>[,...]

vicfg-snmp.pl --server <ESXi4.x_Host_IP> -c <communityname> -p 161 -t <destination_host@161/<communityname>

You can edit the XML file directly, it you so choose.
Thanks Andrew. Sorry I have just found out I need to add 2 community strings. Would this be done using a semi colon perhaps between names?
a comma

two community strings

like

public1
private1

vicfg-snmp.pl --server 192.168.1.1 -c public1,private1 -t 192.168.1.254/public1,192.168.1.6@163/private1 -p 163
Thank you Andrew. So before I run and just so that I am clear. The above example would add a "private1" community name reporting to 192.168.1.254 and a "public1" community name that reports to 192.168.1.6?

I'm just wondering why the @163 isn't specified twice?
Thanks for all your help.
well you could specify 161 twice!

default port 161! (so if not specified, assumes 161!)

163 is a different port!

for completeness, specify 161 twice!
So mine are port 161 so I run:
vicfg-snmp.pl --server ServerName -c CommName1,CommName2 -t ManagementServer1, ManagementServer2.
I get the error of:
Changing community list to: CommName1,CommName2...
Complete.
Changing notification(trap) targets list to: IPAddress1,IPAddress2...
target "IPAddress1" must specify destination/community and optionally a port
Failed.
target "IPAddress2" must specify destination/community and optionally a port
Failed.
Complete.

I know I must be doing something wrong...
vicfg-snmp --server esx1-old --username root --password vmware -t <trap.server1.hostname>@162/public ,<trap.server2.hostname>@162/public


please paste the command you are using.....
Hi, I run this:
vicfg-snmp.pl --server ServerName -c CommName1,CommName2 -t ManagementServer1, ManagementServer2
ASKER CERTIFIED SOLUTION
Avatar of Andrew Hancock (VMware vExpert PRO / EE Fellow/British Beekeeper)
Andrew Hancock (VMware vExpert PRO / EE Fellow/British Beekeeper)
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you Andrew. I will try it when back at the office tomorrow morning.
Yep, all working now many thanks.

Let me know when you release your VMware ESXI eBook and I'll be the first in the queue to purchase it ;)