Error Agent Register not working

CMK version: 2.1.0p1.cee
OS version: Debian 11 Bullseye

Error message:
We upgraded from CMK 2.0.0p24cee to 2.1.0p1.cee.
After the upgrade it try the new Agent Registration on Windows and Linux. The certification trust works, but i’ve got an error message.

Command for registration

cmk-agent-ctl register --server cmkserver:443 --trust-cert --site cmksite --user username --password password --hostname monitoringhost

On Debian 11 if got the following output

ERROR [cmk_agent_ctl] Error pairing with cmkserver:443/cmksite

Caused by:
    Request failed with code 404 Not Found: <!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>

On Windows Server 2012

ERROR [cmk_agent_ctl] src\main.rs:29: Error pairing with cmkserver:443/cmksite

Caused by:
    Request failed with code 404 Not Found: <!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>

I also look a the CMKSERVER in the Apache Log and find the follwoing

10.X.Y.Z - - [03/Jun/2022:02:31:41 +0200] "POST /cmksite/check_mk/deploy_agent.py HTTP/1.1" 200 4931 "-" "python-requests/2.23.0"
10.X.Y.Z - - [03/Jun/2022:06:32:22 +0200] "POST /cmksite/check_mk/deploy_agent.py HTTP/1.1" 200 4931 "-" "python-requests/2.23.0"
10.X.Y.Z - - [03/Jun/2022:08:11:22 +0200] "GET /download/check-mk-agent-generic.deb HTTP/1.1" 200 17901628 "-" "Wget/1.21"
10.X.Y.Z - - [03/Jun/2022:08:11:32 +0200] "GET /download/check-mk-agent-generic.deb HTTP/1.1" 200 17901628 "-" "Wget/1.21"
10.X.Y.Z - - [03/Jun/2022:08:11:35 +0200] "POST /cmksite/check_mk/deploy_agent.py HTTP/1.1" 200 4813 "-" "python-requests/2.23.0"
10.X.Y.Z - - [03/Jun/2022:08:11:35 +0200] "POST /cmksite/check_mk/deploy_agent.py HTTP/1.1" 200 24489832 "-" "python-requests/2.23.0"
10.X.Y.Z - - [03/Jun/2022:08:11:37 +0200] "POST /cmksite/check_mk/deploy_agent.py HTTP/1.1" 200 4813 "-" "python-requests/2.23.0"
10.X.Y.Z - - [03/Jun/2022:08:12:04 +0200] "POST /cmksite/agent-receiver/pairing HTTP/1.1" 404 3344 "-" "-"
10.X.Y.Z - - [03/Jun/2022:08:12:40 +0200] "POST /cmksite/agent-receiver/pairing HTTP/1.1" 401 3580 "-" "-"
10.X.Y.Z - - [03/Jun/2022:08:12:47 +0200] "POST /cmksite/agent-receiver/pairing HTTP/1.1" 404 3344 "-" "-"

Did you have any idea whats wrong?

Thanks for your help

Can the agent-controller reach the agent-receiver on the cmk-server on port:8000
Maybe a firewall (central, cmk-server or host) prevents the access?

Hey,

thanks for your feedback. Your right, it was the wrong port. ich change i to port 8000, no firewall is blcoking, but i’ve got now error

ERROR [cmk_agent_ctl] Error pairing with cmkserver:8000/cmksite

Caused by:
    Request failed with code 500 Internal Server Error: Internal Server Error

Why you used the “–trust-cert” option for the registration?

I enable trust-cert, so that i didn’t need enter Y

I also try without trust-cert and enter Y. Didn’t work

Thanks, i didn’t see this.

I will wait for p2

Update: Nervermind. The hostname “localhost” was wrong. It has to match the actual hostname used by the Checkmk server, found under “Setup” > “Hosts”.


On a related note, I’ve been following the beginner’s guide on setting up Checkmk and found that registering the Checkmk Agent for monitoring the monitoring server itself not working.

CMK version: 2.1.0p6
OS version: Ubuntu Server 22.04 LTS

The command issued was (where mysite = actual site):

sudo cmk-agent-ctl register --hostname localhost --server mysite:8000 --site mysite --user cmkadmin -vv

Error message:

