# Check\_nginx\_status - nagios-plugin to monitor nginx status

**URL:** <https://www.ruby-forum.com/t/check-nginx-status-nagios-plugin-to-monitor-nginx-status/235544>\
**Category:** NGINX\
**Created:** [June 28, 2013, 3:32pm UTC](https://www.ruby-forum.com/t/check-nginx-status-nagios-plugin-to-monitor-nginx-status/235544 "2013-06-28T15:32:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [June 28, 2013, 3:32pm UTC](https://www.ruby-forum.com/t/check-nginx-status-nagios-plugin-to-monitor-nginx-status/235544/1 "2013-06-28T15:32:41Z")

</div>

check\_nginx\_status is (yet another) Nagios-Plugin  
to monitor nginx status and alerts on various values, based on  
HttpStubStatus

it also creates, based on the returned values, a csv to store data

docs&downloads:

[http://doxi-news.blogspot.de/2013/06/checknginxstatus-nagios-plugin-to.html](http://doxi-news.blogspot.de/2013/06/checknginxstatus-nagios-plugin-to.html)  
(with screenshots)  
[Bitbucket](https://bitbucket.org/maresystem/dogtown-nagios-plugins)

Usage:

```
 check_nginx_status [-H|--HOST] [-p|--port] [-u|--url] [-a|--auth]

```

[-s|–ssl]  
[-t|–test] [-w|–warning] [-c|–critical]  
[-o|–output] [-r|–resultfile]  
[-h|–help] [-v|–version] [-d|–debug]

Options:

–help|-h)  
print check\_nginx\_status help

–HOST|-H)  
Sets nginx host  
Default: localhost

–port|-p)  
Sets connection-port  
Default: 80/http, 443/https

–ssl|-s)  
Turns on SSL  
Default: off

–url|-u)  
Sets nginx status url path.  
Default: /nginx\_status

–auth|-a)  
Sets nginx status BasicAuth user:password.  
Default: off  
\*\*\*

–test|-t)  
Sets the test(check)\_value for w/c  
if used, -w/-c is mandatory  
Default: checktime  
possible Values:

```
     active_conns -> active connections
     accepts_err -> difference between accepted and
                        handled requests (should be 0)
     requests -> check for requests/connection
     reading -> actual value for reading headers
     writing -> value for active requests
     waiting -> actual keep-alive-connections
     checktime -> checks if this check need more than
                        given -w/-c milliseconds

 --calculated checks ---------------
     rps -> requests per seconds
     cps -> connections per second
     dreq -> delta requests to the previous one
     dcon -> delta connections to the previous one

     these checks are calculated at runtime with a timeframe
     between the latest and the current check; time is
     extracted from the timestamp of the result_file

     to disable calculation (no files are written) use -n;
     you cannot use -t [rps,cps,dreq,dcon] with -n; this
     will raise an error and the plugin returns UNKNOWN

     see -r - option for an alternate filepath for temporary results

```

–warning|-w)  
Sets a warning level for selected test(check)  
Default: off

–critical|-c)  
Sets a critical level for selected test(check)  
Default: off

–debug|-d)  
turn on debugging - messages (use this for manual testing,  
never via nagios-checks; beware of the messy output  
Default: off

–version|-v)  
display version and exit

–output|-o)  
output only values from selected tests in perfdata; if used w/out  
-t  
the check returns the value for active connections

–resultfile|-r)  
/path/to/check\_nginx.results{.csv}  
please note, beside the values from the actual check  
(eg.g check\_nginx.results) a second  
file is created, if not existent, and written on each plugin-run  
(check\_nginx.results.csv), containign a historic view on all  
extracted values  
default: /tmp/check\_nginx.results{.csv}

–noresult|-n)  
never write a results-file; CANNOT be used with calculated checks  
-t [rps|cps|dreq|dcon]  
default: off

```
 *** ) -> please dont use this option, not implemented or not

```

functional

Examples:

```
 just get all perfdata, url is default (/nginx_status)
 ./check_nginx_status --HOST www.example.com

 just get active connections perfdata
 ./check_nginx_status -H www.example.com -o

 check for plugin_checktime, error > 10ms (warning) or 50ms (error) 

```

and  
output  
only perfdata for that values  
./check\_nginx\_status -H [www.example.com](http://www.example.com) -u /status -w 10 -c 50 -o

```
 check for active connections, alert on > 500/2000 active 

```

connections  
./check\_nginx\_status -H [www.example.com](http://www.example.com) -u /status -t active\_conn  
-w  
500 -c 2000

```
 Check for accepts_errors
 ./check_nginx_status -H www.example.com -t accepts_err -w 1 -c 50

```

Performancedata:

```
 NginxStatus.Check OK | ac=1;acc=64; han=64; req=64; err=0; rpc=1;

```

rps=0; cps=0; dreq=1; dcon=1; read=0; writ=1; wait=0; ct=6ms;

```
     ac -> active connections
     acc -> totally accepted connections
     han -> totally handled connections
     req -> total requests
     err -> diff between acc - han, thus errors
     rpc -> requests per connection (req/han)
     rps -> requests per second (calculated) from last checkrun 

```

vs  
actual values  
cps → connections per (calculated) from last checkrun vs  
actual values  
dreq → request-delta from last checkrun vs actual values  
dcon → accepted-connection-delta from last checkrun vs  
actual  
values  
read → reading requests from clients  
writ → reading request body, processes request, or writes  
response to a client  
wait → keep-alive connections, actually it is ac - (read +  
writ)  
ct → checktime (connection time) for this check

```
 rpc/rps/dreq/dcon are always set to 0 if -n is used

```

Nginx-Config  
be sure to have your nginx compiled with Status-Module  
(–with-http\_stub\_status\_module), you might want to test  
your installation with nginx -V  
[Module ngx\_http\_stub\_status\_module](http://wiki.nginx.org/HttpStubStatusModule)

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

```

Requirements:

```
 nginx compiled with HttpStubStatusModule (see Nginx-Config)

 python 2.x
 this plugin is not yet compatible with python 3.x, but it should be
 easy to convert, using 2to3

```

Docs & Download:

```
     https://bitbucket.org/maresystem/dogtown-nagios-plugins

```

* * *

comments appreciated

regards,

mex

Posted at Nginx Forum:

> **[check\_nginx\_status - nagios-plugin to monitor nginx status](https://forum.nginx.org/read.php?2,240412,240412#msg-240412)**
>
> check\_nginx\_status is (yet another) Nagios-Plugin to monitor nginx status and alerts on various values, based on HttpStubStatus it also creates, based on the returned values, a csv to store data docs&downloads:...
