Wednesday, 29 May 2013

configure snmp on an esxi host

Configure SNMP for ESXi
based on this www

http://pubs.vmware.com/vsphere-50/topic/com.vmware.vsphere.monitoring.doc_50/GUID-8EF36D7D-59B6-4C74-B1AA-4A9D18AB6250.html

numbers in brackets indicate the step is optional

0
download and install the vsphere cli to desktop - from the vcli command prompt:

1
Display snmp agent configuration
**********
vicfg-snmp.pl --server esxi001.domain.com -s
**********
C:\>vicfg-snmp.pl --server esxi001.domain.com -s
Enter username: root
Enter password:
Current SNMP agent settings:
Enabled  : 0
UDP port : 161
Communities :
Notification targets :
Options :
EnvEventSource=indications

2
Configure SNMP Communities
**********
vicfg-snmp.pl --server esxi001 --username root --password Secret!! -c public1
**********
C:\>vicfg-snmp.pl --server esxi001 --username root --password Secret!! -c public1
Changing community list to: public1...
Complete.
C:\>vicfg-snmp.pl --server esxi001.domain.com -s
Enter username: root
Enter password:
Current SNMP agent settings:
Enabled  : 0
UDP port : 161
Communities :
public1
Notification targets :
Options :
EnvEventSource=indications

3
If the SNMP agent is not enabled, enable it by typing
**********
vicfg-snmp.pl --server esxi001 --username root --password Secret!! --enable
**********
C:\>vicfg-snmp.pl --server esxi001 --username root --password Secret!! --enable
Enabling agent...
Complete.
C:\>vicfg-snmp.pl --server esxi001.domain.com -s
Enter username: root
Enter password:
Current SNMP agent settings:
Enabled  : 1UDP port : 161
Communities :
public1
Notification targets :
Options :
EnvEventSource=indications

4
Configure the SNMP Agent to Send Traps
**********
vicfg-snmp.pl --server esxi001 --username root --password Secret!! -t solarwinds.domain.com@162/public1
**********
C:\>vicfg-snmp.pl --server esxi001 --username root --password Secret!! -t solarwinds.domain.com@162/public1
Changing notification(trap) targets list to: solarwinds.domain.com@162/public1...
Complete.

5
Send a test trap to verify that the agent is configured correctly by typing
**********
vicfg-snmp.pl --server esxi001 --username root --password Secret!! --test
**********
C:\>vicfg-snmp.pl --server esxi001 --username root --password Secret!! --test
Sending test nofication(trap) to all configured targets...
Complete. Check with each target to see if trap was received.

(6)
Configure the SNMP Agent for Polling (- not necessary - already done by default)
**********
vicfg-snmp.pl --server esxi001 --username root --password Secret!! -p 161
**********
C:\>vicfg-snmp.pl --server esxi001 --username root --password Secret!! -p 161
Changing udp port to 161...
Complete.

C:\>vicfg-snmp.pl --server esxi001.domain.com -s
Enter username: root
Enter password:
Current SNMP agent settings:
Enabled  : 1
UDP port : 161
Communities :
public1
Notification targets :
solarwinds.domain.com@162/public1
Options :
EnvEventSource=indications

(7)
Configure the Source used by the SNMP Agent for Hardware Events (- not necessary - already done by default)
**********
for vsphere4
vicfg-snmp.pl --server hostname --username username --password password -y sensors
for vsphere5
vicfg-snmp.pl --server esxi001 --username root --password Secret!! -y indications
**********
C:\>vicfg-snmp.pl --server esxi001 --username root --password Secret!! -y indications
Changing source of hardware event source: indications...
Complete.
C:\>vicfg-snmp.pl --server esxi001.domain.com --username root --password Secret!! -s
Current SNMP agent settings:
Enabled  : 1
UDP port : 161
Communities :
public1
Notification targets :
solarwinds.domain.com@162/public1
Options :
EnvEventSource=indications

8
Configure SNMP Management Client Software

After you have configured a vCenter Server system or a host to send traps, you must configure your management client software to receive and interpret those traps.

(9)
Configure the SNMP Agent to Filter Traps
vicfg-snmp.pl --server hostname --username username --password password -n oid_list

