Linuxfabrik / monitoring-plugins

220+ check plugins for Icinga and other Nagios-compatible monitoring applications. Each plugin is a standalone command line tool (written in Python) that provides a specific type of check.
https://linuxfabrik.ch
The Unlicense
220 stars 51 forks source link

Check nginx-status #484

Closed NavidSassan closed 2 years ago

NavidSassan commented 2 years ago

In GitLab by @hayt on Dec 9, 2021, 11:17

I'm trying to execute the script but end with such an error. Could advice? image

NavidSassan commented 2 years ago

In GitLab by @markuslf on Dec 9, 2021, 13:03

Try ./nginx-status --url http://your-server/server-status, assuming you have configured

server {
    location /server-status {
        stub_status;
        allow 127.0.0.1;    # only allow requests from localhost
        deny all;           # deny all other hosts   
    }
}
NavidSassan commented 2 years ago

In GitLab by @hayt on Dec 9, 2021, 16:29

here is conf file. Markus this script should work with server blocks? image

here with curl its working image

NavidSassan commented 2 years ago

In GitLab by @hayt on Dec 9, 2021, 16:31

image

NavidSassan commented 2 years ago

In GitLab by @markuslf on Dec 9, 2021, 20:39

Then please try /usr/lib64/nagios/plugins/nginx-status --url http://your-server.local/nginx_status. This should work.

NavidSassan commented 2 years ago

In GitLab by @markuslf on Dec 15, 2021, 07:45

Were you able to test this?

NavidSassan commented 2 years ago

In GitLab by @hayt on Dec 29, 2021, 14:17

hello Markus, It doesn't ... here same URL using "curl" image

any advice ?

mj

NavidSassan commented 2 years ago

In GitLab by @hayt on Dec 30, 2021, 13:19

@markuslf cant it be the same issue? https://stackoverflow.com/questions/33054527/typeerror-a-bytes-like-object-is-required-not-str-when-writing-to-a-file-in

NavidSassan commented 2 years ago

In GitLab by @markuslf on Jan 4, 2022, 07:55

I was missing the point that you are using the Python 3 version of the check, my mistake.

Fixed via https://git.linuxfabrik.ch/linuxfabrik/lib/-/issues/44. Be sure to checkout the newest url3.py library from the develop branch.

NavidSassan commented 2 years ago

In GitLab by @hayt on Jan 9, 2022, 14:29

thx @markuslf it solved the issue. Tell me please is it possible to get stats only for the exact server block? Right now, for every server block in this instance, I get the same NGINX metrics.

mj

NavidSassan commented 2 years ago

In GitLab by @markuslf on Jan 10, 2022, 08:05

As you can see in the source code, any counter is incremented exactly at the moment when a new request "object" is being created. That is, even before any request header, including the URI, is parsed. So the answer is no, unfortunately there is no way to tell Nginx not to count requests for a particular URI.

Have a look at this discussion on the topic.

NavidSassan commented 2 years ago

In GitLab by @hayt on Jan 10, 2022, 14:13

Markus, as the Nginx status module, is deprecated. Do you plan to develop a plugin for ngx_http_api_module?

http://nginx.org/en/docs/http/ngx_http_api_module.html

NavidSassan commented 2 years ago

In GitLab by @markuslf on Jan 10, 2022, 16:07

Not at the moment, maybe sometimes in the future.