Page 1 of 1

check_mrtgtraf: Unable to open MRTG log file

Posted: Thu Oct 30, 2014 10:03 am
by agarcia9
Hi!

Sorry, I shouldn't probably open a new topic but I have read a lot about this error in this and other forums and I'm still stuck in the same error.

the only thing I could do was with this:

http://bigunix.blogspot.com/2009/07/how ... g-and.html

the problem is that I am very new to centos and I do not know if I've missed some things. After doing everything that tutorial said nothing happened in nagios still the same problem of unable to open file mrtg. Something I've noticed is that the log file is not generated after configured mrtg. In / var / lib / mrtg / I only mrtg.ok. file

I decided to go to the web interface by 10.0.5.1/mrtg mrtg and get this error:

Forbidden

You don 't have permission to access / mrtg on this server.

I'm using Nagios 4.0.7 in centos 6.5

Here I attached some outputs that users have asked for help in the forums.

1) ls -lad /etc/mrtg/
drwxr-xr-x. 2 root root 4096 Oct 18 12:03 /etc/mrtg/

2) ls -la /etc/mrtg/
total 40
drwxr-xr-x. 2 root root 4096 Oct 18 12:03 .
drwxr-xr-x. 67 root root 4096 Oct 24 12:30 ..
-r-xr-xr-x. 1 nagios nagios 29671 Oct 28 07:14 mrtg.cfg
-rw-r--r--. 1 root root 0 Oct 18 12:03 mymrtg.cfg_l

3) ls -la /var/lib/mrtg/
total 8
drwxrwxrwx. 2 nagios nagios 4096 Oct 18 11:45 .
drwxr-xr-x. 20 root root 4096 Oct 18 11:44 ..
-rw-r--r--. 1 root root 0 Oct 30 06:00 mrtg.ok

Thanks in advance, I find myself desperate for not being able resolve!

Re: check_mrtgtraf: Unable to open MRTG log file

Posted: Thu Oct 30, 2014 8:56 pm
by lmiltchev
Run the following command and show us the output:

Code: Select all

cat  /etc/httpd/conf.d/mrtg.conf

Re: check_mrtgtraf: Unable to open MRTG log file

Posted: Fri Oct 31, 2014 2:48 pm
by agarcia9
cat /etc/httpd/conf.d/mrtg.conf
#
# This configuration file maps the mrtg output (generated daily)
# into the URL space. By default these results are only accessible
# from the local host.
#
Alias /mrtg /var/www/mrtg

<Location /mrtg>
Order deny,allow
Deny from all
Allow from 127.0.0.1
Allow from ::1
# Allow from .example.com
</Location>

Re: check_mrtgtraf: Unable to open MRTG log file

Posted: Mon Nov 03, 2014 4:19 pm
by abrist
agarcia9 wrote:Deny from all
Allow from 127.0.0.1
Allow from ::1
My guess would be that the page is configured to only be accessed by localhost. Change the vhost location config to:

Code: Select all

<Location /mrtg>
Order allow,deny
Allow from <your workstation ip here>
Allow from 127.0.0.1
Allow from ::1
# Allow from .example.com
</Location>

Re: check_mrtgtraf: Unable to open MRTG log file

Posted: Tue Nov 11, 2014 9:56 am
by agarcia9
Thanks abrist!
It Works now! but only when I go through http://myip/mrtg not by myip/nagios. In that page I have all the graphics from one switch. I tried to add another one with

cfgmaker --global 'WorkDir: /var/www/mrtg' --output /etc/mrtg/mrtg.cfg public@myip

and it seems that mrtg replaces the information in the page with the new one, so I can never see my two switches. I was also looking for the log file to attach it to nagios and can not find it.

thanks!

Re: check_mrtgtraf: Unable to open MRTG log file

Posted: Wed Nov 12, 2014 5:57 pm
by abrist
Well, the vhost config is for /mrtg, not /nagios. What do you need to display in /nagios? I am a bit confused about this one?

Re: check_mrtgtraf: Unable to open MRTG log file

Posted: Thu Nov 13, 2014 7:57 am
by agarcia9
All I need is show in nagios one port Bandwidth usage of each swtich I have in my network. The main problem was that I couldn't get into myip/mrtg because of permissions, I've solved that. Now, I'm still facing with the problem with mrtg + nagios because when I'm in my nagios page I got a message in the service section:

Switch core:
Port 1 Bandwidth Usage UNKNOWN 11-13-2014 02:36:46 26d 6h 17m 46s 3/3 check_mrtgtraf: Unable to open MRTG log file

now the problem is the log file, I can't find it! if I visit my mrtg page (10.0.0.5/mrtg) I can see all the graphics corresponding to all the active ports of just one switch.
In nagios, I know that I can see just one port Bandwidth usage, for example, Interface fastethernet 0/24 it's fine for me but I can not find the log file for that port and attach it to nagios.

Thanks!

Re: check_mrtgtraf: Unable to open MRTG log file

Posted: Thu Nov 13, 2014 5:57 pm
by sreinhardt
It sounds like cfgmaker is overwriting your mrtg config and making it so that you can only view one at a time. If you installed mrtg from an rpm or repository, try the following to get your version. It is very possible we just need to modify the main config to read from a directory instead of individual config, then have your cfgmaker output to per device files.

rpm -qa | grep mrtg

Also if you could take a copy of your current mrtg.cfg, run cfgmaker as you have, and take another copy of it. Please post them both here so we can see the differences.

Re: check_mrtgtraf: Unable to open MRTG log file

Posted: Wed Nov 26, 2014 5:54 pm
by agarcia9
Thanks, sreinhardt!

I could solve the problem!

for those who are going through the same situation, here I tell you what I did:

just add the next router/switch followed with a space. Ex:

cfgmaker --global 'WorkDir: /var/www/mrtg' --output /etc/mrtg/mrtg.cfg [email protected] [email protected] [email protected]

and then:

indexmaker --output=/var/www/mrtg/index.html /etc/mrtg/mrtg.cfg
//for creating the web page with all switches informations together.

then I went to /usr/local/nagios/etc/objects/swtich and then modify the dir in the check command to:

check_command check_local_mrtgtraf!/var/www/mrtg/10.0.0.1_24.log!AVG!1000000,1000000!5000000,5000000!10 for port 24!

and so on with the next switches!

finally... Service nagios restart and that's it!

now you can go to Nagios and see all your switches with the service of mrtg up!

and also you can go to de mrtg page (x.x.x.x/mrtg) and see all the graphs


Thanks guys for all your helps!

Re: check_mrtgtraf: Unable to open MRTG log file

Posted: Mon Dec 01, 2014 12:00 pm
by tmcdonald
Glad things are working for you, and thanks for the writeup on the fix!

I'll be closing this thread now, but feel free to open another if you need anything in the future.