Page 1 of 3

how to configure MRTG for multiple nodes

Posted: Sun Sep 22, 2013 10:24 am
by barry1946
I have installed nagios and mrtg on centos 6.4 .
for MRTG I used this instruction for creating graphs:
cfgmaker --global 'WorkDir: /var/www/html/mymrtg' --output /etc/mrtg/mymrtg.cfg public@routerip-1
# indexmaker --output=/var/www/html/mymrtg/index.html /etc/mrtg/mymrtg.cfg

when I add another node IP with
cfgmaker --global 'WorkDir: /var/www/html/mymrtg' --output /etc/mrtg/mymrtg.cfg public@routerip-2

the http://hostip/mrtg just shows the last node graph
I wanna have the graph for all of them so what is the instruction to create graph with mrtg for multiple network elements?
TX

Re: how to configure MRTG for multiple nodes

Posted: Mon Sep 23, 2013 10:21 am
by sreinhardt
This sounds like a question best posed to the mrtg community. If you are having issues with a nagios portion of this, we would be happy to help!

Re: how to configure MRTG for multiple nodes

Posted: Mon Sep 23, 2013 1:29 pm
by barry1946
ok I solved this issue and mrtg is working properly but in nagios I have the error :check_mrtgtraf unable to open log file


logfile is in /var/www/mrtg
in services.cfg(all of my services are here) the address of logfile is correct
I recive this mail in root :
From [email protected] Sun Oct 7 04:00:02 2012
Return-Path: <[email protected]>
X-Original-To: root
Delivered-To: [email protected]
Received: by nagios.localdomain (Postfix, from userid 0)
id 831671406E5; Sun, 7 Oct 2012 04:00:02 +0330 (IRST)
From: [email protected] (Cron Daemon)
To: [email protected]
Subject: Cron <root@nagios> LANG=C LC_ALL=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg --lock-file /var/lock/mrtg/mrtg_l --confcache-file /var/lib/mrtg/mrtg.ok
[root@nagios cron.d]# tail /var/spool/mail/root | less
X-Cron-Env: <HOME=/root>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=root>
X-Cron-Env: <USER=root>
Message-Id: <[email protected]>
Date: Mon, 23 Sep 2013 21:08:01 +0330 (IRST)

2013-09-23 21:08:01 -- Started mrtg with config '/etc/mrtg/mrtg.cfg'
2013-09-23 21:08:22 -- ERROR: writing /etc/mrtg/mrtg.ok.ok: Permission denied at /usr/bin/../lib64/mrtg2/MRTG_lib.pm line 1580.

and this one sometimes:

2012-10-07 03:58:01, Rateup WARNING: /usr/bin/rateup could not read the primary log file for 192.168.20.115_902
2012-10-07 03:58:01, Rateup WARNING: /usr/bin/rateup The backup log file for 192.168.20.115_902 was invalid as well
2012-10-07 03:58:01, Rateup WARNING: /usr/bin/rateup Can't remove 192.168.20.115_902.old updating log file

previously I solved it (one of post) in a test server but now on the production server it is not working.
I need urgent help if possible
TX

Re: how to configure MRTG for multiple nodes

Posted: Mon Sep 23, 2013 3:36 pm
by abrist
Looks like a permissions problem. What is the output of:

Code: Select all

ls -lad /etc/mrtg/
ls -la /etc/mrtg/

Re: how to configure MRTG for multiple nodes

Posted: Tue Sep 24, 2013 1:07 am
by barry1946
Tx for taking time , I really appreciate your help.

[root@nagios mrtg]# ls -lad /etc/mrtg/
drwxr-xr-x. 2 root root 4096 Sep 24 09:24 /etc/mrtg/


[root@nagios mrtg]# ls -la /etc/mrtg/
total 1336
drwxr-xr-x. 2 root root 4096 Sep 24 09:24 .
drwxr-xr-x. 105 root root 12288 Sep 23 21:27 ..
-rwxrwxr-x. 1 root root 1347684 Sep 23 20:15 mrtg.cfg
-rw-r--r--. 1 root root 0 Sep 23 20:20 mrtg.ok

Re: how to configure MRTG for multiple nodes

Posted: Tue Sep 24, 2013 10:16 am
by abrist
mrtg.cfg needs to be writable by nagios, and most likely accessible to apache:

Code: Select all

chown nagios:nagios /etc/mrtg/mrtg.cfg

Re: how to configure MRTG for multiple nodes

Posted: Tue Sep 24, 2013 11:16 am
by barry1946
I did ,no deference, still the error is there
also for test ,in /var/www/mrtg where the logs are there I changed the .log files owner to nagios but it changes to root automatically.
this is the way i created the config files (Just in Case)
1)cfgmaker --global 'WorkDir: /var/www/mrtg' --output /tmp/server1.cfg [email protected]
cfgmaker --global 'WorkDir: /var/www/mrtg' --output /tmp/server2.cfg [email protected]


2)cat /tmp/server{1,2}.cfg >> /etc/mrtg/mrtg.cfg

3)indexmaker /etc/mrtg/mrtg.cfg > /var/www/mrtg/index.html

the MRTG Graph is working Properly but the plugin doesnot work with error:check_mrtgtraf unable to open log file.

Re: how to configure MRTG for multiple nodes

Posted: Tue Sep 24, 2013 2:31 pm
by abrist
What are the permissions on your mrtg log files:

Code: Select all

ls -la /var/lib/mrtg/

Re: how to configure MRTG for multiple nodes

Posted: Tue Sep 24, 2013 3:34 pm
by barry1946
my log files are in /var/www/mrtg I changed it to nagios.nagios but it didnt help .
as I told for test I also changed all of the files /var/www/mrtg includes to nagios.nagios but the .log file keeps on returning to root.root permission.

Re: how to configure MRTG for multiple nodes

Posted: Tue Sep 24, 2013 3:41 pm
by abrist
hmmmm. They should not be returning to root:root unless they are being overwritten. You may want to actually use apache:nagios so that apache spawned processes can access the mrtg logs as well.

How quickly do the permissions on logs change back to root:root?