Automate CSV for Availability Report

I’m generating report via curl for automation on the report(raw version)
i want to see the last 30 days like in the web console.
when i download via the “export to CSV” is see the last 30 days ok
but when i’m using curl im not getting the last 30 days, instead i see something like last 24 hours
how can i change that in the curl request?

my request-
curl "https://example.com/site/check_mk/view.py?host_last_check_from=&host_last_check_until=&host_last_state_change_from=&host_last_state_change_until=&mode=availability&optservice_group=Availability-Report-test&output_format=json&selection=43dyc33-6022-4563-bc3b-c876234698&servicegroup=Availability-Report-test&svc_last_check_from=&svc_last_check_until=&svc_last_state_change_from=&svc_last_state_change_until=&view_name=servicegroup&_username=demo&_secret=xxx&_login=1" -o files/test.html

Hi,
a valid URL could look like this:

curl “http://example.com/site/check_mk/view.py?apply=Apply&avo_dateformat=881e08f81c4190714d51ec7b5d16992a0cb6b6012149a98e7c7356b901952cbf&avo_grouping=dc937b59892604f5a86ac96936cd7ff09e25f18ae6b758e8014a24c7fa039e91&avo_outage_statistics_0=1&avo_outage_statistics_1=1&avo_rangespec_sel=13&avo_summary=0e04b5ba903e6b68f52e38e4ca1c40ce2a9fc04e1ff36133e35499378ac4b7f7&avo_timeformat_0=c4e12aa4e018b4d2a2942a7bc7f250c5dd49b55e361c8843a9c6612393c3bad5&avo_timeformat_1=a4223a433eb3597d6ccb9fcd7a67b600fdf8d303965ee6ebdb92b86f324d0045&avo_timeformat_2=c79ce24dccedc25c4bb147dc9fa76a5ff89fd5d76aada1c28494c1e63c63f228&avoptions=set&filled_in=avoptions&mode=availability&output_format=csv_export&view_name=allhosts &_username=YOURAUTOMATIONUSER&_secret=YOURSECRET&avo_rangespec_13_days=30&avo_rangespec_13_hours=0&avo_rangespec_13_minutes=0&avo_rangespec_13_seconds=0”

The important parameters in CMK 1.6 are:

avo_rangespec_sel=13 
avo_rangespec_days=30

They changed in CMK 2.0:

avo_rangespec_sel=16
avo_rangespec_days=30

Karl

Thanks Karl this helps a lot, looks like my url call was wrong

Hi Alexmoo,

in addition to Karl, you can run the following python script:

#!/usr/bin/python

import requests
import json

user = ‘automation’
passwd = ‘b139aa87-3338-4c27-92ca-09ae95307670’
access_addr = ‘https://klappanas/nagnis_master/check_mk/view.py
params_get = (
(‘filled_in’,‘avoptions’),
(‘avoptions’,‘set’),
(‘avo_rangespec_sel’,‘7’),
(‘avo_timeformat_0’,‘2bd0935ed2d327be03a6d0f6cf308b381f292aaaa865903e7de65d58d7b2b16e’),
(‘avo_timeformat_1’,‘a4223a433eb3597d6ccb9fcd7a67b600fdf8d303965ee6ebdb92b86f324d0045’),
(‘avo_timeformat_2’,‘aa4e09d5a3f4d3dc5766fe8fbdc3a8d7e25cc3bca0286b92a70eca486a0f224b’),
(‘avo_grouping’,‘dc937b59892604f5a86ac96936cd7ff09e25f18ae6b758e8014a24c7fa039e91’),
(‘avo_dateformat’,‘881e08f81c4190714d51ec7b5d16992a0cb6b6012149a98e7c7356b901952cbf’),
(‘avo_summary’,‘0e04b5ba903e6b68f52e38e4ca1c40ce2a9fc04e1ff36133e35499378ac4b7f7’),
(‘avo_downtimes_p_include’,‘001e54df574c79b0d62ccd56ae3dda02fa5dbd4c420b6f2cc348d8dc2c4fe310’),
(‘avo_state_grouping_p_warn’,‘f9353e8961734c2e577ccc05c2af08e74ac004732eff3ece623d1707220a23b3’),
(‘avo_state_grouping_p_unknown’,‘551b29bdf877b9cb40b917f9879125e93a61d9d82f143793115ea4b1139a95ba’),
(‘avo_state_grouping_p_host_down’,‘ec0e9274a68050302cba67cc946f565d920579c18274515c276f1a22de53922f’),
(‘avo_av_filter_outages_p_warn’,‘0.0’),
(‘avo_av_filter_outages_p_crit’,‘0.0’),
(‘avo_av_filter_outages_p_non-ok’,‘2.0’),
(‘avo_host_state_grouping_p_unreach’,‘14055e2def9ff2e2afd9cee73209ff5c895c7aee7387a1d42962c01eba828eb8’),
(‘avo_service_period’,‘25b536873c92c841b2f310dce7c53d5ff988763e14d3309c3d00a66c5c61f819’),
(‘avo_notification_period’,‘a7e1d9dbe9e8322f03d4ab84fbac622551bf64156c7ee6d403601c92a9fa0670’),
(‘avo_short_intervals’,‘0’),
(‘avo_timelimit_days’,‘0’),
(‘avo_timelimit_hours’,‘0’),
(‘avo_timelimit_minutes’,‘0’),
(‘avo_timelimit_seconds’,‘30’),
(‘avo_logrow_limit’,‘0’),
(‘apply’,‘Apply’),
(‘view_name’,‘allhosts’),
(‘mode’,‘availability’),
(‘_username’, user),
(‘_secret’, passwd),
(‘output_format’,‘csv_export’)

)

r = requests.post(access_addr, params=params_get, verify=‘/home/anastasios/ssl_CERT/ca-chain.cert.pem’)

#print(r.content)
#print(“headers: %s” % r.headers)
#print(“status_code: %s” % r.status_code)
print(r.text)
#print(r.url)

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed. Contact @fayepal if you think this should be re-opened.