flume添加ganglia监控时空指针的错误解决方法

             为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

   问题解决

            

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值