Class ActiveAgent

  • All Implemented Interfaces:
    java.lang.Runnable

    public class ActiveAgent
    extends ZabbixClient
    implements java.lang.Runnable
    A Zabbix server client that implements the active checks protocol. The client first asks the server for a set of metrics the latter is interested in and then periodically send their fresh values to the server. The set of metrics itself can be renewed periodically.

    One of the advantages of the active check model is that it can work if the agent is behind a firewall and thus can not be reached from the outside network.

    The client uses a (possibly inactive) instance of a AgentServer to retrieve the metric value information. The retrieving process of each metric value is handled asynchronously using a thread pool.

    Author:
    Paul Wolneykien
    • Constructor Summary

      Constructors 
      Constructor Description
      ActiveAgent​(AgentServer agentServer, java.util.concurrent.ThreadPoolExecutor pool, long refreshPeriod)
      Creates the active agent instance with the specified parameters.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.concurrent.ThreadPoolExecutor getPool()
      Returns the thread pool that is used for the asynchronous metric value retrieval.
      long getRefreshPeriod()
      Returns the refresh period of the active check list.
      void run()
      Starts the active check loop.
      void setPool​(java.util.concurrent.ThreadPoolExecutor pool)
      Sets the thread pool for the asynchronous metric value retrieval.
      void setRefreshPeriod​(long refreshPeriod)
      Sets the refresh period of the active check list.
      • Methods inherited from class java.lang.Object

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

      • ActiveAgent

        public ActiveAgent​(AgentServer agentServer,
                           java.util.concurrent.ThreadPoolExecutor pool,
                           long refreshPeriod)
        Creates the active agent instance with the specified parameters.
        Parameters:
        agentServer - the metric value retrieval service
        pool - the thread pool for asynchronous value retrieval
        refreshPeriod - the active check set refresh period in milliseconds
    • Method Detail

      • run

        public void run()
        Starts the active check loop. First the list of monitored metrics is requested from the server. Later the list is updated in accordance with the refreshPeriod parameter. All of the active metric elements are placed in the queue in the order of their expiration. Every time the refreshPeriod of an entry is passed the new value for that entry is requested asynchronously using the composed MetricRequest task object. The task configured in such a way that the updated entry is placed to the ResponseQueue table. By the placing the expiration date of the entry is reset to a new value causing the entry to stay in the queue up to its refreshPeriod before its value is sent to the server. After that the entry is placed back to the active check list.

        When the active check list itself expires the response queue process is signaled to terminate after sending the enqueued data to the server. The up to date set of active checks is requested from the server and a new delay and response queues instances are created. Thus the out of date entries in the previous response queue is not returned back to the new active check list.

        Specified by:
        run in interface java.lang.Runnable
      • setRefreshPeriod

        public void setRefreshPeriod​(long refreshPeriod)
        Sets the refresh period of the active check list.
        Parameters:
        refreshPeriod - the refresh period value in milliseconds
        See Also:
        ActiveMetricTable.setRefreshPeriod(long)
      • getRefreshPeriod

        public long getRefreshPeriod()
        Returns the refresh period of the active check list.
        Returns:
        the refresh period value in milliseconds
        See Also:
        ActiveMetricTable.getRefreshPeriod()
      • setPool

        public void setPool​(java.util.concurrent.ThreadPoolExecutor pool)
        Sets the thread pool for the asynchronous metric value retrieval.
        Parameters:
        pool - the thread pool executor service
      • getPool

        public java.util.concurrent.ThreadPoolExecutor getPool()
        Returns the thread pool that is used for the asynchronous metric value retrieval.
        Returns:
        the thread pool executor service