Query Regarding Saving Availability Reports in CSV Format

Hi

We would like to understand the process for saving the availability report in CSV format in Checkmk and storing the generated CSV file on disk automatically.

Could you please suggest if this can be achieved through an API or any other supported method/process in Checkmk?

1 Like

You can apply all the needed parameters and use the URL to get the data on demand. You can also use the URL the export the data using CSV format and query whenever needed.

Thank you for the reply.

However, I am not fully understanding how this can be achieved. Could you please provide more detailed steps or an example process for implementing this?

1 Like

Generate the report applying all the needed computation parameters needed, then use the URL to regenerate it and change the view:

Then you can get the URL:

https://CHECKMKURL/SITENAME/check_mk/view.py?filled_in=filter&mode=availability&output_format=csv_export&view_name=VIEWNAME#

Thank you for the reply.

When we access this URL using lynx on the Linux machine, it prompts for a username and password. What can be done to handle this?

1 Like

You need to add the following header for authentication

Authorization: Bearer $USERNAME $PASSWORD

You can create an automation account with minimal permissions to be used in that.

When we call the URl with curl on linux , we get the output as below where percentage value is showing as n/a;

curl -k -u automation_user:password “https://url/site/check_mk/view.py?limit=none&mode=availability&output_format=csv_export&view_name=availability_view” -o /opt/checkmk/reports/availability.csv

Output

host1;Process httpd-2465;n/a;n/a;n/a;n/a;n/a;n/a;n/a;n/a
host1;Process tomcat_tc9j11LB2;n/a;n/a;n/a;n/a;n/a;n/a;n/a;n/a

When we call the URl with curl on linux , we get the output as below where percentage value is showing as n/a;the result is not as we view when we export the file from UI.

curl -k -u automation_user:password “https://url/site/check_mk/view.py?limit=none&mode=availability&output_format=csv_export&view_name=availability_view” -o /opt/checkmk/reports/availability.csv

Output

host1;Process httpd-2465;n/a;n/a;n/a;n/a;n/a;n/a;n/a;n/a
host1;Process tomcat_tc9j11LB2;n/a;n/a;n/a;n/a;n/a;n/a;n/a;n/a

Try accessing the user in the Web-browser using the same url and user.

When I use the same URL from browser with the username and password, I am able to download the file. However, it is not working with the Linux command

Use this instead:

curl --noproxy ‘*’ -G -k -H “Authorization: Bearer automation_user password” “https://url/site/check_mk/view.py?limit=none&mode=availability&output_format=csv_export&view_name=availability_view” -o /opt/checkmk/reports/availability.csv

Thank you for the reply.

The command is working, but when executed from the Linux command line, it shows all availability values and the summary as 100%. However, when we check the availability report through the browser, the report shows different values (for example, the summary shows 99.12%).

It appears that the availability calculation is not being reflected correctly when the report is called from the Linux command line.

1 Like

Perfect, you now need to adjust the computation parameters according to your needs. You can do that using any web browser to collect all the parameters available in the URL. Each parameters is going to modify the URL adding or modifying parameters.

1 Like

thank you for the reply.

That’s really helps

How can we change dynamically the Time Range using the curl URL? Currently, we are using the custom-> view , and the Time Range can only be changed through the “Change Display Options” section in the availability report.

1 Like

Each time range has a number, most of them are related to fixed periods while others allow the inclusion of additional parameters. After doing a change in the parameters please check the generated url for differences.

thank you for reply, could you please provide more details for the above explanation?

1 Like

Sure.

Using this URL as starting point:

FQDN/checkmk/check_mk/view.py?host=HOST&mode=availability&site=checkmk&view_name=hoststatus

Then I go to Display Options:

Then I modify from last month to Today and Apply:

The URL will have all parameters and will look like this:
FQDN/SITENAME/check_mk/check_mk/view.py?_csrf_token=4d6c10ec-78b3-4388-8e94-94133ea23048&filled_in=avoptions_display&_transid=1778590242%2F3vXMqhD8fus&avoptions=set&apply=Apply&avo_rangespec_sel=5&avo_rangespec_16_days=0&avo_rangespec_16_hours=0&avo_rangespec_16_minutes=0&avo_rangespec_16_seconds=0&avo_rangespec_17_0_year=2026&avo_rangespec_17_0_month=5&avo_rangespec_17_0_day=12&avo_rangespec_17_1_year=2026&avo_rangespec_17_1_month=5&avo_rangespec_17_1_day=12&avo_labelling=1&avo_av_levels_value_0=99.0&avo_av_levels_value_1=95.0&avo_outage_statistics_0=1&avo_outage_statistics_1=1&avo_timeformat_0=c4e12aa4e018b4d2a2942a7bc7f250c5dd49b55e361c8843a9c6612393c3bad5&avo_timeformat_1=a4223a433eb3597d6ccb9fcd7a67b600fdf8d303965ee6ebdb92b86f324d0045&avo_timeformat_2=c79ce24dccedc25c4bb147dc9fa76a5ff89fd5d76aada1c28494c1e63c63f228&avo_grouping=dc937b59892604f5a86ac96936cd7ff09e25f18ae6b758e8014a24c7fa039e91&avo_dateformat=881e08f81c4190714d51ec7b5d16992a0cb6b6012149a98e7c7356b901952cbf&avo_summary=0e04b5ba903e6b68f52e38e4ca1c40ce2a9fc04e1ff36133e35499378ac4b7f7&host=HOST&mode=availability&site=checkmk&view_name=hoststatus

With that you can find which parameters are being used and apply the conditions that satisfy what you need. Unfortunately I was not able to find documentation or API details to collect this details in a better way.

An easier approach