HenriWahl / Nagstamon

Nagios status monitor for your desktop.
https://nagstamon.de
Other
424 stars 179 forks source link

Recheck not working on Thruk 3.12 #1013

Closed tabbitsp closed 8 months ago

tabbitsp commented 8 months ago

Hi Nagstamon-Team, I got an issue running "Recheck" with Nagstamon on our Naemon/Thruk-Server. Acknowledgement and Downtime work fine, as I deactivated the csrf for our IP addresses, but "Recheck" just won't do anything..

I ran the dumpio on our Apache and got the following POST info from Nagstamon to Thruk: cmd_typ=7&cmd_mod=2&host=localhost&service=Check_Unknown&start_time=2024-03-05+15%3A51%3A00&force_check=on&btnSubmit=Commit

This results in an error: [Tue Mar 05 15:51:05.398973 2024] [fcgid:warn] [pid 9497] [client myipaddress:60166] mod_fcgid: stderr: Can't locate object method "seek" via package "IO::Handle" at /usr/lib/thruk/perl5/Plack/Request.pm line 78.

The original POST from the server itself in the web looks like this: cmd_typ=7&cmd_mod=2&start_time=1709650597&host=localhost&service=Check_Unknown&force_check=1&backend=328c5&referer=extinfo.cgi%3Ftype%3D2%26host%3Dlocalhost%26service%3DCheck_Unknown%26backend%3D328c5&CSRFtoken=1234567890_1

Is there anything which needs to be fixed from Nagstamon's side for this to work?

tabbitsp commented 8 months ago

Hm, I checked once more with pushing the recheck directly in the issue - the POST does not look very different to the one sent from Nagstamon: _referer=%2Fthruk%2Fcgi-bin%2Fextinfo.cgi%3Ftype%3D2%26host%3Dlocalhost%26service%3DCheck_Unknown%26backend%3D328c5&CSRFtoken=1234567890_1&_cmd_typ=7&cmd_mod=2&backend=328c5&host=localhost&service=Check_Unknown&start_time=2024-03-06+09%3A53%3A00&force_check=on&btnSubmit=Commit

If we leave out token and referer, this just leaves the backend - could this be required?

tabbitsp commented 8 months ago

I checked some more and also ran a debug version of Nagstamon to find out more about this issue:

First of all, the command issued by Nagstamon seems to be absolutely fine - manually executing the task using curl with the same CGI data is working as expected: curl -u t.user:password https://servername/thruk/cgi-bin/cmd.cgi -d"cmd_typ=7&cmd_mod=2&host=localhost&service=Check_Unknown&start_time=2024-03-13+10%3A06%3A00&force_check=on&btnSubmit=Commit"`

Checking further on this error in the web led me to this page: https://github.com/plack/Plack/issues/655

And now executing the same command with an empty "Content-Type" header leads to an error on the web server: curl -u t.user:pw https://servername/thruk/cgi-bin/cmd.cgi -d "cmd_typ=7&cmd_mod=2&host=localhost&service=Check_Unknown&start_time=2024-03-13+10%3A06%3A00&force_check=on&btnSubmit=Commit" -H "Content-Type:"

Setting the content type manually to the default from cron, everything works again: curl -u user:pw https://servername/thruk/cgi-bin/cmd.cgi -d "cmd_typ=7&cmd_mod=2&host=localhost&service=Check_Unknown&start_time=2024-03-13+10%3A06%3A00&force_check=on&btnSubmit=Commit" -H "Content-Type: application/x-www-form-urlencoded"

Unfortunately, I'm no programmer and don't know how to tell python to use this content type for the Recheck command. Is there any place this could be done? How do I tell Nagstamon to use the correct content type for this command?

tabbitsp commented 8 months ago

Took the line for IcingDBWeb Server and added it to the "Recheck" function of Thruk

HenriWahl commented 8 months ago

@tabbitsp thanks for your investigations - do you refer to Nagstamon 3.12 or 3.14?

tabbitsp commented 8 months ago

@HenriWahl - both Nagstamon 3.12 and 3.14 did not work - my reference was about Thruk 3.12, which is embedded into the current OMD package - it's a coincidence that they both have a similar version number ;-)

tabbitsp commented 8 months ago

Closing this as fix has been merged to daily of 3.15