Class WMI


  • public class WMI
    extends WinResource
    This class help to collect wmi perf data.
    We will try to extract wmi related credentials from the hostProps if existed.
    The following properties may be used:
    property name property note
    wmi.user / wmiuser the username for wmi requests
    wmi.pass / wmipass the password for wmi requests

    Example:
     
    
    import com.santaba.agent.groovyapi.win32.WMI
    import com.santaba.agent.groovyapi.win32.WMISession
    
    // query all processes with timeout in 30 seconds
    // query the processes on a host monitored by current collector
    List<Map<String, String>> processes = WMI.queryAll("YourHost", "select * from win32_process", 30);
    
    // query the processes on a host NOT monitored by current collector
    WMISession connection = WMI.open("YourHost", "username", "password");
    // queryAll (namespace, wql, timeoutInSeconds)
    connection.queryAll("CIMv2", "select * from win32_process", 30);
    // queryFirst (namespace, wql, timeoutInSeconds)
    connection.queryFirst("CIMv2", "select * from win32_process", 30);
     
     
    • Constructor Summary

      Constructors 
      Constructor Description
      WMI()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static WMISession open​(java.lang.String host)
      Open a WMI session for given host.
      Will try to extract wmi related credentials from hostProps.
      This will only apply to the host which is monitored by current collector.
      static WMISession open​(java.lang.String host, java.lang.String username, java.lang.String password)
      Open a WMI session for given host with username and password provided
      static WMISession open​(java.lang.String host, java.lang.String authority, java.lang.String username, java.lang.String password)
      Open a WMI session for given host with username and password provided
      static java.util.List<java.util.Map<java.lang.String,​java.lang.String>> queryAll​(java.lang.String host, java.lang.String wql)
      Query all the object returned by the WQL in CIMv2 namespace with default timeout This will only apply to the host which is monitored by current collector.
      static java.util.List<java.util.Map<java.lang.String,​java.lang.String>> queryAll​(java.lang.String host, java.lang.String wql, long timeoutSeconds)
      Query all the object returned by the WQL in CIMv2 namespace with given timeout in seconds This will only apply to the host which is monitored by current collector.
      static java.util.List<java.util.Map<java.lang.String,​java.lang.String>> queryAll​(java.lang.String host, java.lang.String namespace, java.lang.String wql)
      Query all the object returned by the WQL in given namespace with default timeout
      This will only apply to the host which is monitored by current collector.
      static java.util.List<java.util.Map<java.lang.String,​java.lang.String>> queryAll​(java.lang.String host, java.lang.String namespace, java.lang.String wql, long timeoutSeconds)
      Query all the object returned by the WQL in given namespace with given timeout in seconds
      This will only apply to the host which is monitored by current collector.
      static java.util.Map<java.lang.String,​java.lang.String> queryFirst​(java.lang.String host, java.lang.String wql)
      Query the first object returned by the WQL in CIMv2 namespace with default timeout
      This will only apply to the host which is monitored by current collector.
      static java.util.Map<java.lang.String,​java.lang.String> queryFirst​(java.lang.String host, java.lang.String wql, long timeoutSeconds)
      Query the first object returned by the WQL in CIMv2 namespace with given timeout.
      This will only apply to the host which is monitored by current collector.
      static java.util.Map<java.lang.String,​java.lang.String> queryFirst​(java.lang.String host, java.lang.String namespace, java.lang.String wql)
      Query the first object returned by the WQL with default timeout
      This will only apply to the host which is monitored by current collector.
      static java.util.Map<java.lang.String,​java.lang.String> queryFirst​(java.lang.String host, java.lang.String namespace, java.lang.String wql, long timeoutSeconds)
      Query the first object returned by the WQL with given timeout
      This will only apply to the host which is monitored by current collector.
      • Methods inherited from class com.logicmonitor.common.sse.utils.SSEResource

        register, unregister
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • WMI

        public WMI()
    • Method Detail

      • open

        public static WMISession open​(java.lang.String host)
        Open a WMI session for given host.
        Will try to extract wmi related credentials from hostProps.
        This will only apply to the host which is monitored by current collector.
        Parameters:
        host - - host to connect to
        Returns:
        WMISession object
      • open

        public static WMISession open​(java.lang.String host,
                                      java.lang.String username,
                                      java.lang.String password)
        Open a WMI session for given host with username and password provided
        Parameters:
        host - - host to connect to
        username - WMI auth username
        password - WMI auth password
        Returns:
        WMISession object
      • open

        public static WMISession open​(java.lang.String host,
                                      java.lang.String authority,
                                      java.lang.String username,
                                      java.lang.String password)
        Open a WMI session for given host with username and password provided
        Parameters:
        host - - host to connect to
        authority - WMI authority type, include: "NTLMv1" | "NTLMv2" | "Kerberos"
        username - WMI auth username
        password - WMI auth password
        Returns:
        WMISession object
      • queryFirst

        public static java.util.Map<java.lang.String,​java.lang.String> queryFirst​(java.lang.String host,
                                                                                        java.lang.String wql)
                                                                                 throws java.io.IOException,
                                                                                        java.lang.InterruptedException,
                                                                                        java.util.concurrent.ExecutionException
        Query the first object returned by the WQL in CIMv2 namespace with default timeout
        This will only apply to the host which is monitored by current collector.
        Parameters:
        host - - host to connect to
        wql - - WQL to execute
        Returns:
        first object as key value pairs
        Throws:
        java.io.IOException
        java.lang.InterruptedException
        java.util.concurrent.ExecutionException
      • queryFirst

        public static java.util.Map<java.lang.String,​java.lang.String> queryFirst​(java.lang.String host,
                                                                                        java.lang.String wql,
                                                                                        long timeoutSeconds)
                                                                                 throws java.io.IOException,
                                                                                        java.lang.InterruptedException,
                                                                                        java.util.concurrent.ExecutionException
        Query the first object returned by the WQL in CIMv2 namespace with given timeout.
        This will only apply to the host which is monitored by current collector.
        Parameters:
        host - - host to connect to
        wql - - WQL to execute
        timeoutSeconds - - timeout in seconds
        Returns:
        first object as key value pairs
        Throws:
        java.io.IOException
        java.lang.InterruptedException
        java.util.concurrent.ExecutionException
      • queryFirst

        public static java.util.Map<java.lang.String,​java.lang.String> queryFirst​(java.lang.String host,
                                                                                        java.lang.String namespace,
                                                                                        java.lang.String wql)
                                                                                 throws java.io.IOException,
                                                                                        java.lang.InterruptedException,
                                                                                        java.util.concurrent.ExecutionException
        Query the first object returned by the WQL with default timeout
        This will only apply to the host which is monitored by current collector.
        Parameters:
        host - - host to connect to
        namespace - - namespace to use, default to CIMv2
        wql - - WQL to execute
        Returns:
        first object as key value pairs
        Throws:
        java.io.IOException
        java.lang.InterruptedException
        java.util.concurrent.ExecutionException
      • queryFirst

        public static java.util.Map<java.lang.String,​java.lang.String> queryFirst​(java.lang.String host,
                                                                                        java.lang.String namespace,
                                                                                        java.lang.String wql,
                                                                                        long timeoutSeconds)
                                                                                 throws java.io.IOException,
                                                                                        java.lang.InterruptedException,
                                                                                        java.util.concurrent.ExecutionException
        Query the first object returned by the WQL with given timeout
        This will only apply to the host which is monitored by current collector.
        Parameters:
        host - - host to connect to
        namespace - - namespace to use, default to CIMv2
        wql - - WQL to execute
        timeoutSeconds - - timeout in seconds
        Returns:
        first object as key value pairs
        Throws:
        java.io.IOException
        java.lang.InterruptedException
        java.util.concurrent.ExecutionException
      • queryAll

        public static java.util.List<java.util.Map<java.lang.String,​java.lang.String>> queryAll​(java.lang.String host,
                                                                                                      java.lang.String wql)
                                                                                               throws java.io.IOException,
                                                                                                      java.lang.InterruptedException,
                                                                                                      java.util.concurrent.ExecutionException
        Query all the object returned by the WQL in CIMv2 namespace with default timeout This will only apply to the host which is monitored by current collector.
        Parameters:
        host - - host to connect to
        wql - - WQL to execute
        Returns:
        objects in key value pairs returned by the query
        Throws:
        java.io.IOException
        java.lang.InterruptedException
        java.util.concurrent.ExecutionException
      • queryAll

        public static java.util.List<java.util.Map<java.lang.String,​java.lang.String>> queryAll​(java.lang.String host,
                                                                                                      java.lang.String wql,
                                                                                                      long timeoutSeconds)
                                                                                               throws java.io.IOException,
                                                                                                      java.lang.InterruptedException,
                                                                                                      java.util.concurrent.ExecutionException
        Query all the object returned by the WQL in CIMv2 namespace with given timeout in seconds This will only apply to the host which is monitored by current collector.
        Parameters:
        host - - host to connect to
        wql - - WQL to execute
        timeoutSeconds - - timeout in seconds
        Returns:
        objects in key value pairs returned by the query
        Throws:
        java.io.IOException
        java.lang.InterruptedException
        java.util.concurrent.ExecutionException
      • queryAll

        public static java.util.List<java.util.Map<java.lang.String,​java.lang.String>> queryAll​(java.lang.String host,
                                                                                                      java.lang.String namespace,
                                                                                                      java.lang.String wql)
                                                                                               throws java.io.IOException,
                                                                                                      java.lang.InterruptedException,
                                                                                                      java.util.concurrent.ExecutionException
        Query all the object returned by the WQL in given namespace with default timeout
        This will only apply to the host which is monitored by current collector.
        Parameters:
        host - - host to connect to
        namespace - - namespace to use
        wql - - WQL to be executed
        Returns:
        objects in key value pairs returned by the query
        Throws:
        java.io.IOException
        java.lang.InterruptedException
        java.util.concurrent.ExecutionException
      • queryAll

        public static java.util.List<java.util.Map<java.lang.String,​java.lang.String>> queryAll​(java.lang.String host,
                                                                                                      java.lang.String namespace,
                                                                                                      java.lang.String wql,
                                                                                                      long timeoutSeconds)
                                                                                               throws java.io.IOException,
                                                                                                      java.lang.InterruptedException,
                                                                                                      java.util.concurrent.ExecutionException
        Query all the object returned by the WQL in given namespace with given timeout in seconds
        This will only apply to the host which is monitored by current collector.
        Parameters:
        host - - host to connect to
        namespace - - namespace to use
        wql - - WQL to be executed
        timeoutSeconds - - timeout in seconds
        Returns:
        objects in key value pairs returned by the query
        Throws:
        java.io.IOException
        java.lang.InterruptedException
        java.util.concurrent.ExecutionException