[ZBXNEXT-2946] Add Agent item for WMI discovery Created: 2015 Sep 09  Updated: 2024 Apr 10  Resolved: 2019 Oct 03

Status: Closed
Project: ZABBIX FEATURE REQUESTS
Component/s: Agent (G)
Affects Version/s: 2.2.10, 2.4.6
Fix Version/s: 4.4.0beta1, 4.4 (plan)

Type: New Feature Request Priority: Major
Reporter: Mārcis Lielturks Assignee: Michael Veksler
Resolution: Fixed Votes: 10
Labels: lld, windows, wmi
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows, WMI


Attachments: PNG File Screenshot from 2019-09-13 09-39-57.png     PNG File image-2019-10-03-11-02-57-867.png     XML File lld.xsl    
Issue Links:
Duplicate
is duplicated by ZBXNEXT-2459 Extend wmi.get functionality to query... Closed
is duplicated by ZBXNEXT-2945 Retrieval of multiple WMI values in ... Closed
Team: Team A
Sprint: Sprint 56 (Sep 2019), Sprint 57 (Oct 2019)
Story Points: 2.5

 Description   

Would be useful to have functionality where WMI query could be converted to JSON that can be supplied for LLD. The item syntax could be the same as for wmi.get[].

Currently the work around is to use system.run or UserParameters utilizing powershell, but that requires at least Windows 2012 or Windows Management Framework with ConvertTo-Json command and You also have to convert all property names before piping array of hashes to ConvertTo-Json. Additionally this creates administrative overhead for distributing helper scripts to agents.

snip from PS code to convert object property names to LLD macros
        $obj | Get-Member | % {
            $PropertyName=$_.Name
            $Value=$obj.$PropertyName
            $HashName="{#" + $PropertyName.ToUpper() + "}"
            if ($_.MemberType -ne "Method" -and $_.MemberType -ne "ScriptMethod" ) {
                $hash.Add($HashName, $Value)
                if ($PropertyName -like "*Time") {
                    if (($obj | Get-Member -MemberType "ScriptMethod" -Name ConvertToDateTime) -ne $null) {
                        Write-Debug "Converting $PropertyName($Value) to unix timestamp"
                        $hash[$HashName]=$($obj.ConvertToDateTime($Value)) | ConvertTo-UnixTimestamp
                    }
                }
            }
        }


 Comments   
Comment by Evgeny Kravchenko [ 2016 Jul 26 ]

It is very, very useful feature for Windows system monitoring.
Nice, if it will supported by zabbix agent for Windows.
I use LLD together with WMI ever and everywhere in Windows:
for hard drive discovery, for service discovery, for shares discovery, for printers discovery, moreover, for MSSQL database discovery.
But, I use wmic whith special format file, which converts result of WMI query to LLD format.

Example:
Windows service discovery
Key: system.run[{$LLD.WMI.SERVICES}]
Macro
{$LLD.WMI.SERVICES}
Value
wmic.exe /output:"%TEMP%\lld-wmi-srv.json" service where startmode="Auto" get displayname,name /format:"%ProgramFiles%\Zabbix\usr\xsl\lld.xsl" & type "%TEMP%\lld-wmi-srv.json" & del "%TEMP%\lld-wmi-srv.json"

I use temp file for output, because wmic works wrong with UTF8 in console.
File lld.xsl attached.

Comment by Vitor Duarte [ 2019 Aug 07 ]

Hi, @Evgeny. 

Is it possible that you attach your lld-wmi-srv.json? Just for I get the complete idea of your solution.

Comment by Michael Veksler [ 2019 Sep 26 ]

Available in 4.4.0beta1(master) 2bb5159ad86

Comment by Alexander Vladishev [ 2019 Oct 03 ]

Updated documentation:

Generated at Sat May 24 08:10:08 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.