The OP5 Monitor HTTP API provides access to report data, delivering the "E" in the ETL model for customers interested in performing their own report analysis in a data warehouse solution. In some cases, custom analysis is not required and in those cases the data in the standard OP5 Monitor reports often provides the necessary information. OP5 Monitor does not provide an API for getting existing reports so this solution is not guaranteed to work in the future, but they can be fetched over HTTP with a little work. To do this, two steps are required: authentication and setting parameters.
Note: Authenticating using GET parameters can be a security risk, since the username and password will be part of the URL and therefore can be exposed in various places such as the address bar of the web browser, web server log files and saved bookmarks.
- Create the file /opt/monitor/op5/ninja/application/config/custom/auth.php with the following contents (make sure you keep your old settings if you have customized other authentication settings)
- Add the following:
<?php defined('SYSPATH') OR die('No direct access allowed.');
* Setting this to TRUE will allow you to access any page by
* appending ?username=<username>&password=<password> to the URL.
* Warning: this is insecure! Do know what you're doing!
$config['use_get_auth'] = true;
You can now add the username and password as GET parameters to any ninja URL and be logged in automatically. Example:
Note that different authentication types may need to be identified. Active Directory users can be marked using the $Default parameter after the username but before the password. Example:
Set up the report you want to generate by using the op5 Monitor web interface. Once the report is generated, click the "Direct link" button and copy the URL. You can now use the URL from curl or another tool. Append &output_format=csv and then append the authentication mentioned above.
As this is not an API, the parameter names and meaning may change between releases so make sure you verify on each upgrade.
It is likely that you'll want to modify the time parameters in the URL when generating the report, to reflect the time when the report is generated:
|parameter name||example value||description|
|start_time||1385049008||Unix timestamp for the start time of the report. Will be ignored, unless report_period is "custom".|
|end_time||1385653808||Unix timestamp for the end time of the report. Will be ignored, unless report_period is "custom".|
Getting the data this way would put load on the Monitor server every time a report is generated, so you will need to take performance into consideration in order to not affect the monitoring. If the number of concurrent users generating reports is small, this should not be a problem.