sni / Thruk

Thruk is a multibackend monitoring webinterface for Naemon, Nagios, Icinga and Shinken using the Livestatus API.
http://www.thruk.org
Other
408 stars 148 forks source link

Duration suffix in the rest api is not correct #1340

Closed lausser closed 8 months ago

lausser commented 8 months ago

Describe the bug I was setting a scheduled host downtime using the thruk rest api as described in: https://www.thruk.org/documentation/rest_commands.html#_relative-timestamps But instead of a duration of 1 minute i get a duration of 1 month.

Thruk Version Thruk 3.13.20240217

To Reproduce

$ thruk r -d "comment_data=test" -d "end_time=+1m" /hosts/myhost.com/cmd/schedule_host_downtime
{
   "commands" : "COMMAND [1709047680] SCHEDULE_HOST_DOWNTIME;myhost.com;1709047680;1711549680;1;0;0;(cli);test",
   "message" : "Command successfully submitted"
}

Today is 27st february. In the Thruk ui i see Start Time 10:28:00 End Time 2024-03-27 10:28:00 Type Fixed Duration 28d 23h 0m 0s

Expected behavior According to the documentation, 1m should be one minute. Instead it is one month.

sni commented 8 months ago

the issue was, that the "+" got urldecoded into a space " ". Then the end_date was " 1m" and this got parsed as "one month" later. The quick and dirty fix is to replace leading plus signs as %2B so it can be decoded into a plus later as done in 9e67cb3d8f865bb69e294f10aa722d1f2211ba87. So it should be fine again tomorrow.