protected override object GetAttributeValue(string attribute) { // Find MBean object. var objectNames = MBeanClient.QueryObjects(JmxDomain, Path); // Validated MBean object was found. if (objectNames.Count == 0) { throw new ArgumentException("Unable to query MBean."); } object result; var obj = objectNames[0]; // The Java Health counters may be nested as CompositeData objects, so we need to be prepared to handle this. if (attribute.Contains(@"\")) { var pathSegments = attribute.Split('\\'); var parent = pathSegments[0]; var child = pathSegments[1]; var compositeData = MBeanClient.GetAttributeValue(obj, parent) as CompositeData; result = compositeData.get(child); } else { result = MBeanClient.GetAttributeValue(obj, attribute); } // Wonky parsing to convert result from Java lang object into C# float. return(float.Parse(result.ToString())); }
protected override object GetAttributeValue(string attribute) { // Find MBean object. ICollection <ObjectName> objectNames = MBeanClient.QueryObjects(JmxDomain, Path); // Validated MBean object was found. if (objectNames.Count == 0) { throw new ArgumentException("Unable to query MBean."); } ObjectName obj = objectNames.First(); object result = MBeanClient.GetAttributeValue(obj, attribute); // Wonky parsing to convert result from Java lang object into C# float. return(float.Parse(result.ToString())); }