public void getValue(StringBuffer res) throws Exception { if (dataProvider.isBytesValue()) { dataProvider.getValue(res, dividingFactor); } else { dataProvider.getValue(res); } }
public JMXMetric(MetricParams params, JMXConnectorHelper jmxHelper) { super(null); String url = "localhost:4711"; String user = ""; String pwd = ""; for (int i = 0; i < params.params.length; i++) { if (params.params[i].startsWith("url=")) { url = MetricParams.getParamValue(params.params[i]); } else if (params.params[i].startsWith("user="******"password="******"'url' parameter required for metric type 'jmx'"); } MBeanServerConnection mBeanServerConn = jmxHelper.getServerConnection(url, user, pwd); try { dataProvider = AbstractJMXDataProvider.getProvider(mBeanServerConn, params.type); } catch (Exception ex) { log.debug("Failed to get MX Bean data provider", ex); throw new RuntimeException("Failed to get MX Bean data provider", ex); } dividingFactor = getUnitDividingFactor(params.getUnit()); }