为flume添加ganglia监控,启动后出现如下错误: 

            


              查看源代码发现

protected void createGangliaMessage31(String name, String value) {
    logger.debug("Sending ganglia 3.1 formatted message: "
            + name + ": " + value);
    xdr_int(128); // metric_id = metadata_msg
    xdr_string(hostname); // hostname            //254行
    xdr_string(name); // metric name
    xdr_int(0); // spoof = False
    String type = "string";
    try {
      Float.parseFloat(value);
      type = "float";
    } catch (NumberFormatException ex) {
      // The param is a string, and so leave the type as is.
    }
    xdr_string(type); // metric type
    xdr_string(name); // metric name
    xdr_string(DEFAULT_UNITS); // units
    xdr_int(DEFAULT_SLOPE); // slope
    xdr_int(DEFAULT_TMAX); // tmax, the maximum time between metrics
    xdr_int(DEFAULT_DMAX); // dmax, the maximum data value
    xdr_int(1); /*Num of the entries in extra_value field for Ganglia 3.1.x*/
    xdr_string("GROUP"); /*Group attribute*/
    xdr_string("flume"); /*Group value*/

    this.sendToGangliaNodes();

    // Now we send out a message with the actual value.
    // Technically, we only need to send out the metadata message once for
    // each metric, but I don't want to have to record which metrics we did and
    // did not send.
    xdr_int(133); // we are sending a string value
    xdr_string(hostname); // hostName
    xdr_string(name); // metric name
    xdr_int(0); // spoof = False
    xdr_string("%s"); // format field
    xdr_string(value); // metric value
  }

找到hostname赋值的代码
      hostname = InetAddress.getLocalHost().getHostName();

      也就是说没有能获取到hostname

     http://stackoverflow.com/questions/1881546/inetaddress-getlocalhost-throws-unknownhostexception

    根据这里的方法,为host添加<your-machine-ip> <your-machine-name> localhost

   如:192.168.0.1 my localhost

   问题解决

            

Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