ZABBIX Forums  

Go Back   ZABBIX Forums > Zabbix Discussions and Feedback > Zabbix Cookbook

Reply
 
Thread Tools Display Modes
  #1  
Old 02-02-2010, 08:39
dima_dm dima_dm is offline
Senior Member
 
Join Date: Dec 2009
Location: Moscow, Russia
Posts: 2,681
Default ESXi 4.0 Hardware and Software Monitoring VMWare

I use software:
ESXi 4.0:
ESXi 4 with HP agents
https://h20392.www2.hp.com/portal/sw...tegory=VIRTVMW

On Zabbix Server:
Software monitoring
VMware Infrastructure (VI) Perl Toolkit
http://communities.vmware.com/commun...phere_sdk_perl
See vSphere SDK for Perl Installation Guide http://www.vmware.com/support/developer/viperltoolkit/

Hardware monitoring
WBEM wbemcli
http://sourceforge.net/apps/mediawik...?title=Wbemcli

Used TCP ports:
WBEM https (TCP 5989)
VMware Infrastructure (VI) Perl Toolkit https (TCP 443)

/etc/zabbix/zabbix_server.conf

Timeout=30
….

/etc/zabbix/zabbix_agentd.conf
Timeout=30

### VMWare WBEM Monitoring
UserParameter=WBEM[*],/etc/zabbix/zabbix_wbem_vmware.pl $1 $2 $3
UserParameter=NumericSensor[*],egrep -i "SMX_NumericSensor_$2:" /tmp/vmware_$1.txt|sed 's/.*\t//'
UserParameter=Temperature[*],egrep -i "Temperature_$2:" /tmp/vmware_$1.txt|sed 's/.*\t//'
UserParameter=Power_Supply[*],egrep -i "Power_Supply_$2:" /tmp/vmware_$1.txt|sed 's/.*\t//'
UserParameter=Fan[*],egrep -i "Fan_$2:" /tmp/vmware_$1.txt|sed 's/.*\t//'
UserParameter=Proc[*],egrep -i "Proc_$2:" /tmp/vmware_$1.txt|sed 's/.*\t//'
UserParameter=Array[*],egrep -i "Array_$2:" /tmp/vmware_$1.txt|sed 's/.*\t//'
UserParameter=System_Memory[*],egrep -i "System_Memory:" /tmp/vmware_$1.txt|sed 's/.*\t//'
### End VMWare WBEM Monitoring
### VMWare Perl API Monitoring
UserParameter=API[*],/etc/zabbix/zabbix_perl_api_vmware.pl $1 $2 $3
UserParameter=Volume.Capacity[*],egrep -i "Volume.Capacity_$2:" /tmp/vmware_api_$1.txt|sed 's/.*\t//'
UserParameter=Volume.Free[*],egrep -i "Volume.Free_$2:" /tmp/vmware_api_$1.txt|sed 's/.*\t//'
UserParameter=CpuTotal[*],egrep -i "CpuTotal:" /tmp/vmware_api_$1.txt|sed 's/.*\t//'
UserParameter=CpuUsed[*],egrep -i "CpuUsed:" /tmp/vmware_api_$1.txt|sed 's/.*\t//'
UserParameter=MemSize[*],egrep -i "MemSize:" /tmp/vmware_api_$1.txt|sed 's/.*\t//'
UserParameter=MemUsage[*],egrep -i "MemUsage:" /tmp/vmware_api_$1.txt|sed 's/.*\t//'
UserParameter=MaintenanceMode[*],egrep -i "MaintenanceMode:" /tmp/vmware_api_$1.txt|sed 's/.*\t//'
UserParameter=MEM[*],egrep -i "MEM_$2:" /tmp/vmware_api_$1.txt|sed 's/.*\t//'
UserParameter=Array_stat[*],egrep -i "Array_$2.$3:" /tmp/vmware_api_$1.txt|sed 's/.*\t//'
UserParameter=NET[*],egrep -i "vmnic$2.$3:" /tmp/vmware_api_$1.txt|sed 's/.*\t//'
UserParameter=Uptime[*],egrep -i "Uptime:" /tmp/vmware_api_$1.txt|sed 's/.*\t//'
### End VMWare Perl API Monitoring


