"There is no service named" when using "[ ]" in descriptions

Issue #1092 closed
Lars Langner created an issue

Example checks

check process "NTP"       with pidfile /run/ntpd.pid
check process "NTP Test"  with pidfile /run/ntpd.pid
check process "NTP[Test]" with pidfile /run/ntpd.pid
check process "[Test]NTP" with pidfile /run/ntpd.pid

Local CLI test

> monit start "NTP[Test]"
There is no service named "NTP[Test]"
> monit start "[Test]NTP"
There is no service named "NTP[Test]"
> monit start "NTP"       => OK
> moint start "NTP Test"  => OK

This effect shows to be locally as well as from M/Monit GUI call.

> tail /var/log/monit/monit.log
[2023-10-05T11:47:27+0200] info     : 'NTP' start on user request
[2023-10-05T11:47:27+0200] info     : Monit daemon with PID 1681898 awakened
[2023-10-05T11:47:27+0200] info     : Awakened by User defined signal 1
[2023-10-05T11:47:27+0200] info     : 'NTP' start action done
[2023-10-05T11:47:29+0200] info     : 'NTP Test' start on user request
[2023-10-05T11:47:29+0200] info     : Monit daemon with PID 1681898 awakened
[2023-10-05T11:47:29+0200] info     : Awakened by User defined signal 1
[2023-10-05T11:47:29+0200] info     : 'NTP Test' start action done
[2023-10-05T11:47:35+0200] error    : HttpRequest: error -- client [::1]: HTTP/1.0 400 There is no service named "NTP[Test]"
[2023-10-05T11:47:35+0200] error    : There is no service named "NTP[Test]"

Comments (2)

  1. hauk

    The check NAME must (unfortunately) only contain URL-safe chars as it is part of the URL when you check the web, like http://localhost:2812/NAME

  2. Lutz Mader

    As a comment only.
    You can use a service name like "NTP[Test]" but you must quote the "[" in the command line, you try to find a service named "NTPT", "NTPe", etc., but not "NTP[Test]".

    monit summary "NTP.*"
    monit summary 'NTP\[Test]'
    Monit 5.33.0 uptime: 46d 14h 40m
     Service Name                     Status                      Type
     NTP[Test]                        OK                          Directory
    

    But, if you use such service names, the most people are angry and you will got some problems, because the names are not url-safe.

    Lutz

    p.s.
    Use service names like "NTP_Test" or "NTP-Test" and not "NTP Test" (with a space/blank in the name), this is a bad idea, also.

  3. Log in to comment