# Nagios check for nginx with separate metrics

**URL:** <https://www.ruby-forum.com/t/nagios-check-for-nginx-with-separate-metrics/237145>\
**Category:** NGINX\
**Created:** [October 27, 2013, 8:10pm UTC](https://www.ruby-forum.com/t/nagios-check-for-nginx-with-separate-metrics/237145 "2013-10-27T20:10:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![musicdenotation](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea666f/32.png) [@musicdenotation](https://www.ruby-forum.com/u/musicdenotation)\
**Post date:** [October 27, 2013, 8:10pm UTC](https://www.ruby-forum.com/t/nagios-check-for-nginx-with-separate-metrics/237145/1 "2013-10-27T20:10:22Z")

</div>

Hello,

I am trying to run a Nagios check for nginx (in Opsview Core) but I have  
a problem: All of the available (to my knowledge) nginx Nagios checks  
([http://exchange.nagios.org/directory/Plugins/Web-Servers/nginx/](http://exchange.nagios.org/directory/Plugins/Web-Servers/nginx/))  
produce comprehensive output which includes all “metrics” together,  
while I would want one that can output a selected metric at a time, by  
using a parameter, like “-m ,” in the following example:

./check\_nginx.sh -H localhost -P 80 -p /var/run -n nginx.pid -s  
nginx\_status -o /tmp -m current\_requests

- or -  
./check\_nginx.sh -H localhost -P 80 -p /var/run -n nginx.pid -s  
nginx\_status -o /tmp -m requests\_per\_second
- or -  
./check\_nginx.sh -H localhost -P 80 -p /var/run -n nginx.pid -s  
nginx\_status -o /tmp -m accesses  
etc.

Does anyone know whether such an nginx Nagios check exists (and where)  
or we would have to modify source code of one of these plugins to  
achieve the required behavior? (Frankly, I would be surprised if such a  
check does not exist yet, but I couldn’t find one on the Net, despite my  
searches.)

Output with a single metric at a time is important for use in  
server/network monitoring systems.

(I know that the issue is more related to Nagios, but I am hoping that  
someone on this mailing list has faced this problem with monitoring  
NGINX and can point to a solution.)

Thanks and regards,  
Nick

---

<div class="post-metadata">

**Author:** ![Nikolaos\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ecc23a/32.png) [@Nikolaos\_M](https://www.ruby-forum.com/u/Nikolaos_M)\
**Post date:** [November 13, 2013, 4:11pm UTC](https://www.ruby-forum.com/t/nagios-check-for-nginx-with-separate-metrics/237145/2 "2013-11-13T16:11:15Z")

</div>

On 27/10/2013 9:09 μμ, Nikolaos M. wrote:

> - or -  
> a check does not exist yet, but I couldn’t find one on the Net,  
> despite my searches.)
> 
> Output with a single metric at a time is important for use in  
> server/network monitoring systems.

Anyone? No NGINX Nagios users around?

Regards,  
Nick

---

<div class="post-metadata">

**Author:** ![Nikolaos\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ecc23a/32.png) [@Nikolaos\_M](https://www.ruby-forum.com/u/Nikolaos_M)\
**Post date:** [November 13, 2013, 11:01pm UTC](https://www.ruby-forum.com/t/nagios-check-for-nginx-with-separate-metrics/237145/3 "2013-11-13T23:01:27Z")

</div>

On Wed, Nov 13, 2013 at 05:10:25PM +0200, Nikolaos M. wrote:

> On 27/10/2013 9:09 μμ, Nikolaos M. wrote:

Hi there,

> > All of the available (to my knowledge) nginx Nagios checks

> > produce comprehensive output which includes all “metrics” together,

> > Output with a single metric at a time is important for use in  
> > server/network monitoring systems.

If _everyone_ who writes a checker provides multiple metrics at once,  
that  
kind of suggests that a single metric at a time isn’t all that  
important.

> > Does anyone know whether such an nginx Nagios check exists (and where)  
> > or we would have to modify source code of one of these plugins to  
> > achieve the required behavior?

I suspect you’re going to have to write your own – maybe from scratch,  
maybe a wrapper around one you like.

Presumably they all ask for a url where nginx serves “stub\_status”, and  
process the numbers returned. In your version, just ignore the numbers  
you don’t care about. (Or cache them and serve slightly-stale  
information,  
to avoid making the same request three times in succession.)

Good luck with it,

## f

Francis D. removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![Nikolaos\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ecc23a/32.png) [@Nikolaos\_M](https://www.ruby-forum.com/u/Nikolaos_M)\
**Post date:** [November 14, 2013, 12:04pm UTC](https://www.ruby-forum.com/t/nagios-check-for-nginx-with-separate-metrics/237145/4 "2013-11-14T12:04:17Z")

</div>

On 14/11/2013 12:00 πμ, Francis D. wrote:

> If_everyone_ who writes a checker provides multiple metrics at once, that  
> kind of suggests that a single metric at a time isn’t all that important.

I won’t disagree, you need to correlate metrics, but you cannot graph  
them as a function of time if you don’t log them separately.

> Presumably they all ask for a url where nginx serves “stub\_status”, and  
> process the numbers returned.

Right. That’s how they operate.

> In your version, just ignore the numbers you don’t care about. (Or cache them  
> and serve slightly-stale information,  
> to avoid making the same request three times in succession.)
> 
> Good luck with it,

I am still surprised, however, that I couldn’t find such a thing around,  
esp. since it’s standard in Apache Nagios checks!

I can (most probably) do it, but life is just not enough to find time to  
do everything by yourself! ☹

Thanks,  
Nick
