Is it possible to create an RHQ plugin that collects historic measurements from files?

68 views Asked by At

I'm trying to create an RHQ plugin to gather some measurements. It seems relativity easy to create a plugin that return a value for the present moment. However, I need to collect these measurements from files. These files are created on a schedule, for example one per hour, but they contain much finer measurements, for example a measurement for every minute. The file may look something like below:

18:00 20
18:01 42
18:02 39
...
18:58 12
18:59 15

Is it possible to create a RHQ plugin that can return many values with timestamps for a measurement?

2

There are 2 answers

0
Heiko Rupp On BEST ANSWER

I think you can within org.rhq.core.pluginapi.measurement.MeasurementFacet#getValues return as many values as you want within the MeasurementReport.

So basically open the file, seek to the last known position (if the file is always appended to), read from there and for each line you go

MeasurementData data = new MeasurementDataNumeric(timeInFile, request, valueFromFile);
report.add(data);

Of course alerting on this (historical) data is sort of questionable, as if you only read the file one hour later, the alert can not be retroactively fired at the time the bad value happened :->

0
Rahul Sharma On

Yes it is surely possible .

@Override
public void getValues(MeasurementReport report,  Set<MeasurementScheduleRequest> metrics) throws Exception {     
    for (MeasurementScheduleRequest request : metrics) {
        Double result = SomeReadUtilClass.readValueFromFile();
        MeasurementData data =  new MeasurementDataNumeric(request, result)
        report.addData(data );
    }
}

SomeReadUtilClass is a utility class to read the file and readValueFromFile is the function, you can write you login to read the value from file.

result is the Double variable that is more important, this result value you can calculate from database or read file. And then this result value you have to provide to MeasurementDataNumeric function MeasurementDataNumeric(request, result));