INFO [cmk_agent_ctl] starting
INFO [cmk_agent_ctl] Loaded config from '"/etc/check_mk/cmk-agent-ctl.toml"', legacy pull 'LegacyPullMarker("/var/lib/cmk-agent/allow-legacy-pull")' exists
Attempting to register at monitoring.mysite.com:8000/mysite. Server certificate details:

PEM-encoded certificate:
...
-----END CERTIFICATE-----

Issued by:
        Site 'mysite' local CA
Issued to:
        mysite
Validity:
        From Mon, 11 Jul 2022 21:20:15 +0000
        To   Sat, 11 Nov 3020 21:20:15 +0000

Do you want to establish this connection? [Y/n]
> Y

Please enter password for 'cmkadmin'
>

DEBUG [reqwest::connect] starting new connection: https://monitoring.mysite.com:8000/
DEBUG [rustls::client::hs] No cached session for DnsName(DnsName(DnsName("monitoring.mysite.com")))
DEBUG [rustls::client::hs] Not resuming any session
DEBUG [rustls::client::hs] Using ciphersuite TLS13_AES_256_GCM_SHA384
DEBUG [rustls::client::tls13] Not resuming
DEBUG [rustls::client::tls13] TLS1.3 encrypted extensions: []
DEBUG [rustls::client::hs] ALPN protocol is None
DEBUG [rustls::client::tls13] Ticket saved
DEBUG [rustls::client::tls13] Ticket saved
DEBUG [reqwest::async_impl::client] response '200 OK' for https://monitoring.mysite.com:8000/mysite/agent-receiver/pairing
DEBUG [reqwest::connect] starting new connection: https://monitoring.mysite.com:8000/
DEBUG [rustls::client::hs] No cached session for DnsName(DnsName(DnsName("monitoring.mysite.com")))
DEBUG [rustls::client::hs] Not resuming any session
DEBUG [rustls::client::hs] Using ciphersuite TLS13_AES_256_GCM_SHA384
DEBUG [rustls::client::tls13] Not resuming
DEBUG [rustls::client::tls13] TLS1.3 encrypted extensions: []
DEBUG [rustls::client::hs] ALPN protocol is None
DEBUG [rustls::client::tls13] Ticket saved
DEBUG [rustls::client::tls13] Ticket saved
DEBUG [reqwest::async_impl::client] response '404 Not Found' for https://monitoring.mysite.com:8000/mysite/agent-receiver/register_with_hostname
ERROR [cmk_agent_ctl] Error registering with hostname at monitoring.mysite.com:8000/mysite

Caused by:
    Request failed with code 404 Not Found: Host localhost does not exist.

I have no clue if this is caused by a missing REST endpoint or what is going on.
Can you provide any tips to resolve this?

Same problem! Please help!

Hello all

is there any solution available?
W e coming from 2.0.0p37 updated to 2.1.0p31 and has the same problem, the the registration tells us:

ERROR [cmk_agent_ctl] Error pairing with <site-host>:443/<site>:8000

Caused by:
    Request failed with code 404 Not Found: <!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>

It seams the port 8000 is not reachable but the firewall is open at the site host:

 ss -tulpn|grep 8000
tcp   LISTEN 0      2048               *:8000             *:*    users:(("python3",pid=1178546,fd=7),("python3",pid=1178538,fd=7))

Agent site:
nc 8000
Ncat: No route to host.

Are there any solution available?

Please let us know.

Thanks
JP

This looks a bit weird. Can you paste the full command used?

Same here… Ubuntu 22.04 LTS Linux Debian Client for registration.

cmk-agent-ctl register --hostname pve1.tux.lan --server monitoring.tux.lan:8000 --site home --user cmkadmin --trust-cert

Please enter password for 'cmkadmin'
> 
ERROR [cmk_agent_ctl] Error registering existing host at https://monitoring.tux.lan:8000/home

Caused by:
    Request failed with code 500 Internal Server Error: Internal Server Error

Here my CheckMK Version 2.2.0p12
And here a log of very bad Logs:

