Solved

Set snmp on ESXi version 4.1, 5.1 and 5.5

Posted on 2014-09-08
25
2,455 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
  • 14
  • 10
25 Comments
 
LVL 117

Expert Comment

by:Andrew Hancock (VMware vExpert / EE MVE)
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 117

Expert Comment

by:Andrew Hancock (VMware vExpert / EE MVE)
Comment Utility
So, is the issue now only with 4.1 ?
0
 
LVL 1

Author Comment

by:Jason Thomas
Comment Utility
Hi Andrew. Yes, I looked at the link you sent and have successfully deployed SNMP on 5x versions. Just 4.1 outstanding.
0
 
LVL 117

Expert Comment

by:Andrew Hancock (VMware vExpert / EE MVE)
Comment Utility
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
Comment Utility
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 117

Expert Comment

by:Andrew Hancock (VMware vExpert / EE MVE)
Comment Utility
vCLI is installed on the workstation.
0
 
LVL 1

Author Comment

by:Jason Thomas
Comment Utility
My miss-understanding.
0
 
LVL 1

Author Comment

by:Jason Thomas
Comment Utility
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 117

Expert Comment

by:Andrew Hancock (VMware vExpert / EE MVE)
Comment Utility
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
Comment Utility
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
Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

 
LVL 9

Expert Comment

by:Carlos Ijalba
Comment Utility
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
Comment Utility
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 117

Expert Comment

by:Andrew Hancock (VMware vExpert / EE MVE)
Comment Utility
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
Comment Utility
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 117

Expert Comment

by:Andrew Hancock (VMware vExpert / EE MVE)
Comment Utility
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
Comment Utility
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 117

Expert Comment

by:Andrew Hancock (VMware vExpert / EE MVE)
Comment Utility
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
Comment Utility
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 117

Expert Comment

by:Andrew Hancock (VMware vExpert / EE MVE)
Comment Utility
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
Comment Utility
Hi, I run this:
vicfg-snmp.pl --server ServerName -c CommName1,CommName2 -t ManagementServer1, ManagementServer2
0
 
LVL 117

Accepted Solution

by:
Andrew Hancock (VMware vExpert / EE MVE) earned 500 total points
Comment Utility
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
Comment Utility
Thank you Andrew. I will try it when back at the office tomorrow morning.
0
 
LVL 1

Author Closing Comment

by:Jason Thomas
Comment Utility
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

NetScaler Deployment Guides and Resources

Citrix NetScaler is certified to support many of the most commonly deployed enterprise applications. Deployment guides provide in-depth recommendations on configuring NetScaler to meet specific application requirements.

Join & Write a Comment

This article will show you how to create an ISO CD-ROM/DVD-ROM image (*.iso), and MD5 checksum signature, for use with VMware vSphere Hypervisor 6.5 (ESXi 6.5). It's a good idea to compare checksums, because many installations fail because of a corr…
HOW TO: Upload an ISO image to a VMware datastore for use with VMware vSphere Hypervisor 6.5 (ESXi 6.5) using the vSphere Host Client, and checking its MD5 checksum signature is correct.  It's a good idea to compare checksums, because many installat…
Teach the user how to install log collectors and how to configure ESXi 5.5 for remote logging Open console session and mount vCenter Server installer: Install vSphere Core Dump Collector: Install vSphere Syslog Collector: Open vSphere Client: Config…
Advanced tutorial on how to run the esxtop command to capture a batch file in csv format in order to export the file and use it for performance analysis. He demonstrates how to download the file using a vSphere web client (or vSphere client) and exp…

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now