From the vSphere CLI, vicfg-snmp.pl --server hostname --username username --password password -n oid_list
oid_list is a list of OIDs for the traps to filter, separated by commas. This list replaces any OIDs that were previously specificed using this command.
For example, to filter out coldStart (OID 1.3.6.1.4.1.6876.4.1.1.0) and warmStart (OID 1.3.6.1.4.1.6876.4.1.1.1) traps, type vicfg-snmp.pl --server hostname --username username --password password -n 1.3.6.1.4.1.6876.4.1.1.0,1.3.6.1.4.1.6876.4.1.1.1
To clear all trap filters, typevicfg-snmp.pl --server hostname --username username --password password -n reset

Thursday, 23 May 2013

vmware tools install upgrade error how to force uninstall

force uninstall of vmtools / vmware tools

mount the vmtools cdrom in the vm using VM -> Guest -> Install / Upgrade VMware Tools - choose interactive install

from the VM command prompt cd to the cdrom drive and run the command
setup64 /c
this does the uninstall - no reboot needed

then run setup64 (from gui) to reinstall
error when trying to upgrade = isolation.tools.guestInitiatedUpgrade.disable = "FALSE"

Wednesday, 22 May 2013

service mgmt-vmware stop start restart -ash: service: not found - Usage: /etc/init.d/hostd {start|stop|restart}

KB: 2030663

~ # service mgmt-vmware restart
-ash: service: not found

~ # /etc/init.d/hostd status
Usage: /etc/init.d/hostd {start|stop|restart}
~ # ps -s | grep hostd
16978 16978 hostd-worker         WAIT   UFUTEX 0-31 hostd
16979 16978 hostd-poll           WAIT   UPOL   0-31 hostd
16980 16978 hostd-worker         WAIT   USLP   0-31 hostd17006 16978 vix-high-p           WAIT   UPOL   0-31 hostd
17007 17007 nssquery             WAIT   UPIPER 0-31 /usr/libexec/hostd/nssquery
17008 16978 hostd-worker         WAIT   UFUTEX 0-31 hostd
17010 16978 hostd-worker         WAIT   UFUTEX 0-31 hostd
17011 16978 hostd-worker         WAIT   UFUTEX 0-31 hostd
17087 16978 vix-poll             WAIT   UPOL   0-31 hostd
17275 16978 hostd-worker         WAIT   UFUTEX 0-31 hostd
17390 16978 hostd-worker         WAIT   UFUTEX 0-31 hostd
17506 16978 hostd-worker         WAIT   UFUTEX 0-31 hostd


~ # /etc/init.d/vpxa status
-ash: /etc/init.d/vpxa: not found

~ # ps -s | grep vpxa
16987 16987 vpxa                 WAIT   UFUTEX 0-31 /opt/vmware/vpxa/vpx/vpxa
16997 16987 vpxa                 WAIT   UPOL   0-31 /opt/vmware/vpxa/vpx/vpxa
16998 16987 vpxa                 WAIT   USLP   0-31 /opt/vmware/vpxa/vpx/vpxa
16999 16987 vpxa                 WAIT   UFUTEX 0-31 /opt/vmware/vpxa/vpx/vpxa
17001 16987 vpxa                 WAIT   UFUTEX 0-31 /opt/vmware/vpxa/vpx/vpxa
17002 16987 vpxa                 WAIT   UFUTEX 0-31 /opt/vmware/vpxa/vpx/vpxa
17003 16987 vpxa                 WAIT   UFUTEX 0-31 /opt/vmware/vpxa/vpx/vpxa
17004 16987 vpxa                 WAIT   UFUTEX 0-31 /opt/vmware/vpxa/vpx/vpxa
17005 16987 vpxa                 WAIT   UFUTEX 0-31 /opt/vmware/vpxa/vpx/vpxa
17271 16987 vpxa                 WAIT   UFUTEX 0-31 /opt/vmware/vpxa/vpx/vpxa
17278 16987 vpxa                 WAIT   UFUTEX 0-31 /opt/vmware/vpxa/vpx/vpxa
17279 16987 vpxa                 WAIT   UFUTEX 0-31 /opt/vmware/vpxa/vpx/vpxa
17282 16987 vpxa                 WAIT   UFUTEX 0-31 /opt/vmware/vpxa/vpx/vpxa
17293 16987 vpxa                 WAIT   UFUTEX 0-31 /opt/vmware/vpxa/vpx/vpxa
17294 16987 vpxa                 WAIT   UFUTEX 0-31 /opt/vmware/vpxa/vpx/vpxa
17295 16987 vpxa                 WAIT   UFUTEX 0-31 /opt/vmware/vpxa/vpx/vpxa
17296 16987 vpxa                 WAIT   UFUTEX 0-31 /opt/vmware/vpxa/vpx/vpxa
17297 16987 vpxa                 WAIT   UFUTEX 0-31 /opt/vmware/vpxa/vpx/vpxa

