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.
LVL 1
Jason ThomasAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Andrew Hancock (VMware vExpert / EE MVE^2)VMware and Virtualization ConsultantCommented:
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.
0
Jason ThomasAuthor Commented:
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.
0
Jason ThomasAuthor Commented:
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?
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Andrew Hancock (VMware vExpert / EE MVE^2)VMware and Virtualization ConsultantCommented:
So, is the issue now only with 4.1 ?
0
Jason ThomasAuthor Commented:
Hi Andrew. Yes, I looked at the link you sent and have successfully deployed SNMP on 5x versions. Just 4.1 outstanding.
0
Andrew Hancock (VMware vExpert / EE MVE^2)VMware and Virtualization ConsultantCommented:
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
0
Jason ThomasAuthor Commented:
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?
0
Andrew Hancock (VMware vExpert / EE MVE^2)VMware and Virtualization ConsultantCommented:
vCLI is installed on the workstation.
0
Jason ThomasAuthor Commented:
My miss-understanding.
0
Jason ThomasAuthor Commented:
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?
0
Andrew Hancock (VMware vExpert / EE MVE^2)VMware and Virtualization ConsultantCommented:
vCLI are remote tools, that connect to an ESXi Host (or vSphere Server!)

so you connect via vCLI to host.
0
Jason ThomasAuthor Commented:
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.
0
Carlos IjalbaSenior SysadminCommented:
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!
0
Jason ThomasAuthor Commented:
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.
0
Andrew Hancock (VMware vExpert / EE MVE^2)VMware and Virtualization ConsultantCommented:
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.
0
Jason ThomasAuthor Commented:
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?
0
Andrew Hancock (VMware vExpert / EE MVE^2)VMware and Virtualization ConsultantCommented:
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
0
Jason ThomasAuthor Commented:
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.
0
Andrew Hancock (VMware vExpert / EE MVE^2)VMware and Virtualization ConsultantCommented:
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!
0
Jason ThomasAuthor Commented:
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...
0
Andrew Hancock (VMware vExpert / EE MVE^2)VMware and Virtualization ConsultantCommented:
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.....
0
Jason ThomasAuthor Commented:
Hi, I run this:
vicfg-snmp.pl --server ServerName -c CommName1,CommName2 -t ManagementServer1, ManagementServer2
0
Andrew Hancock (VMware vExpert / EE MVE^2)VMware and Virtualization ConsultantCommented:
try my command I posted.

You could always edit the XML file!

I've just tested this...this is the command I've used

public1
private1

are the community names

C:\Program Files (x86)\VMware\VMware vSphere CLI\bin>vicfg-snmp.pl --server 192.168.10.130 --username root --password "" -c public1,private1 -t 192.168.10.1@162/public1,192.168.10.2@162/private1
Changing community list to: public1,private1...
Complete.
Changing notification(trap) targets list to: 192.168.10.1@162/public1,192.168.10.2@162/private1...
Complete.

C:\Program Files (x86)\VMware\VMware vSphere CLI\bin>vicfg-snmp.pl --server 192.
168.10.130 --username root --password "" --show
Current SNMP agent settings:
Enabled  : 0
UDP port : 161

Communities :
public1
private1

Notification targets :
192.168.10.2@162/private1
192.168.10.1@162/public1
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jason ThomasAuthor Commented:
Thank you Andrew. I will try it when back at the office tomorrow morning.
0
Jason ThomasAuthor Commented:
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 ;)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VMware

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.