Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

There are various instances where there are values I want to monitor with Nagios, and I don't care as much about the value itself, but rather how it compares to the previous value.

For instance, I wrote one to check the fail counters in OpenVZ. In this case, I didn't care about the value that much, but rather I cared if the value increased. Another example might be switch ports, I would be most interested to get alerted about the change of state of a port (Although perhaps a trap would be better for this one).

For my OpenVZ script, I used a temp file, but I am wondering if there is a better way? Maybe Nagios has some variables that plugins (check scripts) can access that are persistent across checks?

share|improve this question
up vote 1 down vote accepted

I don't think you will be able to do this directly with Nagios but what you can do is use MRTG (or similar) logging to rrdtool databases, which can then be read by a suitable Nagios plugin. e.g. I use this method to monitor DNS queries per minute.

Alternatively, have a plugin compare the current value with one previously saved, with the latest value then being saved for the next call.

share|improve this answer
Between your rrd comment and Richard's that just reminded me that I wrote a script that used rrd before with Nagios, because I use n2rrd for graphing. The script looks for growth in Exchange SMTP queues. I had totally forgot I wrote this :-P – Kyle Brandt Mar 19 '10 at 12:01
I use a combination of Nagios for alerts and MRTG to watch trends. In fact flat lines in MRTG are of no interest they just show that it is all business as usual, it is the movement that is important. – Richard Holloway Mar 19 '10 at 12:10
Thanks Kyle. I'll see if I can use what you have there to improve my own scripts. – John Gardeniers Mar 19 '10 at 12:24
Let me know if you see something wrong with it :-P – Kyle Brandt Mar 19 '10 at 15:32

If you just want to alert for an increase, this is what Nagios does already, just set your threshold to be a little bit higher than the current value, then you will be alerted when the value increased.

Or do you mean you want to monitor the rate of change, so a small upward trend is okay, but a sudden movement sets of an alarm.

Nagios only allows you watch for changes and not the rate of change but you could write your monitor script to report the rate of change, which will be 0 for no change and a value for some change. Then you can watch for sudden movements by setting the thresholds accordingly.

There is an example in perl here for monitoring processes. This example is a bit over my head, so not sure if it is what you are looking for.

share|improve this answer

If you don't mind having another daemon on the monitored machines, you might want to look at Munin, which plots the RRD data output from Nagios over time. It's very easy to set up and has a lot of stats right out of the box; additional stats are straightforward to implement via custom plugins.

share|improve this answer

i have several checks that rely on the change of a count for triggering warning and critical conditions as opposed to an absolute count, and i use temp files for the persistency.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.