mysqlfunctionparametersjasper-reportsicinga

MySQL function with variable parameter


I am creating a monitoring report with iReport from Jaspersoft and data from icinga. In ireport I have to enter the query to get the data I need. Now, I want to get the name (of a monitored object) and the corresponding availability from that service. For this, icinga provides a function which takes the object_id, a start date and an end date as parameters. Such as this:

select icinga_availability(203, '2017-09-01 00:00:00','2017-09-30 23:59:59'), name1 from icinga_objects where object_id = '203';

For iReport I need to get all needed objects in one single query. For example I need object number 131, 258, 101, 465.

Is it possible to pass a variable/wildcard or multiple object_ids into the function? I couldn't manage it yet.

Thank you for your help!


Solution

  • iReport isn't officialy supported anymore, so it would be the best to switch to Jaspersoft Studio.

    So I can only tell how it works in JSS, but it should work in iReport too:

    select icinga_availability( $P{obejct_id} , '2017-09-01 00:00:00','2017-09-30 23:59:59'), name1 from icinga_objects where object_id = to_char( $P{obejct_id} );
    

    Using an Integer-Parameter:

    <parameter name="obejct_id" class="java.lang.Integer"/>
    

    So when running the report, you can enter the object_id you want to view.