Exemple #1
0
  /**
   * {@inheritDoc}
   *
   * <p>Responsible for performing all necessary initialization for the specified interface in
   * preparation for data collection.
   */
  @Override
  public void initialize(CollectionAgent agent, Map<String, Object> parameters) {
    InetAddress ipAddr = agent.getAddress();
    int nodeID = agent.getNodeId();

    // Retrieve the name of the JMX data collector
    String collectionName = ParameterMap.getKeyedString(parameters, "collection", serviceName);

    final String hostAddress = InetAddressUtils.str(ipAddr);
    LogUtils.debugf(
        this, "initialize: InetAddress=%s, collectionName=%s", hostAddress, collectionName);

    JMXNodeInfo nodeInfo = new JMXNodeInfo(nodeID);
    LogUtils.debugf(this, "nodeInfo: %s %d %s", hostAddress, nodeID, agent);

    /*
     * Retrieve list of MBean objects to be collected from the
     * remote agent which are to be stored in the node-level RRD file.
     * These objects pertain to the node itself not any individual
     * interfaces.
     */
    Map<String, List<Attrib>> attrMap =
        JMXDataCollectionConfigFactory.getInstance()
            .getAttributeMap(collectionName, serviceName, hostAddress);
    nodeInfo.setAttributeMap(attrMap);

    Map<String, JMXDataSource> dsList = buildDataSourceList(collectionName, attrMap);
    nodeInfo.setDsMap(dsList);
    nodeInfo.setMBeans(JMXDataCollectionConfigFactory.getInstance().getMBeanInfo(collectionName));

    // Add the JMXNodeInfo object as an attribute of the interface
    agent.setAttribute(NODE_INFO_KEY, nodeInfo);
    agent.setAttribute("collectionName", collectionName);
  }