Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recheck not working on Thruk 3.12 #1013

Closed
tabbitsp opened this issue Mar 5, 2024 · 6 comments · Fixed by #1017
Closed

Recheck not working on Thruk 3.12 #1013

tabbitsp opened this issue Mar 5, 2024 · 6 comments · Fixed by #1017

Comments

@tabbitsp
Copy link
Contributor

tabbitsp commented Mar 5, 2024

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
Copy link
Contributor Author

tabbitsp commented Mar 6, 2024

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
Copy link
Contributor Author

tabbitsp commented Mar 13, 2024

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:
plack/Plack#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
Copy link
Contributor Author

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

@HenriWahl
Copy link
Owner

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

@tabbitsp
Copy link
Contributor Author

@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
Copy link
Contributor Author

Closing this as fix has been merged to daily of 3.15

HenriWahl added a commit that referenced this issue Apr 20, 2024
* Update Thruk.py

Fixing "Recheck" error for Thruk systems by adding the mandatory "Content-Type" header to fix #1013

* Update build-release-latest.yml

---------

Co-authored-by: tabbitsp <[email protected]>
HenriWahl added a commit that referenced this issue Apr 20, 2024
* Update Thruk.py

Fixing "Recheck" error for Thruk systems by adding the mandatory "Content-Type" header to fix #1013

* Update build-release-latest.yml

---------

Co-authored-by: tabbitsp <[email protected]>
HenriWahl added a commit that referenced this issue Apr 21, 2024
* Centreon, 24.04, Fix ack on host (#1030)

Tested on 24.04 unstable.
All the others actions are working on this version.

* 3.15 20240314 (#1033)

* Update Thruk.py

Fixing "Recheck" error for Thruk systems by adding the mandatory "Content-Type" header to fix #1013

* Update build-release-latest.yml

---------

Co-authored-by: tabbitsp <[email protected]>

* 3.15-20240420

* actions/checkout@v4

* actions/download-artifact@v4

* docker/login-action@v3

* actions/upload-artifact@v4

* name: ${{ github.job }}

* actions/setup-python@v5

* actions/setup-python@v5

* actions/download-artifact ${{ github.job }}

* artifact patterns

* artifact patterns ''

* added build-release-latest-test-artifacts.yml

* no deps

* no tests at all

* path artifact

* path artifact all distros

* pattern: 'rhel*'

* path: artifact

---------

Co-authored-by: Benoit Poulet <[email protected]>
Co-authored-by: tabbitsp <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants