Troubleshooting agent updater registration errors caused by missing JSON data
This article explains how to troubleshoot missing JSON data errors during Checkmk agent updater registration.
LAST TESTED ON CHECKMK 2.5.0P14
Table of Contents
Problem
When registering the Checkmk agent updater, the registration fails because the updater receives an unexpected response from the Checkmk server.
This can occur when running the following command on a monitored Linux host:
root@linux$
cmk-update-agent register
Depending on the Checkmk version and underlying issue, one of the following errors may appear.
Error example 1: Missing JSON data
Response without json Content-Type
Unexpected answer from Checkmk server: Missing json data.
Maybe we are talking to an agent bakery from before Checkmk 2.0?
Error example 2: Unexpected server response
Unexpected answer from Checkmk server, missing json data.
Please check that the credentials you entered are correct
or use an automation user for the registration.
The updater log may also contain the following exception:
Exception: Unexpected answer from Checkmk server,
missing json data. Please check that the credentials
you entered are correct or use an automation user
for the registration.
Error example 3: Agent Bakery communication failure
Agent Bakery: Error communicating with central bakery
HTTP Error - 404:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html>
<head>
<title>404 Not Found</title>
</head>
<body>
<h1>Not Found</h1>
<p>The requested URL was not found on this server.</p>
</body>
</html>These errors indicate that the updater did not receive the expected response from the Checkmk server or Agent Bakery.
Although the messages may suggest incorrect credentials or an outdated server, the underlying cause can also be related to the configuration of a distributed monitoring environment.
Possible causes
Several conditions can prevent the agent updater from receiving the expected JSON response.
Invalid or expired user credentials
The user account specified during registration may be unable to authenticate against the Checkmk server.
Possible reasons include:
An incorrect username or password.
An expired password that must be changed.
An account that cannot currently log in to the Checkmk GUI.
When authentication fails, the server may return an unexpected response instead of the JSON data required by the updater.
Incorrect Checkmk server or site
The agent updater may be connecting to an incorrect or outdated Checkmk site.
If the target site does not support the expected response format, registration may fail with a missing JSON data error.
This was particularly relevant when connecting newer agent updaters to Checkmk sites running versions earlier than 2.0.
Direct GUI login disabled on a distributed site
In distributed monitoring environments, a remote site may be configured to prevent users from logging in directly through its web interface.
When the agent updater attempts to register against this site, the registration endpoint may redirect the request to the login page.
Instead of receiving JSON data, the updater receives an HTML response.
An HTTP 302 response from register_agent.py indicates that the request is being redirected. If the redirect leads to the Checkmk login page, the updater receives HTML instead of the expected JSON response, causing registration to fail.
The updater then reports:
Unexpected answer from Checkmk server, missing json data.
Note
This issue is not necessarily related to the host name or installed agent version. Registration fails before the updater can complete its initial configuration.
Incorrect central Agent Bakery URL
In distributed monitoring environments, a remote site may need to communicate with the central Agent Bakery.
If the configured URL is incorrect or incomplete, the central server may return an HTTP 404 Not Found response.
For example, the URL may be missing:
The protocol (
https://).The central Checkmk site name.
The
/check_mk/path component.
The updater may then report:
Agent Bakery: Error communicating with central bakery
HTTP Error - 404
Unsigned agent packages
Unsigned agent packages can prevent the agent updater from retrieving or installing the required package.
This issue may occur during regular automatic agent updates, not only during initial registration.
Solution
Follow the troubleshooting steps below to identify and resolve the underlying issue.
Check the agent updater log
Start by examining the updater log on the affected host.
On Linux, the log is typically located at:
/var/lib/check_mk_agent/cmk-update-agent.log
View the latest entries:
root@linux$
tail -n 50 /var/lib/check_mk_agent/cmk-update-agent.log
Look for messages containing:
Unexpected answer from Checkmk server
missing json data
Error communicating with central bakery
HTTP Error - 404These messages can help determine whether the problem is related to authentication, server connectivity, or Agent Bakery configuration.
Verify the registration credentials
Verify that the account used for registration can authenticate successfully.
Open the Checkmk web interface.
Log in using the credentials specified during agent updater registration.
Check whether the account is required to change its password.
If necessary, update the password.
Retry the registration using valid credentials.
For automated registrations, consider using a dedicated automation user with the required permissions.
Note
An automation user is not a substitute for correcting an incorrectly configured distributed site. If the registration endpoint redirects requests to the login page, the site's configuration must also be checked.
Verify the Checkmk server and site
Confirm that the updater is connecting to the intended Checkmk server and site.
Check the following:
The server name resolves to the correct Checkmk server.
The specified site name is correct.
The Checkmk site is running and accessible.
The target site supports the agent updater being used.
If the updater is connecting to an outdated Checkmk site, verify that the server is running a supported Checkmk version.
Enable direct GUI login on the distributed site
If registration fails with a missing JSON data error in a distributed monitoring environment, verify whether direct GUI login is permitted on the affected remote site.
Check the Apache access log
Log in to the Checkmk server and switch to the affected site user.
root@linux$
su - mysite
Examine the Apache access log:
OMD[mysite]:~$
grep -E "register_agent|deploy_agent" var/log/apache/access_log | tail -5
Look for requests to:
register_agent.py
An HTTP 302 response indicates that the registration request is being redirected.
For example:
POST /mysite/check_mk/register_agent.py HTTP/1.1" 302If the redirect leads to the Checkmk login page, the updater receives HTML instead of the expected JSON response.
Update the distributed monitoring configuration
On the central Checkmk site:
Navigate to Setup > General > Distributed monitoring.
Edit the affected remote site.
Locate the Configuration connection section.
Enable Users are allowed to directly login into the web GUI of this site.
Save the configuration.
Activate the changes for the affected site.
The URL of remote site field should contain the appropriate remote site address, for example:
https://<remote-server>/<mysite>/check_mk/
Note
Enabling this option does not automatically grant users permission to modify the remote site's configuration. The Disable configuration via Setup on this site setting remains active, and existing user roles and permissions continue to apply.
Retry the registration
On the monitored Linux host, retry registration using the same server, site, host name, and credentials:
root@linux#
cmk-update-agent register \
--server <myserver> \
--site <mysite> \
--hostname <myhostname> \
--user myuser \
--password '<secret>' \
--trust-cert
Warning
The --trust-cert option trusts the server certificate during registration. Use it only when you have verified that you are connecting to the intended Checkmk server. Supplying passwords directly on the command line can also expose them through shell history or process information.
After registration, examine the Apache access log again:
OMD[mysite]:~$
grep -E "register_agent|deploy_agent" var/log/apache/access_log | tail -5
The registration request should now return HTTP 200 instead of 302.
POST /mysite/check_mk/register_agent.py HTTP/1.1" 200An HTTP 200 response confirms that the endpoint no longer redirects the request.
However, registration may still fail if the remote site cannot communicate with the central Agent Bakery.
If an HTTP 404 error occurs, continue with the next section.
Correct the central Agent Bakery URL
If registration progresses beyond the initial authentication problem but fails with an HTTP 404 error, verify the connection to the central Agent Bakery.
The updater log may contain:
Response from Agent Bakery:
{
'result_code': 1,
'result': 'Error communicating with central bakery\nHTTP Error - 404',
'severity': 'error'
}This indicates that the remote site received an error while communicating with the central Agent Bakery.
Verify the Agent Bakery connection
In the Checkmk GUI, navigate to Setup > General > Global settings > Automatic agent updates > Connection to central Agent Bakery.
Locate the URL to central site setting.
Ensure that the URL contains the complete address, including the protocol, site name, and /check_mk/ path.
For example:
https://myserver.example.com/mysite/check_mk/
The URL should follow this structure:
https://<central-server>/<central-site>/check_mk/
Save and activate the changes
Correct the URL.
Save the configuration.
Activate the changes.
Retry agent updater registration using the original registration command.
Verify that agent packages are signed
If the updater encounters errors when retrieving or installing an agent package, verify that the required package has been signed.
Open the Agent Bakery in the Checkmk GUI.
Check the available baked agent packages.
Verify that the required package has been signed.
If necessary, bake and sign the agent package again.
Retry the automatic update or registration.
Verify the resolution
After applying the appropriate fix, verify that the agent updater can register successfully.
On the monitored Linux host, run:
root@linux$
cmk-update-agent statusCheck that the updater reports a successful registration and displays the expected server, site, and host information.
If registration is unsuccessful, examine the updater log for additional errors:
root@linux$
tail -n 50 /var/lib/check_mk_agent/cmk-update-agent.log
For distributed monitoring environments, you can also check the Apache access log on the relevant Checkmk site:
OMD[mysite]:~$
grep -E "register_agent|deploy_agent" var/log/apache/access_log | tail -5Verify that registration requests return HTTP 200 rather than 302.
A successful HTTP response alone does not guarantee that the entire registration process has completed. Confirm the registration status on the monitored host.
Related articles