Page 1 of 2

MRTG Issue w/ Nagios 4.0.6

Posted: Mon Oct 06, 2014 6:36 pm
by adamh0903
Ubuntu 14.04
Nagios 4.0.6

First let me say I have searched and researched this issue a lot and followed a lot of tutorials on fixes including one in this forum from a few days ago but nothing seems to fix my issue, there are so many links on the issue it should be an easy fix but I haven't been able to fix it yet. I think it is because I am missing a piece of the puzzle.

I have Nagios 4.0.6 up and running with nagiosgraph. My issue is with MRTG, I have it configured and working if I go to http://myserver/nagios/stats I am measuring data and I see graphs, but when I look at my hosts in nagios I see this


Port 1 Bandwidth Usage UNKNOWN 10-06-2014 19:22:25 0d 5h 37m 30s 3/3 check_mrtgtraf: Unable to open MRTG log file.



I know the issue is not being able to read my log file. My service definitions in switch.cfg is like this

# Monitor bandwidth via MRTG logs

define service{
use generic-service ; Inherit values from a template
hostgroup_name switches
service_description Port 1 Bandwidth Usage
check_command check_local_mrtgtraf!/var/lib/mrtg/10.42.0.7_1.log!AVG!1000000,1000000!5000000,5000000!10
}

There isnt a log file at /var/lib/mrtg/10.42.0.7_1.log so I know i am missing something. I just dont know enough about Linux / ubuntu to figure out where to look

thanks in advance everyone.

Re: MRTG Issue w/ Nagios 4.0.6

Posted: Tue Oct 07, 2014 11:56 am
by sreinhardt
This is generally caused when mrtg is either not logging to that location or is not able to pull bandwidth for that port. Do you have any files or folders in /var/lib/mrtg? What does your /etc/mrtg/mrtg.conf file look like?

Re: MRTG Issue w/ Nagios 4.0.6

Posted: Fri Oct 10, 2014 10:37 am
by adamh0903
The only file I have in /var/lib/mrtg is _usr_local_nagios_etc_mrtg.cfg


and my /etc/mrtg/mrtg.cfg file looks like this

Code: Select all

# Created by
# /usr/bin/cfgmaker --global WorkDir:/usr/local/nagios/share/stats --global "Options[_]: bits,growright" --output /etc/mrtg/mrtg.cfg [email protected]


### Global Config Options

#  for UNIX
# WorkDir: /home/http/mrtg

#  for Debian
WorkDir:/usr/loca/nagios/share/stats

#  or for NT
# WorkDir: c:\mrtgdata

### Global Defaults

#  to get bits instead of bytes and graphs growing to the right
# Options[_]: growright, bits

EnableIPv6: no
RunAsDaemon: Yes
Interval: 5
Options[_]: bits,growright
logdir: /var/log/mrtg

######################################################################
# System: yh0209hp8212zl
# Description: HP J9091A Switch 8212zl, revision K.15.13.0005, ROM K.15.30 (/ws/swbuildm/K_rel_laredo_qaoff/code/build/btm(swbuildm_K_rel_laredo_qaoff_rel_laredo)) (Formerly ProCurve)
# Contact:
# Location:
######################################################################


### Interface 1 >> Descr: 'A1' | Name: 'A1' | Ip: 'No Ip' | Eth: '2c-59-e5-2b-b2-ff' ###

Target[10.42.132.5_A1]: #A1:[email protected]:
SetEnv[10.42.132.5_A1]: MRTG_INT_IP="No Ip" MRTG_INT_DESCR="A1"
MaxBytes[10.42.132.5_A1]: 12500000
Title[10.42.132.5_A1]: Traffic Analysis for A1 -- yh0209hp8212zl
PageTop[10.42.132.5_A1]: <h1>Traffic Analysis for A1 -- yh0209hp8212zl</h1>
                <div id="sysdetails">
                        <table>
                                <tr>
                                        <td>System:</td>
                                        <td>yh0209hp8212zl in </td>
                                </tr>
                                <tr>
                                        <td>Maintainer:</td>
                                        <td></td>
                                </tr>
                                <tr>
                                        <td>Description:</td>
                                        <td>A1  </td>
                                </tr>
                                <tr>
                                        <td>ifType:</td>
                                        <td>ethernetCsmacd (6)</td>
"mrtg.cfg" 10722L, 255165C                                                                                                                 1,1           Top


Re: MRTG Issue w/ Nagios 4.0.6

Posted: Fri Oct 10, 2014 4:57 pm
by sreinhardt
OK for some reason your mrtg is set to log to a different directory. Let's check whats in /var/log/mrtg with:

Code: Select all

ls -lart /var/log/mrtg/

Re: MRTG Issue w/ Nagios 4.0.6

Posted: Fri Oct 10, 2014 4:59 pm
by Box293
This MRTG file looks cut off and does not look complete.

Re: MRTG Issue w/ Nagios 4.0.6

Posted: Fri Oct 10, 2014 5:49 pm
by adamh0903
the MRTG file is cut off i believe but it is very long, 15k rows before i stopped

here is the output

Code: Select all

root@DONETMON:/home/ahenderson# cd /
root@DONETMON:/# ls -lart /var/log/mrtg/
total 8
drwxr-x---  2 root adm    4096 May 19  2013 .
drwxrwxr-x 12 root syslog 4096 Oct 10 06:44 ..

Re: MRTG Issue w/ Nagios 4.0.6

Posted: Wed Oct 15, 2014 12:03 pm
by sreinhardt
Don't worry about the whole file, you got most if not all the important details with the snippet provided! :) I find the permissions on your /var/log/mrtg folder a little interesting. Do you know what user you have mrtg running via your cron? Most likely that user does not currently have create or write permissions based on what I see here.

Re: MRTG Issue w/ Nagios 4.0.6

Posted: Tue Oct 21, 2014 11:15 am
by adamh0903
how would I go back and tell what user is running the cron job?

Re: MRTG Issue w/ Nagios 4.0.6

Posted: Wed Oct 22, 2014 3:04 pm
by abrist
adamh0903 wrote:how would I go back and tell what user is running the cron job?

Code: Select all

cat /etc/cron.d/mrtg

Re: MRTG Issue w/ Nagios 4.0.6

Posted: Wed Feb 03, 2016 11:16 am
by xsaithanx
i have the same trouble, in my case root is the user wich run the cron job