Help with nginx app

I am trying to get to work nginx app on localhost for example, i did what is mentioned here

and what is mentioned here

https://docs.librenms.org/#Extensions/Applications/#nginx

but when i trying to run ./nginx it is not working.

root@librenms:/usr/lib/check_mk_agent/local# ls
nginx
root@librenms:/usr/lib/check_mk_agent/local# ./nginx
<<>>

Traceback (most recent call last):
File “./nginx”, line 35, in
Active = int(params[“Reading”]) + int(params[“Writing”]) + int(params[“Waiting”])
KeyError: ‘Reading’
root@librenms:/usr/lib/check_mk_agent/local#

Please help

And on another linux I getting this error

:/usr/lib/check_mk_agent/local$ ./nginx
Traceback (most recent call last):
File “./nginx”, line 6, in
data = urllib2.urlopen(‘http://127.0.0.1/nginx-status’).read()
File “/usr/lib/python2.7/urllib2.py”, line 127, in urlopen
return _opener.open(url, data, timeout)
File “/usr/lib/python2.7/urllib2.py”, line 410, in open
response = meth(req, response)
File “/usr/lib/python2.7/urllib2.py”, line 523, in http_response
‘http’, request, response, code, msg, hdrs)
File “/usr/lib/python2.7/urllib2.py”, line 448, in error
return self._call_chain(*args)
File “/usr/lib/python2.7/urllib2.py”, line 382, in _call_chain
result = func(*args)
File “/usr/lib/python2.7/urllib2.py”, line 531, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 404: Not Found

It doesn’t look to me like your NGINX server is serving up the nginx-status page like the script expects. On the NGINX server itself you could try running: curl http://127.0.0.1/nginx-status

Ideally you would see something like:

$ curl http://127.0.0.1/nginx-status
Active connections: 1
server accepts handled requests
 274 274 357
Reading: 0 Writing: 1 Waiting: 0

If not there’s probably some kind of issue with the location /nginx-status config block in your nginx conf file from the docs page you linked above. Or in some rare cases your NGINX install might not have been compiled with the stub_status_module. You should be able to confirm with: nginx -V 2>&1 | grep -o with-http_stub_status_module

Ideally you would see something like:

$ nginx -V 2>&1 | grep -o with-http_stub_status_module
with-http_stub_status_module

here is my config of nginx

https://pastebin.com/embed_js/xeQ3uYFT

I have stub_status_module

librenms:~# nginx -V 2>&1 | grep -o with-http_stub_status_module
with-http_stub_status_module

But when i ran

curl http://127.0.0.1/nginx-status

I got this

https://pastebin.com/embed_js/tjUay3Kq

please help with this

thank you.

Unless you have a specific reason for not doing so, I would just take your location /nginx-status {} config block and move it into the same server config block as LibreNMS. Right under the location /api/v0 {} block for example.

You can run multiple virtual servers in NGINX but you would need more configuration to do so. listen port, server_name, etc. And assuming both are on the same port you would need to make one server the default.

Like Slashdoom said you have to move

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

Into the first server block if you specify a second serverblock you have to have servername added and modify the check_mk_agent/local/nginx file to point to the servername to get nginx-status to work.

Ok i got it.

Now i can see

#curl http://127.0.0.1/nginx-status
Active connections: 1
server accepts handled requests
 2 2 2
Reading: 0 Writing: 1 Waiting: 0

I added

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

to my librenms nginx conf in /etc/nginx/sites-enabled/ right away behind my server_name

server {

    # Add your own domain name
    listen      80;
    server_name librenms;

location /nginx-status {
    stub_status on;
    access_log   off;
    allow 127.0.0.1;
    deny all;
}

And It is working. Thank you.