Ad Widget
Collapse
ESXi 4.0 Hardware and Software Monitoring VMWare
Collapse
X
-
-
Last edited by dima_dm; 30-12-2010, 14:19.Comment
-
Good Job dima_dm, Thanks !
Got the script working with Proliant DL380 G5 and G6 too (ESXi 4.1 with HP tools).
Some problems on DL360 G5 under ESXi 3.5 (with HP tools) with WBEM: some classes are missing (Array classes like SMX_SAArraySystem). Perl-CLI script is working well. So I think I will cut the template into two parts: WBEM and Perl-CLI.
A tip, if you don't want to use root user (and the root password):
- Create a Role with right only on Host/CIM/CIM Interaction
- Create a user for zabbix and put it on the "root" group (user must be in the group in order to use WBEM and be in the group don't seems that you can make more thing that the role where you are).
- Give a permission with the role and the user
And now you can use this user to have monitoring informations. The user can long on the ESXi with VSphere Client but just have ReadOnly rights (better than root).Comment
-
-
I have started with playing with CIM access to ESXi (HW independed)
First start here http://www.vmware.com/support/develo...ash/index.html
There is API and Profile Ref (all supported objects and items you can pull)
Then you need pywebm http://blogs.vmware.com/esxi/2010/04...g-via-cim.html (link to pywebm and some sample)
My part of cim.py for monitoring vDs and pDs
client = pywbem.WBEMConnection('https://'+options.server,
(options.username, options.password),
'root/cimv2')
list = client.EnumerateInstances('VMware_DiskDrive')
if list is None:
print 'Error: Unable to locate any instances of VMware_HypervisorSoftwareIdentity'
else:
for i in range (len(list)):
print str(list[i]['HealthState']) + '---' + 'Disk' + str(i) + '---' + list[i]['Name']
list = client.EnumerateInstances('VMware_StorageVolume')
if list is None:
print 'Error: Unable to locate any instances of VMware_HypervisorSoftwareIdentity'
else:
for i in range (len(list)):
print str(list[i]['HealthState']) + '---' + list[i]['ElementName']
The output is following
5---Disk0---Drive 0 in enclosure 32 on controller 0 - ONLINE
5---Disk1---Drive 1 in enclosure 32 on controller 0 - ONLINE
5---Disk2---Drive 2 in enclosure 32 on controller 0 - ONLINE
5---Disk3---Drive 3 in enclosure 32 on controller 0 - ONLINE
5---Disk4---Drive 4 in enclosure 32 on controller 0 - ONLINE
5---Disk5---Drive 5 in enclosure 32 on controller 0 - ONLINE
5---Disk6---Drive 6 in enclosure 32 on controller 0 - ONLINE
5---Disk7---Drive 7 in enclosure 32 on controller 0 - ONLINE
5---RAID 1 boot Logical Volume 0 on controller 0, Drives(0e32,1e32) - OPTIMAL
5---RAID 5 data Logical Volume 1 on controller 0, Drives(2e32,3e32,4e32,5e32,6e32,7e32) - OPTIMAL
Then you need just to extract desired values and port it to ZabbixComment
-
Comment
-
another way to monitor vmware esx:
Browse with Yawn:
YAWN download: http://pywbem.svn.sourceforge.net/vi.../trunk/yawn.py
and configure the script:
script:
#!/usr/bin/python
import sys
import pywbem
wbemclient = pywbem.WBEMConnection("https://"+sys.argv[1], (sys.argv[2], sys.argv[3]), 'vmware/esxv2')
for instance in wbemclient.EnumerateInstances('CIM_ManagedElement' ) :
#if instance['ElementName'] == 'Proc 1' :
print "%s" % (instance['ElementName'])
use:
script ip user password______________________________
Version : 2.0.x
Server OS: Ubuntu 12.04
Zabbix Servers: 12
Monitored Windows Server: ~ 1000
______________________________Comment
-
Hi dima_dm,
I'm using your scripts with success, mostly. But I do regularly see this error in my zabbix_agentd.log file.
Line 205 is the print statement in this block...Code:Use of uninitialized value in concatenation (.) or string at /etc/zabbix/zabbix_perl_api_vmware.pl line 205. Use of uninitialized value in concatenation (.) or string at /etc/zabbix/zabbix_perl_api_vmware.pl line 205. Use of uninitialized value in concatenation (.) or string at /etc/zabbix/zabbix_perl_api_vmware.pl line 205. Use of uninitialized value in concatenation (.) or string at /etc/zabbix/zabbix_perl_api_vmware.pl line 205. Use of uninitialized value in concatenation (.) or string at /etc/zabbix/zabbix_perl_api_vmware.pl line 205.
Any thoughts on why I get this error?Code:foreach $i (keys(%hash)) { print FILE "$i:\t$hash{$i}\n"; } close(FILE); return $error; }
Thanks,
MattComment
-
Do you see line in your vmware_api_X.Y.Z.H.txt file without data?Hi dima_dm,
I'm using your scripts with success, mostly. But I do regularly see this error in my zabbix_agentd.log file.
Code:Use of uninitialized value in concatenation (.) or string at /etc/zabbix/zabbix_perl_api_vmware.pl line 205. Use of uninitialized value in concatenation (.) or string at /etc/zabbix/zabbix_perl_api_vmware.pl line 205. Use of uninitialized value in concatenation (.) or string at /etc/zabbix/zabbix_perl_api_vmware.pl line 205. Use of uninitialized value in concatenation (.) or string at /etc/zabbix/zabbix_perl_api_vmware.pl line 205. Use of uninitialized value in concatenation (.) or string at /etc/zabbix/zabbix_perl_api_vmware.pl line 205.
Example
Key: Data
Key1:Comment
-
Problem may be in the code
You can add print operator. Why variable $Value[0] was not specified for this key? It’s may be bug in VMware Hypervisor or problem in VMware Disk Arrays configuration or bug in script zabbix_perl_api_vmware.pl.Code:if ($args{countertype} eq "disk" && $name ne "") { my $type=$counter->rollupType->val; my $desc=$counter->nameInfo->label; my $units=$counter->unitInfo->label; if (defined $ARRAY{$name}) { $name=$ARRAY{$name}; }else{ my $i; my $max=-1; my $current=0; foreach $i (keys %ARRAY) { if ($ARRAY{$i}=~/Array_(\d+)/) {$current=$1; if ($current > $max) {$max=$current}} } $max++; $ARRAY{$name}="Array_".$max; $name=$ARRAY{$name}; } $desc=~s/ /_/g; $desc=~s/"//g; $desc=~s/:/_/g; if ($name ne "" && $desc ne "" ) { if ($units eq "KBps") { $API{$name.".".$desc.".".$type}=$Value[0] * 1024; # in Bps }else{ $API{$name.".".$desc.".".$type}=$Value[0]; # Number or Millisecond } } }
Do you have 4 Disk Arrays in configuration VMware Hypervisor?Last edited by dima_dm; 19-04-2011, 09:02.Comment
-
I'm trying to run zabbix_perl_api_vmware.pl against vcenter, and am getting:
The --vihost option must be specified when connecting to vCenter.
I'm aware that this is generated by VIExt::get_host_view - any ideas? I thought I might be able to use Opts::set_option, but the syntax is evading me.Comment

Comment