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

    xiaoxiao2025-11-01  0

                 为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

       问题解决

                

    转载请注明原文地址: https://ju.6miu.com/read-1303722.html
    最新回复(0)