Review Board 1.7.22


Ganglia metrics plugin should filter MBean name

Review Request #6060 - Created July 20, 2012 and submitted

Mubarak Seyed
trunk
FLUME-1386
Reviewers
Flume
Flume
Ganglia metrics shows MBean name + metric name and it appears from ganglia UI that graph is not getting rendered properly. The fix is to filter the MBean name and prepend "flume" for ganglia context. Thanks.
Yes.
trunk/flume-ng-core/src/main/java/org/apache/flume/instrumentation/GangliaServer.java
Revision 1363666 New Change
[20] 90 lines
[+20] [+] public class GangliaServer implements MonitorService {
91
  private String hostname;
91
  private String hostname;
92
  public final String CONF_POLL_FREQUENCY = "pollFrequency";
92
  public final String CONF_POLL_FREQUENCY = "pollFrequency";
93
  public final int DEFAULT_POLL_FREQUENCY = 60;
93
  public final int DEFAULT_POLL_FREQUENCY = 60;
94
  public final String CONF_HOSTS = "hosts";
94
  public final String CONF_HOSTS = "hosts";
95
  public final String CONF_ISGANGLIA3 = "isGanglia3";
95
  public final String CONF_ISGANGLIA3 = "isGanglia3";

    
   
96
  private static final String GANGLIA_CONTEXT = "flume.";
96

    
   
97

   
97
  /**
98
  /**
98
   *
99
   *
99
   * @param hosts List of hosts to send the metrics to. All of them have to be
100
   * @param hosts List of hosts to send the metrics to. All of them have to be
100
   * running the version of ganglia specified by the configuration.
101
   * running the version of ganglia specified by the configuration.
[+20] [20] 247 lines
[+20] [+] public void run() {
348
          for (int i = 0; i < strAtts.length; i++) {
349
          for (int i = 0; i < strAtts.length; i++) {
349
            strAtts[i] = attrs[i].getName();
350
            strAtts[i] = attrs[i].getName();
350
          }
351
          }
351
          AttributeList attrList = mbeanServer.getAttributes(
352
          AttributeList attrList = mbeanServer.getAttributes(
352
                  obj.getObjectName(), strAtts);
353
                  obj.getObjectName(), strAtts);

    
   
354
          String component = obj.getObjectName().toString().substring(

    
   
355
              obj.getObjectName().toString().indexOf('=') + 1);
353
          for (Object attr : attrList) {
356
          for (Object attr : attrList) {
354
            Attribute localAttr = (Attribute) attr;
357
            Attribute localAttr = (Attribute) attr;
355
            if (isGanglia3) {
358
            if (isGanglia3) {
356
              server.createGangliaMessage(obj.getObjectName() + "."
359
              server.createGangliaMessage(GANGLIA_CONTEXT + component + "."
357
                      + localAttr.getName(),
360
                      + localAttr.getName(),
358
                      localAttr.getValue().toString());
361
                      localAttr.getValue().toString());
359
            } else {
362
            } else {
360
              server.createGangliaMessage31(obj.getObjectName() + "."
363
              server.createGangliaMessage31(GANGLIA_CONTEXT + component + "."
361
                      + localAttr.getName(),
364
                      + localAttr.getName(),
362
                      localAttr.getValue().toString());
365
                      localAttr.getValue().toString());
363
            }
366
            }
364
            server.sendToGangliaNodes();
367
            server.sendToGangliaNodes();
365
          }
368
          }
366
        } catch (Exception ex) {
369
        } catch (Exception ex) {
367
          logger.error("Error getting mbean attributes", ex);
370
          logger.error("Error getting mbean attributes", ex);
368
        }
371
        }
369
      }
372
      }
370
    }
373
    }
371
  }
374
  }
372
}
375
}
  1. trunk/flume-ng-core/src/main/java/org/apache/flume/instrumentation/GangliaServer.java: Loading...