Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

-> With this example you will receive all perfdata for a specific service/host. You can use livestatus for that


Query via WEB-API

Warning

With Checkmk 2.1, announced by Werk #13640, the Web API was deprecated. This release now (Checkmk 2.2) removes the Web API.

We recommend migrating all existing scripts that use the Web API to the REST API.


Expand

Custom graph

Code Block
languagebash
root@klappanas:~# curl -k "https://klappanas/daily/check_mk/webapi.py?action=get_graph&_username=automation&_secret=ROQAKYYIDYDOELRRLVVH&request_format=python&output_format=python" -d 'request={"specification":["custom","custom_graph_1"],"data_range":{"time_range":[1615627389,1616062956]}}'

{'result_code': 0, 'result': {'start_time': 1615626000, 'end_time': 1616063400, 'step': 1800, 'curves': [{'line_type': 'area', 'color': '#00b2ff', 'title': 'Service Costs per Day', 'rrddata': [None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None]}]}}

-> With example you can query the metrics of a custom graph in Checkmk


Forecast graph

Code Block
languagebash
curl -k "https://klappanas/daily/check_mk/webapi.py?action=get_graph&_username=automation&_secret=ROQAKYYIDYDOELRRLVVH&request_format=python&output_format=python" -d 'request={"specification":["forecast","forecast_graph_4"],"data_range":{"time_range":[1616062956,1616513102]}}'

{'result_code': 0, 'result': {'start_time': 1616504400, 'end_time': 1616527800, 'step': 1800, 'curves': [{'line_type': 'area', 'color': '#FFFFFF', 'title': 'CPU utilization - lower edge', 'rrddata': [33.345051190851265, 37.67683226938787, 44.50125333428577, 53.2724501059588, 60.44537606761632, 66.75387999685792, 72.64393851155472, 78.29311232060269, 83.75780489204897, 89.06739515972093, 94.1829539622409, 99.15563480780335, 104.09381440605844]}, {'line_type': 'stacked', 'color': '#F4E750', 'title': 'CPU utilization - confidence interval', 'rrddata': [11.100249458703228, 10.146064241405181, 10.102262795192633, 11.3949147901306, 16.27542796258677, 22.884785199874802, 30.331033266252426, 38.25905074392767, 46.55603069680629, 55.163215257233624, 64.15846274796492, 73.43946615261119, 82.78947205187224]}, {'line_type': 'line', 'color': '#0000FF', 'title': 'CPU utilization - original', 'rrddata': [42.2174, 40.4999, 47.7736, 60.8701, None, None, None, None, None, None, None, None, None]}, {'line_type': 'line', 'color': '#FF0000', 'title': 'CPU utilization - fit & forecast', 'rrddata': [38.89517592020288, 42.749864390090465, 49.552384731882086, 58.969907501024096, 68.58309004890971, 78.19627259679532, 87.80945514468094, 97.42263769256652, 107.03582024045211, 116.64900278833774, 126.26218533622335, 135.87536788410895, 145.48855043199455]}]}}

-> With example you can query the metrics of a forecast graph in Checkmk


Builtin graph

Code Block
languagebash
root@klappanas:~# curl -k "https://klappanas/daily/check_mk/webapi.py?action=get_graph&_username=automation&_secret=ROQAKYYIDYDOELRRLVVH&request_format=python&output_format=python" -d 'request={"specification":["template",{"service_description":"Filesystem /","site":"daily","graph_index":0,"host_name":"localhost2"}],"data_range":{"time_range":[1615627389, 1616062956]}}'
{'result_code': 0, 'result': {'start_time': 1615626000, 'end_time': 1616063400, 'step': 1800, 'curves': [{'line_type': 'area', 'color': '#00ffc6', 'title': 'Used filesystem space', 'rrddata': [None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None]}, {'line_type': 'stack', 'color': '#e3fff9', 'title': 'Free space', 'rrddata': [None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None]}, {'line_type': 'line', 'color': '#006040', 'title': 'Filesystem size', 'rrddata': [None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None]}]}}root@klappanas:~# 

-> With example you can query the metrics of a builtin graph in Checkmk. You will  receive the data for all lines of a specific line.



RRDcached

If you want the values unfiltered, you can access these from the rrd journal.log directly:

Code Block
languagebash
OMD[daily]:~/var/rrdcached$ ls -ltr
total 8744
-rw-r----- 1 daily daily 2435087 Mar 23 15:45 rrd.journal.1616503549.911643
-rw-r----- 1 daily daily 1720320 Mar 23 17:07 rrd.journal.1616510749.911407
-rw-r--r-- 1 daily daily 2456557 Mar 24 09:13 rrd.journal.1616566388.199299
-rw-r--r-- 1 daily daily 2322432 Mar 24 10:49 rrd.journal.1616573588.199726


OMD[daily]:~/var/rrdcached$ tail -f rrd.journal.1616573588.199726 
update /opt/omd/sites/daily/var/check_mk/rrd/localhost/OMD_daily_apache.rrd 1616579503:0:0:0:0:0:0:0:0:0.08098:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0.002154:19.176001:0:0:0:0:0:0:0:0:0:0:0
update /opt/omd/sites/daily/var/check_mk/rrd/localhost/OMD_daily_performance.rrd 1616579503:559:25:0:0.000009:0:364608.943527:0:0:0.583053:0:0.000008:0.000038:0:0.259135:3.09749:3.611691:5.571399:0.015021
update /opt/omd/sites/daily/var/check_mk/rrd/localhost/OMD_dashboard_Notification_Spooler.rrd 1616579503:0:2560278
update /opt/omd/sites/daily/var/check_mk/rrd/localhost/OMD_nagnis_master_Notification_Spooler.rrd 1616579503:0:63841:U:U
update /opt/omd/sites/daily/var/check_mk/rrd/localhost/OMD_nagnis_master_backup_test.rrd 1616579503:3377776640:128932341.39868:49.073688
update /opt/omd/sites/daily/var/check_mk/rrd/localhost/OMD_nagvis_master_backup_test.rrd 1616579503:3377776640:128932341.39868:49.073688
update /opt/omd/sites/daily/var/check_mk/rrd/localhost/Process_chrome.rrd 1616579503:3264916:543481580:7.288174:23
update /opt/omd/sites/daily/var/check_mk/rrd/localhost/Site_daily_statistics.rrd 1616579503:13:42:18:1:119:366:3:0:1:21
update /opt/omd/sites/daily/var/check_mk/rrd/localhost/Systemd_Timesyncd_Time.rrd 1616579503:0.000024:0.000463
update /opt/omd/sites/daily/var/check_mk/rrd/localho^C



Info
titleSources

https://docs.checkmk.com/latest/en/livestatus.html

https://docs.checkmk.com/1.6.0/de/web_api_references.html

https://docs.checkmk.com/1.6.0/de/graphing.html

...