For monitoring hardware I use script
/etc/zabbix/zabbix_wbem_vmware.pl IP password username

For monitoring software I use script
/etc/zabbix/zabbix_perl_api_vmware.pl IP password username

where
IP – IP address of ESXi hypervisor
password – password for ESXi hypervisor
username - username for ESXi hypervisor

The scripts writes data in files
WBEM: /tmp/vmware_IP.txt
VMware Infrastructure (VI) Perl Toolkit: /tmp/vmware_api_IP.txt
Data format:
Key: Data

IP – IP address of ESXi hypervisor

Example:
cat /tmp/vmware_172.16.38.103.txt
SMX_NumericSensor_18: 2
Temperature_5: 34
Temperature_19: 42
SMX_NumericSensor_27: 2
Power_Supply_2: 2
Temperature_6: 51
Temperature_20: 48
SMX_NumericSensor_1: 2
Temperature_18: 42
Temperature_9: 37
SMX_NumericSensor_0: 2
Proc_1: 2

Power_Supply[172.16.38.103,1] – status 1-st Power_Supply on ESXi HyperVisor 172.16.38.103
/usr/local/bin/zabbix_get -s localhost -k Power_Supply[172.16.38.103,1]
Proc[172.16.38.103,2] - status 2-nd Processor on ESXi HyperVisor 172.16.38.103
/usr/local/bin/zabbix_get -s localhost -k Proc[172.16.38.103,2]




In Zabbix template
Macros
{$HOST} - IP address of ESXi hypervisor
{$PASSWORD} – password for ESXi hypervisor
{$USERNAME} - username for ESXi hypervisor

In Zabbix HOST IP Address = 127.0.0.1 for ALL ESXi hypervisor

Testing on HP DL360G5, HP DL360G6, HP DL360G7 and ESXi 4.0, ESXi 4.1, ESXi 5.0
Use command-line utils for testing
WBEM:
/usr/bin/wbemcli ei -noverify "https://root:Password@172.16.38.103/root/hpq:SMX_FAN"

VMware Infrastructure (VI) Perl Toolkit:
/usr/lib/vmware-viperl/apps/performance/viperformance.pl --host vmware2 --server 172.16.38.103 --countertype net --samples 1 --instance "*" --username root --password XXXXXX

Alternative method of access to WBEM Class via VMware Infrastructure (VI) Perl Toolkit
http://communities.vmware.com/docs/DOC-10665

1.10.2010 New Version ESXi4_VMWare.2010.10.01.zip
Changes:
1) Error handler for wbemcli is improved
Administration ->General ->VALUE MAPPING for Items "Perl API client status" and "WBEM client status"
VMWare client status
Code:
0 OK
1 VMWare client error
2 Status file write error
3 bad username or password
4 Can't connect to ESXi
5 Can't get data from ESXi
2)Template for ESXi4.1 is added
3) add -i option for egrep in /etc/zabbix/zabbix_agentd.conf

16.11.2010 new XML Template
P.S. On other versions ESXi the name of variables can be others. Fix names in Template Template_VMWare_HP_DL360_G6.xml
Attached Files
File Type: zip ESXi4_VMware.zip (10.9 KB, 2213 views)
File Type: zip ESXi4_VMWare.2010.10.01.zip (17.2 KB, 1094 views)
File Type: zip ESXi4_VMWare.2010.11.16.zip (17.5 KB, 4479 views)

Last edited by dima_dm; 11-11-2011 at 11:07. Reason: add -i option for egrep, New version 16.11.2010
Reply With Quote
  #2  
Old 02-02-2010, 16:45
alubel alubel is offline
Junior Member
 
Join Date: Jan 2010
Posts: 13
Default

I have a similar need: To monitor hardware health of ESXi box.

my only difference is im running sun 4170's.

The approach I took was to use IPMI directly to the Service processor. good thing about zabbix is that to do both host monitoring and IPMI monitoring, you dont have to create 2 hosts