great post on how to change vmnic numbering

http://www.virten.net/2012/09/esxi-change-vmnic-vmhba-numbering/


cp /etc/vmware/esx.conf /etc/vmware/esx.conf.old

vi /etc/vmware/esx.conf

Search for “vmnic” (press /vmnic<ENTER>)
press n for next occurance and N for previous.

/device/000:000:26.0/owner = "vmkernel"
/device/000:000:29.0/owner = "vmkernel"
/device/000:000:31.2/vmkname = "vmhba0"
/device/000:001:00.0/vmkname = "vmnic0"
/device/000:001:00.1/vmkname = "vmnic1"
/device/000:001:00.2/vmkname = "vmnic2"
/device/000:001:00.3/vmkname = "vmnic3"
/device/000:001:00.4/vmkname = "vmnic4"
/device/000:001:00.5/vmkname = "vmnic5"
/device/000:003:00.0/vmkname = "vmnic6"
/device/000:003:00.1/vmkname = "vmnic7"
/device/000:067:00.0/vmkname = "vmhba1"
/device/000:068:00.0/vmkname = "vmhba2"

Change the vmnic label. (Move the cursor to the label, press r for “replace” and enter the new number)


Search again for “vmnic” (press /vmnic<ENTER>) until you find something like this

/net/pnic/child[0000]/duplex = "full"
/net/pnic/child[0000]/mac = "90:b1:1c:0f:7a:fb"
/net/pnic/child[0000]/name = "vmnic0"
/net/pnic/child[0000]/speed = "10000"
/net/pnic/child[0000]/virtualMac = "00:50:56:5f:7a:fb"
/net/pnic/child[0001]/duplex = "full"
/net/pnic/child[0001]/mac = "90:b1:1c:0f:7a:fd"
/net/pnic/child[0001]/name = "vmnic1"
/net/pnic/child[0001]/speed = "10000"
/net/pnic/child[0001]/virtualMac = "00:50:56:5f:7a:fd"
/net/pnic/child[0002]/mac = "90:b1:1c:0f:7a:ff"
/net/pnic/child[0002]/name = "vmnic2"
/net/pnic/child[0002]/virtualMac = "00:50:56:5f:7a:ff"
/net/pnic/child[0003]/mac = "90:b1:1c:0f:7b:01"
/net/pnic/child[0003]/name = "vmnic3"
/net/pnic/child[0003]/virtualMac = "00:50:56:5f:7b:01"
/net/pnic/child[0004]/mac = "90:b1:1c:0f:7b:03"
/net/pnic/child[0004]/name = "vmnic4"
/net/pnic/child[0004]/virtualMac = "00:50:56:5f:7b:03"
/net/pnic/child[0005]/mac = "90:b1:1c:0f:7b:05"
/net/pnic/child[0005]/name = "vmnic5"
/net/pnic/child[0005]/virtualMac = "00:50:56:5f:7b:05"

Move the cursor to the line and press dd for each line you want to delete.

reboot

Tuesday, 21 May 2013

configuring LLDP and cdp

esxcfg-vswitch vSwitch0 -b
shows current status - which is listen


esxcfg-vswitch vSwitch0 -B both
sets esx host to broadcast and listen

use
esxcli network vswitch standard set -c both -v vSwitch0
for esxi5


command to run on the switch:

show lldp info remote-device



thanks to http://rickardnobel.se/vswitch-cdp-with-hp-switches/

Friday, 17 May 2013

echo to stdout all the commands in a script

put this at the top of the file
#!/bin/bash -x

for esxi
#!/bin/ash -x