Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


Info
This check parses the information provided by the NGINX stub status module. If you have enabled that module, then the URL /nginx_status shows interesting information about the inner state of the web server when accessed from localhost. The agent plugin nginx_status fetches

...

this information and processes it.

...

Status
colourGreen
titleLAST TESTED ON CHECKMK 2.2.0P1


Panel
borderColorblack
bgColor#f8f8f8
titleTable of Contents

Table of Contents

Step-by-step guide

After installing and configuring nginx Nginx, you can follow this these steps to monitor Nginx status.

...

  1. Nginx stub status module

    Make sure that the server process is configured with the stub status module. Use the command:

    Code Block
    languagelinenumbersbash
    themetrueRDark
    root@klappanasroot@linux:~# nginx -V 2>&1 | grep -o with-http_stub_status_module   
    with-http_stub_status_module

    If the stub status module is not installed, you can follow this guide for the installation: https://www.tecmint.com/enable-nginx-status-page/

  2. Add a new server block configuration inside /etc/nginx/sites-enabled/default

    Code Block
    languagebash
    themeRDark
    title/etc/nginx/sites-enabled/default
    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;
    
            }
    }

    .

  3. restart

    Restart nginx service

    Code Block
    languagebash
    themeRDark
    root@linux:~# systemctl restart nginx

    .

  4. Now the

    Url

    URL 127.0.0.1:8081/nginx_status should be available

    Code Block
    languagebash
    themeRDark
    root@linux:~# wget -qO - http://127.0.0.1:8081/nginx_status
    Active connections: 1 
    server accepts handled requests
     1 1 1 
    Reading: 0 Writing: 1 Waiting: 0 

    .

  5. Configure nginx_status

    • Manually
      You must install the agent plugin nginx_status into your agent's plugins directory (usually /usr/lib/check_mk_agent/plugins). The plugin tries to autodetect all running NGINX servers. If that fails, you must create the configuration file /etc/check_mk/nginx_status

    1. manually
    2. via Bakery

...

    • .cfg. Here is one example:

      Code Block
      languagebash
      themeRDark
      servers = [{'address': '127.0.0.1',
        'page': 'nginx_status',
        'port': 8081,
        'protocol': 'http'}]


    • via Bakery
      Setup → Agents → Windows, Linux, Solaris... → Agent rules →NGINX webservers (Linux)

      • Autodetect instances expect HTTPS on the following ports: nginx_status will try to autodetect all running NGINX servers.
        Screenshot of New rule for Nginx webserver. Autodetect instances, expect HTTPS on the following ports enabled. Port 443 selected.Image Added

      • Specific list of instances: You can specify NGINX instances
        Screenshot of New rule for Nginx webserver. Specific list of instances enabled. Protocol set to HTTP. IP address used in this example is 127.0.0.1. TCP port number set to 8081. URI set to nginx_status.Image Added


  1. Test the plugin

Now you can execute the plugin manually and see if it works:

Code Block
languagebash
themeRDark
MK_CONFDIR=/etc/check_mk /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  380 380 380 
127.0.0.1 8081 Reading: 0 Writing: 1 Waiting: 0 


Check_MK will create one service for each web server.
Screenshot of Undecided services, currently not monitored 1. Check reports pending.Image Added

Debugging

Port Checking

Code Block
languagebash
themeRDark
linenumberstrue
root@klappanasroot@linux:~# netstat -tulpen |grep 8081
tcp        0      0 0.0.0.0:8081            0.0.0.0:*               LISTEN      0          43044      1353/nginx: master  
tcp6       0      0 :::8081                 :::*                    LISTEN      0          43045      1353/nginx: master  


Nginx Service

Code Block
languagelinenumbersbash
themetrueRDark
root@klappanasroot@linux:~# systemctl status nginx

Stub status module

root@klappanas
Code Block
linenumberstrue
languagebash
themeRDark
root@linux:~# nginx -V 2>&1 | grep -o with-http_stub_status_module   
with-http_stub_status_module


Checking the status page

root@klappanasinfo
Code Block
linenumberstrue
languagebash
themeRDark
root@linux:~# wget -qO - http://127.0.0.1:8081/nginx_status
Active connections: 1 
server accepts handled requests
 398 398 398 
Reading: 0 Writing: 1 Waiting: 0


Note

We also have detailed documentation about nginx_status: https://checkmk.com/cms_check_nginx_status.html.

Do you want to learn more about monitoring web servers? Check out our blog page: https://checkmk.com/blog/how-to-monitor-web-server.

Filter by label (Content by label)
showLabelsfalse
max5
spacesKB
showSpacefalse
sortmodified
reversetrue
typepage
cqllabel in ( "nginx" , "nginx_status" , "webserver" , "kb-how-to-article" ) and type = "page" and space = "KB"
labelsnginx webserver nginx_status

...