Skip to Content
0
Former Member
Dec 01, 2011 at 06:13 PM

Server Start time from IMetrics

55 Views

Can you tell me how to parse back the time value i get form the metrics interface from a server?

I can see we have a Enum to tell me it is Date / Time, but the value i get back is a decimal:

sample output:

Metric Name:

ISPROP_GEN_STARTTIME

Metric Value:

40877.1362435995

it seems there should be some easy way to cast this into Date / Time, since it is displayed that way in the CMC.

IInfoObjects objects = infoStore.query("select * from CI_SYSTEMOBJECTS where SI_KIND = 'Server' ");

for (@SuppressWarnings("rawtypes")

Iterator iterator = objects.iterator(); iterator.hasNext();)

{

try {

IServer server = (IServer) iterator.next();

String metricDescriptionsQuery = "SELECT * FROM CI_SYSTEMOBJECTS WHERE SI_KIND='MetricDescriptions'";

//get the base collection

IServerMetrics baseMetrics = server.getMetrics();

IMetricDescriptions metricDescriptions;

metricDescriptions = (IMetricDescriptions) infoStore.query(metricDescriptionsQuery).get(0);

//get the set of metrics that has the server start time

IMetrics subMetrics = baseMetrics.getMetrics("ISGeneralAdmin");

Iterator serviceMetricsIter = subMetrics.iterator();

while(serviceMetricsIter.hasNext()) {

IMetric metric = (IMetric) serviceMetricsIter.next();

String metricName = metric.getName().trim();

System.out.println(metricName + ";");

// Get the localized metric name.

IMLDescriptions descriptions = metricDescriptions.getMetricDescriptions("ISGeneralAdmin");

IPropertyRenderTemplate propertyRenderTemplate = descriptions.getPropertyRenderTemplate(metricName);

if(metricName.contains("ISPROP_GEN_STARTTIME") )

{

System.out.println(metric.getValue().toString());

ValueFormat metricValFormat = propertyRenderTemplate.getValueFormat();

System.out.println(metricValFormat.toString());

}