Class PDH


  • public class PDH
    extends java.lang.Object
    This will provide PDH related operations.
    property name property note
    pdh.user the username for pdh requests (Will prefer to use this property)
    pdh.pass the username for pdh requests (Will prefer to use this property)
    wmi.user / wmiuser the username for pdh requests
    wmi.pass / wmipass the password for pdh requests

    Example:
     
    
    import com.santaba.agent.groovyapi.win32.PDH
    import com.santaba.agent.groovyapi.win32.PDHSession
    // for the host which monitored by current collector
    String processorTime = PDH.getCounter("YourHost", "\\Processor(_Total)\\% Processor Time");
    println processorTime;
    
    // for the host which NOT monitored by current collector
    // open a PDH sesion
    PDHSession session = PDH.open("TheHost", "username", "password");
    // query
    processorTime2 = session.getCounter("\\Processor(_Total)\\% Processor Time");
    println processorTime2;
    
     
     
    • Constructor Summary

      Constructors 
      Constructor Description
      PDH()  
    • Method Summary

      All Methods Static Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      static java.lang.String getCounter​(java.lang.String host, java.lang.String counter)
      Get a single counter from the given host
      This will only apply to the host which is monitored by current collector.
      static java.lang.String getCounter​(java.lang.String host, java.lang.String counter, long timeoutSeconds)
      Get a single counter from the given host with timeout
      This will only apply to the host which is monitored by current collector.
      static java.util.List<java.lang.String> getCounters​(java.lang.String host, java.util.List<java.lang.String> counters)
      Get values for a list of counters from the given host
      This will only apply to the host which is monitored by current collector.
      static java.util.List<java.lang.String> getCounters​(java.lang.String host, java.util.List<java.lang.String> counters, long timeoutSeconds)
      Get values for a list of counters from the given host
      This will only apply to the host which is monitored by current collector.
      static java.lang.String getDiscover​(java.lang.String host, java.lang.String category)
      Get a single counter from the given host
      This will only apply to the host which is monitored by current collector.
      static java.lang.String getDiscover​(java.lang.String host, java.lang.String category, long timeoutSeconds)
      Get a single counter from the given host with timeout
      This will only apply to the host which is monitored by current collector.
      static java.lang.String getEnum​(java.lang.String host, java.lang.String object)
      Get a object from the given host
      This will only apply to the host which is monitored by current collector.
      static java.lang.String getEnum​(java.lang.String host, java.lang.String object, long timeoutSeconds)
      Get a object from the given host with timeout
      This will only apply to the host which is monitored by current collector.
      static java.lang.String getRatioCounter​(java.lang.String host, java.lang.String counter)
      Get a single ratio counter from the given host
      This will only apply to the host which is monitored by current collector.
      static java.lang.String getRatioCounter​(java.lang.String host, java.lang.String counter, long timeoutSeconds)
      Get a single ratio counter from the given host
      This will only apply to the host which is monitored by current collector.
      static java.util.List<java.lang.String> getRatioCounters​(java.lang.String host, java.util.List<java.lang.String> counters)
      Get values for a list of ratio counters from the given host
      This will only apply to the host which is monitored by current collector.
      static java.util.List<java.lang.String> getRatioCounters​(java.lang.String host, java.util.List<java.lang.String> counters, long timeoutSeconds)
      Get values for a list of ratio counters from the given host
      This will only apply to the host which is monitored by current collector.
      static PDHSession open​(java.lang.String host)
      Deprecated.
      static PDHSession open​(java.lang.String host, java.lang.String username, java.lang.String password)
      open a PDH session with username or password provided
      • Methods inherited from class java.lang.Object

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

      • PDH

        public PDH()
    • Method Detail

      • open

        @Deprecated
        public static PDHSession open​(java.lang.String host)
        Deprecated.
        Open a PDH session, using host's property for user & password
        Parameters:
        host - - host to connect to
        Returns:
        a PDH session object representing the session for interaction This will only apply for the hosts monitored by current collector. use other static methods like get* instead.
      • open

        public static PDHSession open​(java.lang.String host,
                                      java.lang.String username,
                                      java.lang.String password)
        open a PDH session with username or password provided
        Parameters:
        host - PDH host url
        username - Auth username
        password - Auth password
        Returns:
        PDHSession object
      • getCounter

        public static java.lang.String getCounter​(java.lang.String host,
                                                  java.lang.String counter)
                                           throws java.io.IOException,
                                                  java.lang.InterruptedException,
                                                  java.util.concurrent.ExecutionException
        Get a single counter from the given host
        This will only apply to the host which is monitored by current collector.
        Parameters:
        host - - host to connect to
        counter - - counter to get
        Returns:
        - value of counter, in string format
        Throws:
        java.io.IOException
        java.lang.InterruptedException
        java.util.concurrent.ExecutionException
      • getCounter

        public static java.lang.String getCounter​(java.lang.String host,
                                                  java.lang.String counter,
                                                  long timeoutSeconds)
                                           throws java.io.IOException,
                                                  java.lang.InterruptedException,
                                                  java.util.concurrent.ExecutionException
        Get a single counter from the given host with timeout
        This will only apply to the host which is monitored by current collector.
        Parameters:
        host - PDH host url
        counter - Counter of pdh
        timeoutSeconds - Timeout(seconds)
        Returns:
        - value of counter, in string format
        Throws:
        java.io.IOException - If some other I/O error occurs
        java.lang.InterruptedException - If wait request interrupt
        java.util.concurrent.ExecutionException - If wait request execution failed
      • getCounters

        public static java.util.List<java.lang.String> getCounters​(java.lang.String host,
                                                                   java.util.List<java.lang.String> counters)
                                                            throws java.io.IOException,
                                                                   java.lang.InterruptedException,
                                                                   java.util.concurrent.ExecutionException
        Get values for a list of counters from the given host
        This will only apply to the host which is monitored by current collector.
        Parameters:
        host - - host to connect to
        counters - - counters to get
        Returns:
        - values of counters, in given order of counters parameters
        Throws:
        java.io.IOException
        java.lang.InterruptedException
        java.util.concurrent.ExecutionException
      • getCounters

        public static java.util.List<java.lang.String> getCounters​(java.lang.String host,
                                                                   java.util.List<java.lang.String> counters,
                                                                   long timeoutSeconds)
                                                            throws java.io.IOException,
                                                                   java.lang.InterruptedException,
                                                                   java.util.concurrent.ExecutionException
        Get values for a list of counters from the given host
        This will only apply to the host which is monitored by current collector.
        Parameters:
        host - - host to connect to
        counters - - counters to get
        timeoutSeconds - timeout (seconds)
        Returns:
        - values of counters, in given order of counters parameters
        Throws:
        java.io.IOException
        java.lang.InterruptedException
        java.util.concurrent.ExecutionException
      • getDiscover

        public static java.lang.String getDiscover​(java.lang.String host,
                                                   java.lang.String category)
                                            throws java.io.IOException,
                                                   java.lang.InterruptedException,
                                                   java.util.concurrent.ExecutionException
        Get a single counter from the given host
        This will only apply to the host which is monitored by current collector.
        Parameters:
        host - - host to connect to
        category - - category to get
        Returns:
        - value of counter, in string format
        Throws:
        java.io.IOException
        java.lang.InterruptedException
        java.util.concurrent.ExecutionException
      • getDiscover

        public static java.lang.String getDiscover​(java.lang.String host,
                                                   java.lang.String category,
                                                   long timeoutSeconds)
                                            throws java.io.IOException,
                                                   java.lang.InterruptedException,
                                                   java.util.concurrent.ExecutionException
        Get a single counter from the given host with timeout
        This will only apply to the host which is monitored by current collector.
        Parameters:
        host - PDH host url
        category - category of pdh
        timeoutSeconds - Timeout(seconds)
        Returns:
        - value of category, in string format
        Throws:
        java.io.IOException - If some other I/O error occurs
        java.lang.InterruptedException - If wait request interrupt
        java.util.concurrent.ExecutionException - If wait request execution failed
      • getEnum

        public static java.lang.String getEnum​(java.lang.String host,
                                               java.lang.String object)
                                        throws java.io.IOException,
                                               java.lang.InterruptedException,
                                               java.util.concurrent.ExecutionException
        Get a object from the given host
        This will only apply to the host which is monitored by current collector.
        Parameters:
        host - - host to connect to
        object - - object to get
        Returns:
        - value of object, in string format
        Throws:
        java.io.IOException
        java.lang.InterruptedException
        java.util.concurrent.ExecutionException
      • getEnum

        public static java.lang.String getEnum​(java.lang.String host,
                                               java.lang.String object,
                                               long timeoutSeconds)
                                        throws java.io.IOException,
                                               java.lang.InterruptedException,
                                               java.util.concurrent.ExecutionException
        Get a object from the given host with timeout
        This will only apply to the host which is monitored by current collector.
        Parameters:
        host - PDH host url
        object - object of pdh
        timeoutSeconds - Timeout(seconds)
        Returns:
        - value of object, in string format
        Throws:
        java.io.IOException - If some other I/O error occurs
        java.lang.InterruptedException - If wait request interrupt
        java.util.concurrent.ExecutionException - If wait request execution failed
      • getRatioCounter

        public static java.lang.String getRatioCounter​(java.lang.String host,
                                                       java.lang.String counter)
                                                throws java.io.IOException,
                                                       java.lang.InterruptedException,
                                                       java.util.concurrent.ExecutionException
        Get a single ratio counter from the given host
        This will only apply to the host which is monitored by current collector.
        Parameters:
        host - - host to connect to
        counter - - ratio counter to get
        Returns:
        - value of counter, in string format
        Throws:
        java.io.IOException
        java.lang.InterruptedException
        java.util.concurrent.ExecutionException
      • getRatioCounter

        public static java.lang.String getRatioCounter​(java.lang.String host,
                                                       java.lang.String counter,
                                                       long timeoutSeconds)
                                                throws java.io.IOException,
                                                       java.lang.InterruptedException,
                                                       java.util.concurrent.ExecutionException
        Get a single ratio counter from the given host
        This will only apply to the host which is monitored by current collector.
        Parameters:
        host - - host to connect to
        counter - - ratio counter to get
        timeoutSeconds - timeout (seconds)
        Returns:
        - value of counter, in string format
        Throws:
        java.io.IOException
        java.lang.InterruptedException
        java.util.concurrent.ExecutionException
      • getRatioCounters

        public static java.util.List<java.lang.String> getRatioCounters​(java.lang.String host,
                                                                        java.util.List<java.lang.String> counters)
                                                                 throws java.io.IOException,
                                                                        java.lang.InterruptedException,
                                                                        java.util.concurrent.ExecutionException
        Get values for a list of ratio counters from the given host
        This will only apply to the host which is monitored by current collector.
        Parameters:
        host - - host to connect to
        counters - - ratio counters to get
        Returns:
        - values of ratio counters, in given order of ratio counters parameters
        Throws:
        java.io.IOException
        java.lang.InterruptedException
        java.util.concurrent.ExecutionException
      • getRatioCounters

        public static java.util.List<java.lang.String> getRatioCounters​(java.lang.String host,
                                                                        java.util.List<java.lang.String> counters,
                                                                        long timeoutSeconds)
                                                                 throws java.io.IOException,
                                                                        java.lang.InterruptedException,
                                                                        java.util.concurrent.ExecutionException
        Get values for a list of ratio counters from the given host
        This will only apply to the host which is monitored by current collector.
        Parameters:
        host - - host to connect to
        counters - - ratio counters to get
        timeoutSeconds - timeout (seconds)
        Returns:
        - values of ratio counters, in given order of ratio counters parameters
        Throws:
        java.io.IOException
        java.lang.InterruptedException
        java.util.concurrent.ExecutionException