Nginx Status Check

Hello! we are adding nginx to our check_mk Enterprise 1.6.0 p5, nginx is not appearing in the services list on the desired host.

we followed the following tutorial:

i’m running the plugin nginx_status from on the host i’m getting the following error:

Exception (127.0.0.1:443): hostname ‘127.0.0.1’ doesn’t match either of ‘*.x.com’, ‘x.com

my nginx_status.conf is the following:

servers = [
{
“protocol” : “http”,
“address” : “127.0.0.1”,
“port” : 80,
},
]

My fix should help you out:

If your nginx doesn’t listen http (e.g. 127.0.0.1 port 80), if it’s only SSL, then the subject needs to be fully qualified in order to match the certificate presented SSL wise.

Hello @cjcox and @mace,
@cjcox Yep i know the what is the reason and nginx is listening on both HTTP and HTTPS, but i need a way to bypass it because it’s not logical …, @mace i tried your pull request the error is gone but the plugin is not returning any data, even tho if i do wget -qO - http://127.0.0.1/nginx_status

the answer is:

Active connections: 20
server accepts handled requests
130935 130935 196748
Reading: 0 Writing: 1 Waiting: 19

the output of the script is:

./nginx_status
<<<nginx_status>>>

Hi ziad,

I will show an example of my configuration:

  1. Create a server section in /etc/nginx/sites-enabled/default
    (Path can be different. I use the default path for that)

server {
listen 8081;
listen [::]:8081;

server_name _;

root /var/www/html;
index index.html;

location /nginx_status
{
stub_status on;
access_log off;
allow 127.0.0.1;
deny all;

}
}

  1. Create the config file in /etc/check/nginx_status.cfg

#Example configuration for NGNIX plugin
#If you do not supply a configuration file then autodetection
#is being tried.

servers = [
{
“protocol” : “http”,
“address” : “127.0.0.1”,
“port” : 8081,
“page” : “nginx_status”,
}
]

  1. Testing

/usr/lib/check_mk_agent/plugins/nginx_status
<<<nginx_status>>>
127.0.0.1 8081 Active connections: 1
127.0.0.1 8081 server accepts handled requests
127.0.0.1 8081 74 74 74
127.0.0.1 8081 Reading: 0 Writing: 1 Waiting: 0

I hope it helps

BR

Anastasios

Hello,

Found the issue the script was trying to auto discover nginx on localhost:443 and not localhost:80, even tho the configuration in nginx is on port 80.

It was not noticing the nginx_status.cfg because i was calling it nginx_status.conf lol… devs… some wants to call the file cfg and other wants to call it conf and we system engineers have to suffer :rofl:

Thanks for the help anyway!!!

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.