Michael_Baker
5 years agoNeophyte
Port WMI to linux collectors
Many of the WMI property sources could easily be done with wmic on Linux, look at MSSQL property source this simply looks for the SQL instances ect with WMI this can easily be done on Linux reducing the need for a Windows based collector I have included sample Groovy code and a link to a static compiled wmic to make life easier to test. wmic can be found here https://assets.nagios.com/downloads/nagiosxi/agents/wmic_1.3.16_static_64bit.tar.gz if needed I can jump on a session with your team and show it working on our Linux collectors.
Thoughts would be have the WMI class check what the underlying OS is on the collector to determine which method to use?
def queryAll(host, query) { def map = [] def wmi_user = hostProps.get("wmi.user") def wmi_pass = hostProps.get("wmi.pass") def wmi_domain = hostProps.get("wmi.domain") def command = ["/usr/local/bin/wmic", "-U", "${wmi_domain}/${wmi_user}%${wmi_pass}", "//${host}", "${query}"].execute().text.split("\n") command.each { if(!it.contains("CLASS:")) { mappings = it.tokenize("|") key = mappings.get(0) value = mappings.get(1) map << ["DISPLAYNAME":key,"NAME":value] } } return map }