[ZBXNEXT-2459] Extend wmi.get functionality to query properties of type array Created: 2014 Sep 13  Updated: 2019 Sep 23  Resolved: 2019 Sep 23

Status: Closed
Project: ZABBIX FEATURE REQUESTS
Component/s: Agent (G)
Affects Version/s: None
Fix Version/s: None

Type: New Feature Request Priority: Trivial
Reporter: v99glu Assignee: Unassigned
Resolution: Duplicate Votes: 8
Labels: windows, wmi
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Text File wmi.cpp    
Issue Links:
Duplicate
duplicates ZBXNEXT-2946 Add Agent item for WMI discovery Closed

 Description   

I need to monitor SmartArray HDDs of old server HP DL360 G5. ILO2 of the server doesn't support SNMP (agentless SNMP) and HP system software for Windows on the server doesn't support monitoring of HDDs via SNMP, therefore I have to use HP WBEM Provider for Windows and WMI to get info about SmartArray disk drives.
Fortunately Zabbix supports WMI and I gaily execute on zabbix server:
zabbix_get -s winhost -k "wmi.get[root\hpq,Select OperationalStatus from HPSA_DiskDrive where ElementName='Port:2I Box:1 Bay:5']" and ...
get ZBX_NOTSUPPORTED!

According to MS note (http://msdn.microsoft.com/en-us/library/aa392902(v=vs.85).aspx) "WQL does not support queries of array datatypes" therefore some programming logic is requirred to access the arrays queried with WQL. And HPSA_DiskDrive.OperationalStatus is just a property of type array of strings.
As mentioned above, WQL doesn't allow query like "Select OperationalStatus[0] from HPSA_DiskDrive" and usually arrays queried with WQL processed with something like "for each" loop. Such technique is not available in Zabbix wmi.get.

So, the feature request:
Please add third parameter to wmi.get - index of element in an array:
wmi.get[<namespace>,<query>,<index>]
<namespace> - WMI namespace
<query> - WMI query returning a single object
<index> - index of element if <query> returns object of type array (default value is 0)

Similar functionality is realized in powershell - http://technet.microsoft.com/en-us/library/ff405671.aspx

IMHO, such improvement will be usefull in many WMI cases not only in my one because property of type array is an ordinary thing amongst WBEM classes.



 Comments   
Comment by v99glu [ 2014 Sep 13 ]

Of course I can use Zabbix Agent UserParameter + PowerShell script to fetch element of array but it is elegantless and excellent Zabbix wmi.get ability stays outboard.

Comment by Oleksii Zagorskyi [ 2014 Sep 14 ]

could be used then for LLD+WMI (missing yet, even corresponding feature request).

EDIT: created in ZBXNEXT-2946

Comment by Pedro Nunes [ 2014 Nov 26 ]

Attached wmi.cpp that supports arrays. Only index 0. Think thats enought to support HP Wbem providers.

Comment by Pedro Nunes [ 2014 Dec 23 ]

Ok,

Attached my last wmi.cpp that i use for some time in my production environment.
Full features and fixes:

  • Memory leak that is also fixed in ZBX-8506
  • Supports arrays, only index 0 right now but for me is enought. Queries like: wmi.get[root\hpq,select OperationalStatus from HP_ManagementProcessor where Name = 'Integrated Lights Out (iLO)'] are supported
  • Support for queries with \ like: wmi.get[root\cimv2,select status from Win32_DiskDrive where DeviceId = '\\.\PHYSICALDRIVE0']. Current agent does not support them.
  • Some fixes from my previous code.
  • Added timeout on WMI queries which prevents stucking threads on agent (This happens on the current agent). Hardcoded timeout is 60sec.
  • Extensive logging for debugging and normal operation.
Generated at Thu Apr 25 16:59:10 EEST 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.