[2024-01-22 10:32:53 +0000] [48511] [ERROR] Exception in ASGI application
Traceback (most recent call last):
  File "/omd/sites/home/lib/python3.11/site-packages/uvicorn/protocols/http/h11_impl.py", line 407, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/omd/sites/home/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 78, in __call__
    return await self.app(scope, receive, send)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/omd/sites/home/lib/python3.11/site-packages/fastapi/applications.py", line 284, in __call__
    await super().__call__(scope, receive, send)
  File "/omd/sites/home/lib/python3.11/site-packages/starlette/applications.py", line 122, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/omd/sites/home/lib/python3.11/site-packages/starlette/middleware/errors.py", line 184, in __call__
    raise exc
  File "/omd/sites/home/lib/python3.11/site-packages/starlette/middleware/errors.py", line 162, in __call__
    await self.app(scope, receive, _send)
  File "/omd/sites/home/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 79, in __call__
    raise exc
  File "/omd/sites/home/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 68, in __call__
    await self.app(scope, receive, sender)
  File "/omd/sites/home/lib/python3.11/site-packages/fastapi/middleware/asyncexitstack.py", line 20, in __call__
    raise e
  File "/omd/sites/home/lib/python3.11/site-packages/fastapi/middleware/asyncexitstack.py", line 17, in __call__
    await self.app(scope, receive, send)
  File "/omd/sites/home/lib/python3.11/site-packages/starlette/routing.py", line 718, in __call__
    await route.handle(scope, receive, send)
  File "/omd/sites/home/lib/python3.11/site-packages/starlette/routing.py", line 443, in handle
    await self.app(scope, receive, send)
  File "/omd/sites/home/lib/python3.11/site-packages/fastapi/applications.py", line 284, in __call__
    await super().__call__(scope, receive, send)
  File "/omd/sites/home/lib/python3.11/site-packages/starlette/applications.py", line 122, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/omd/sites/home/lib/python3.11/site-packages/starlette/middleware/errors.py", line 184, in __call__
    raise exc
  File "/omd/sites/home/lib/python3.11/site-packages/starlette/middleware/errors.py", line 162, in __call__
    await self.app(scope, receive, _send)
  File "/omd/sites/home/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 79, in __call__
    raise exc
  File "/omd/sites/home/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 68, in __call__
    await self.app(scope, receive, sender)
  File "/omd/sites/home/lib/python3.11/site-packages/fastapi/middleware/asyncexitstack.py", line 20, in __call__
    raise e
  File "/omd/sites/home/lib/python3.11/site-packages/fastapi/middleware/asyncexitstack.py", line 17, in __call__
    await self.app(scope, receive, send)
  File "/omd/sites/home/lib/python3.11/site-packages/starlette/routing.py", line 718, in __call__
    await route.handle(scope, receive, send)
  File "/omd/sites/home/lib/python3.11/site-packages/starlette/routing.py", line 276, in handle
    await self.app(scope, receive, send)
  File "/omd/sites/home/lib/python3.11/site-packages/starlette/routing.py", line 66, in app
    response = await func(request)
               ^^^^^^^^^^^^^^^^^^^
  File "/omd/sites/home/lib/python3.11/site-packages/fastapi/routing.py", line 241, in app
    raw_response = await run_endpoint_function(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/omd/sites/home/lib/python3.11/site-packages/fastapi/routing.py", line 167, in run_endpoint_function
    return await dependant.call(**values)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/omd/sites/home/lib/python3.11/site-packages/agent_receiver/endpoints.py", line 110, in register_existing
    _sign_agent_csr(
  File "/omd/sites/home/lib/python3.11/site-packages/agent_receiver/endpoints.py", line 88, in _sign_agent_csr
    internal_credentials(),
    ^^^^^^^^^^^^^^^^^^^^^^
  File "/omd/sites/home/lib/python3.11/site-packages/agent_receiver/utils.py", line 76, in internal_credentials
    secret = (users_dir() / INTERNAL_REST_API_USER / "automation.secret").read_text().strip()
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/omd/sites/home/lib/python3.11/pathlib.py", line 1058, in read_text
    with self.open(mode='r', encoding=encoding, errors=errors) as f:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/omd/sites/home/lib/python3.11/pathlib.py", line 1044, in open
    return io.open(self, mode, buffering, encoding, errors, newline)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/omd/sites/home/var/check_mk/web/automation/automation.secret'

1 Like

I was facing this issues and got it solved after updating the agent to match checkmk server version.

Fixed after create the user automation with secret.

1 Like