Automation / Download Agent Output

Hi All.

With CheckMk and the Browser GUI it is possible to produce a raw file by using Download Agent File. This option generates an URL and in the backgound a text file. So far so well. But this needs interaction with the browser GUI.

I do automation with CheckMk values. How can I use this way for automation? I tried some of the URLs in different versions inside a JAVA Program, but it fails often. So a stable usage seems to be impossible by simply using the URL in usall way.

I got things like this:

Internal error: [Errno 2] No such file or directory: ‘/omd/sites/arag_it/var/check_mk/backgrou nd_jobs/agent-output-arag_it-vl115add-agent/arag_it-server_xyz-agent.txt’

Internal error: [Errno 2] No such file or directory: ‘/omd/sites/arag_it/var/check_mk/background_jobs/agent-outpu t-arag_it-server_xyz-agent/arag_it-it-server_xyz-agent.txt’

An internal error occured while processing your request. You can report this issue to the Check_MK team to help fixing this issue. Please use the form bel ow for reporting.

I guess, it has something to do with interaction of the website in GUI and checkMk which I not have inside my JAVA Program.

…check_mk/fetch_agent_output.py?_start=1&back_url=view.py%3Fdeployment_last_contact_from%3D%26deployment_last_contact_until%3D%26deployment_last_download_from%3D%26deployment_last_download_until%3D%26deployment_last_registered_from%3D%26deployment_last_registered_until%3D%26host_last_check_from%3D%26host_last_check_until%3D%26host_last_state_change_from%3D%26host_last_state_change_until%3D%26selection%%26view_name%3Dallhosts&folder=&host=&type=agent

Which parameters produce this file (where is a very long list of parameters in the URL)? Exist where some special parameters to start the background_job producing the file without using a Browser? How can I start this background process by bash command using ssh? Exists these text files elsewhere on the checkMk server?

If you can ssh to the checkmk server then it’s far easier than you imagined:

ssh CMKSERVER "su - SITEUSER -c 'cmk -d HOSTNAME'" > agent_ouput.txt

Et voilĂ , the agent output is in the local file agent_output.
The command cmk -d HOSTNAME (issued as site user) retrieves the agent output of the given hostname an prints it to stdout. If you can login as the site user, it’s even easier:

ssh SITEUSER@CMKSERVER cmk -d HOSTNAME > agent_ouput.txt

You don’t even need quotes here.

The “latest” agent output is also cached in the files ~siteuser/tmp/check_mk/cache/$hostname. Maybe that’s sufficient for you.

It’s even more easy:

cat $OMD_ROOT/tmp/check_mk/cache/$HOSTNAME

But why on earth do you need the raw agent data for automation? Do you really like to re-interpret all the data?

1 Like

Typically not all figures are shown in the service or invetory views. Partions and filesystem. HD values…

sftp seems to be the choice for now. I am coming from a spring program inside a container to get the files.

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.