check_mrtgtraf: Unable to open MRTG log file

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
agarcia9
Posts: 5
Joined: Mon Oct 20, 2014 10:35 am

check_mrtgtraf: Unable to open MRTG log file

Post 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!
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: check_mrtgtraf: Unable to open MRTG log file

Post by lmiltchev »

Run the following command and show us the output:

Code: Select all

cat  /etc/httpd/conf.d/mrtg.conf
Be sure to check out our Knowledgebase for helpful articles and solutions!
agarcia9
Posts: 5
Joined: Mon Oct 20, 2014 10:35 am

Re: check_mrtgtraf: Unable to open MRTG log file

Post 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>
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: check_mrtgtraf: Unable to open MRTG log file

Post 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>
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
agarcia9
Posts: 5
Joined: Mon Oct 20, 2014 10:35 am

Re: check_mrtgtraf: Unable to open MRTG log file

Post 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!
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: check_mrtgtraf: Unable to open MRTG log file

Post 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?
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
agarcia9
Posts: 5
Joined: Mon Oct 20, 2014 10:35 am

Re: check_mrtgtraf: Unable to open MRTG log file

Post 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!
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: check_mrtgtraf: Unable to open MRTG log file

Post 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.
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
agarcia9
Posts: 5
Joined: Mon Oct 20, 2014 10:35 am

Re: check_mrtgtraf: Unable to open MRTG log file

Post 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 public@10.0.0.1 public@10.0.0.2 public@10.0.0.254

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!
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: check_mrtgtraf: Unable to open MRTG log file

Post 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.
Former Nagios employee
Locked