the advantage of doing it out of band is that if a server goes down, we have logs and graphs of the events that led up to it.

What would be more interesting is hacking up the good old nagios check_esx scripts that use perl sdk and report things like disk I/O latency etc to zabbix
Reply With Quote
  #3  
Old 02-02-2010, 17:51
dima_dm dima_dm is offline
Senior Member
 
Join Date: Dec 2009
Location: Moscow, Russia
Posts: 2,681
Default

Disk I/O you can see in the script zabbix_perl_api_vmware.pl (Array_stat)
Reply With Quote
  #4  
Old 28-02-2010, 13:06
Murilex Murilex is offline
Senior Member
 
Join Date: Nov 2009
Posts: 119
Default

The idea of setting the IPs of my esxi boxes to 127.0.0.1 didn't sound very good for me. How about use your scripts as external check items? This way, we didn't need to use macros for real IPs of esxi boxes and these IPs would be passed automatically by zabbix server as parameters to external scripts.
Reply With Quote
  #5  
Old 01-03-2010, 05:36
dima_dm dima_dm is offline
Senior Member
 
Join Date: Dec 2009
Location: Moscow, Russia
Posts: 2,681
Default

Monitoring scripts it is polling a lot of variables, and use directly External Check will create very much unwanted loading of Zabbix and WMWare server.
You can use method:
To start polling of variables from cron (or External Check) and to write data to temp files.
External Check script will be get data from temp files

I register ESXi Hupervisor and ESXi guest system as separate monitoring objects and 127.0.0.1 in Zabbix does not create for me any problems.

Last edited by dima_dm; 01-03-2010 at 05:58.
Reply With Quote
  #6  
Old 01-03-2010, 13:50
Murilex Murilex is offline
Senior Member
 
Join Date: Nov 2009
Posts: 119
Default

Hello dima_dm! I haven't understood very well what you said . My plans are use your main scripts (zabbix_perl_api_vmware.pl and zabbix_wbem_vmware.pl) as external monitoring items. This way I could use real IPs of my ESXi hypervisors (zabbix hosts) and not fake IPs (127.0.0.1). I wouldn't change the logic of your scripts, therefore, they would continue to write info in temp files. I intend to write some scritps in order to read the temp files. These scripts would also be run by zabbix server as external monitoring scripts, again passing the real IP of ESXi hypervisors as parameters.

I wonder, considering that zabbix server and zabbix agents processes are running on the same machine, are there any benefits (for the server load) of using your scripts as user parameters (in zabbix agents) instead of as external monitoring items?

PS: I said nothing about monitoring of VMware guests.

Last edited by Murilex; 01-03-2010 at 14:29.
Reply With Quote
  #7  
Old 02-03-2010, 05:31
dima_dm dima_dm is offline
Senior Member
 
Join Date: Dec 2009
Location: Moscow, Russia
Posts: 2,681
Default

You have understood correctly.
Productivity will be identical with External check (get data via temp files) and Zabbix Agent.
Reply With Quote
  #8  
Old 22-04-2010, 15:56
Tristan Tristan is offline
Senior Member
 
Join Date: Feb 2008
Posts: 107
Default

why don't you just send the output from the perl scripts with the zabbixsender perl version to zabbix?
Reply With Quote
  #9  
Old 23-04-2010, 12:44
dima_dm dima_dm is offline
Senior Member
 
Join Date: Dec 2009
Location: Moscow, Russia
Posts: 2,681
Default

Because to debug and solve problems is much easier. At once it is clear where a problem in Zabbix or script.
Reply With Quote
  #10  
Old 01-10-2010, 10:55
dima_dm dima_dm is offline
Senior Member
 
Join Date: Dec 2009
Location: Moscow, Russia
Posts: 2,681
Default

1.10.2010 New Version ESXi4_VMWare.2010.10.01.zip
http://www.zabbix.com/forum/showpost...26&postcount=1
Changes:
1) Error handler for wbemcli is improved
2) Template for ESXi4.1 HP DL360G6 is added
3) add -i option for egrep in /etc/zabbix/zabbix_agentd.conf
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 12:14.