How to integrate Nagios & MRTG

Israel Brewster israel at frontierflying.com
Tue Sep 5 18:44:33 CEST 2006


On Sep 4, 2006, at 5:39 AM, Ranjeet Kumar wrote:

> Hi,
>
>
> Can anyone give me idea how to integrate Nagios & MRTG?
>
>
>
> Thanks,
>
> Ranjeet
>
>
>
> The information contained in, or attached to, this e-mail, contains  
> confidential information and is intended solely for the use of the  
> individual or entity to whom they are addressed and is subject to  
> legal privilege. If you have received this e-mail in error you  
> should notify the sender immediately by reply e-mail, delete the  
> message from your system and notify your system manager. Please do  
> not copy it for any purpose, or disclose its contents to any other  
> person. The views or opinions presented in this e-mail are solely  
> those of the author and do not necessarily represent those of the  
> company. The recipient should check this e-mail and any attachments  
> for the presence of viruses. The company accepts no liability for  
> any damage caused, directly or indirectly, by any virus transmitted  
> in this email.
>
> www.aztecsoft.com
> ---------------------------------------------------------------------- 
> ---
> Using Tomcat but need to do more? Need to support web services,  
> security?
> Get stuff done quickly with pre-integrated technology to make your  
> job easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache  
> Geronimo
> http://sel.as-us.falkag.net/sel? 
> cmd=lnk&kid=120709&bid=263057&dat=121642______________________________ 
> _________________
> Nagios-users mailing list
> Nagios-users at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/nagios-users
> ::: Please include Nagios version, plugin version (-v) and OS when  
> reporting any issue.
> ::: Messages without supporting info will risk being sent to /dev/null

I did the following, after setting up both nagios and MRTG  
separately. First, for each host that MRTG is monitoring, define one  
or more services in nagios (for example, if MRTG is monitoring the  
traffic on three ports of a router, you will need three services in  
Nagios). These services are then set up to use the check_mrtgtraf  
plugin. This plugin gives a result based on the traffic that MRTG is  
seeing. My check command for this is defined as follows:

define command{
         command_name    check_mrtgtraf
         command_line    $USER1$/check_mrtgtraf -F /usr/local/mrtg-2/ 
share/mrtg2/$ARG1$.log -w $ARG2$ -c $ARG3$
         }

where the arguments are the name of the log file MRTG creates for the  
device being monitored, the traffic level at which to give a warning  
status, and the traffic level at which to give a critical status (see  
check_mrtgtraf --help for more info). Depending on how you have this  
set up,  you should be able to simplify the command somewhat by using  
the $HOSTADDRESS$ macro. The path to the log files will, of course,  
depend on your MRTG setup. To link the MRTG graphs in to the  
services, I simply used a serviceextinfo declaration for each  
service, and defined the notes_url property as the webpage that MRTG  
creates with the graph for the device. In my case, I put in a  
separate definition for each port pointing to the detail webpage for  
that port, you could, of course, choose to simply make one definition  
pointing to the summary webpage.

This may not be the most "integrated" approach possible, but it does  
give me the ability to have nagios send me notifications (or  
whatever) based on the traffic information gathered by MRTG, as well  
as giving me easy access to the MRTG graphs from within nagios. You  
could take a similar approach using the check_mrtg plugin instead, if  
you wanted nagios to pay attention to information other than what the  
check_mrtgtraf plugin returns, but I haven't looked into this. A  
couple of caveats:

1) the version of the check_mrtgtraf plugin I had, for some reason,  
wasn't coded to ever set the output status to 'OK'. I don't know if  
that was a bug in the source code in general, or just the version I  
got, but I had to add code to set the output to OK and recompile  
before it would work for me. Simple enough (at least if you know  
basic C programing).

2) The plug in, as written, reports and sets warning states based on  
the incoming and outgoing traffic separately, with independent  
warning/critical thresholds for each. This may well be what you want.  
In our case, however, I was more interested in the TOTAL traffic- if  
the traffic in is 128 kb/s and the traffic out is also 128 kb/s, then  
our 256 kb/s link is saturated, and I wanted nagios to return  
critical, even though neither the inbound or the outbound traffic is  
by itself enough to warrant a critical state. Again, I was easily  
able to modify the plugin source to do this, but this may not be  
desirable in other situations.

-------------------------------------
Israel Brewster
Computer Support Technician
Frontier Flying Service, Inc.
5245 Airport industrial Rd.
Fairbanks, AK 99709
--------------------------------------



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.monitoring-lists.org/archive/users/attachments/20060905/541758c8/attachment.html>
-------------- next part --------------
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
-------------- next part --------------
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null


More information about the Users mailing list