Solved

Set snmp on ESXi version 4.1, 5.1 and 5.5

Posted on 2014-09-08
25
2,752 Views
Last Modified: 2014-09-17
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.
0
Comment
Question by:Jason Thomas
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 14
  • 10
25 Comments
 
LVL 120
ID: 40309483
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
 
LVL 1

Author Comment

by:Jason Thomas
ID: 40309514
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
 
LVL 1

Author Comment

by:Jason Thomas
ID: 40309542
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 120
ID: 40309545
So, is the issue now only with 4.1 ?
0
 
LVL 1

Author Comment

by:Jason Thomas
ID: 40309622
Hi Andrew. Yes, I looked at the link you sent and have successfully deployed SNMP on 5x versions. Just 4.1 outstanding.
0
 
LVL 120
ID: 40309645
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
 
LVL 1

Author Comment

by:Jason Thomas
ID: 40309788
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
 
LVL 120
ID: 40309905
vCLI is installed on the workstation.
0
 
LVL 1

Author Comment

by:Jason Thomas
ID: 40309953
My miss-understanding.
0
 
LVL 1

Author Comment

by:Jason Thomas
ID: 40309969
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
 
LVL 120
ID: 40309982
vCLI are remote tools, that connect to an ESXi Host (or vSphere Server!)

so you connect via vCLI to host.
0
 
LVL 1

Author Comment

by:Jason Thomas
ID: 40310305
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
 
LVL 9

Expert Comment

by:Carlos Ijalba
ID: 40311741
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
 
LVL 1

Author Comment

by:Jason Thomas
ID: 40322882
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
 
LVL 120
ID: 40322955
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
 
LVL 1

Author Comment

by:Jason Thomas
ID: 40323087
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
 
LVL 120
ID: 40323094
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
 
LVL 1

Author Comment

by:Jason Thomas
ID: 40323129
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
 
LVL 120
ID: 40323159
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
 
LVL 1

Author Comment

by:Jason Thomas
ID: 40323187
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
 
LVL 120
ID: 40323330
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
 
LVL 1

Author Comment

by:Jason Thomas
ID: 40323459
Hi, I run this:
vicfg-snmp.pl --server ServerName -c CommName1,CommName2 -t ManagementServer1, ManagementServer2
0
 
LVL 120

Accepted Solution

by:
Andrew Hancock (VMware vExpert / EE MVE^2) earned 500 total points
ID: 40323495
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
 
LVL 1

Author Comment

by:Jason Thomas
ID: 40324152
Thank you Andrew. I will try it when back at the office tomorrow morning.
0
 
LVL 1

Author Closing Comment

by:Jason Thomas
ID: 40327592
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

Featured Post

Building an interactive eFuture classroom

Watch and learn how ATEN provided a total control system solution including seamless switching matrix switch, HDBaseT extenders, PDU, lighting control to build an interactive eFuture classroom.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VMware - Migrating 1 60
Hack an Nvidia commercial card  to Grid K1 / K2 or K340 / K520 3 94
V2V conversion or Clone in vCenter vSphere 6.x 5 92
SonicWall port forward 4 26
If we need to check who deleted a Virtual Machine from our vCenter. Looking this task in logs can be painful and spend lot of time, so the best way to check this is in the vCenter DB. Just connect to vCenter DB(default DB should be VCDB and using…
If your vDisk VHD file gets deleted from the image store accidentally or on purpose, you won't be able to remove the vDisk from the PVS console. There is a known workaround that is solid.
Teach the user how to configure vSphere clusters to support the VMware FT feature Open vSphere Web Client: Verify vSphere HA is enabled: Verify netowrking for vMotion and FT Logging is in place or create it: Turn On FT for a virtual machine: Verify …
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question