Forum Discussion

Michael_Baker's avatar
4 years ago

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
}

 

6 Replies

  • We're working on getting "Windows Parity" on Linux collectors this year. WMI, Powershell, PDH. We're not using wmic, but more info will come as we progress.

  • Hi Michael,

    you might want to take a look at this recently release WMI open source library:

    https://github.com/cesbit/aiowmi

    If you have any questions with regards to this library feel free to reach out.

     

     

  • From what i hear this is pretty close to or already in beta for PowerShell. Likely only a matter of time before WMI happens. 

  • Moving away from WMI to WinRM would be the more forward looking path.


  • From what i hear this is pretty close to or already in beta for PowerShell. Likely only a matter of time before WMI happens. 

    WinRM is in beta from what I have heard.

  • That may be, but Microsoft has released officially supported Powershell for Linux. They’ll probably go that route. @Michael Rodrigues , thoughts?