how to configure MRTG for multiple nodes

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.
barry1946
Posts: 32
Joined: Wed Aug 14, 2013 11:29 am

how to configure MRTG for multiple nodes

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

Re: how to configure MRTG for multiple nodes

Post 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!
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.
barry1946
Posts: 32
Joined: Wed Aug 14, 2013 11:29 am

Re: how to configure MRTG for multiple nodes

Post 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 root@nagios.localdomain Sun Oct 7 04:00:02 2012
Return-Path: <root@nagios.localdomain>
X-Original-To: root
Delivered-To: root@nagios.localdomain
Received: by nagios.localdomain (Postfix, from userid 0)
id 831671406E5; Sun, 7 Oct 2012 04:00:02 +0330 (IRST)
From: root@nagios.localdomain (Cron Daemon)
To: root@nagios.localdomain
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: <20130923173822.C66CC140726@nagios.localdomain>
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
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: how to configure MRTG for multiple nodes

Post by abrist »

Looks like a permissions problem. What is the output of:

Code: Select all

ls -lad /etc/mrtg/
ls -la /etc/mrtg/
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.
barry1946
Posts: 32
Joined: Wed Aug 14, 2013 11:29 am

Re: how to configure MRTG for multiple nodes

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

Re: how to configure MRTG for multiple nodes

Post 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
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.
barry1946
Posts: 32
Joined: Wed Aug 14, 2013 11:29 am

Re: how to configure MRTG for multiple nodes

Post 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 public@server1.example.com
cfgmaker --global 'WorkDir: /var/www/mrtg' --output /tmp/server2.cfg public@server2.example.com


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

Re: how to configure MRTG for multiple nodes

Post by abrist »

What are the permissions on your mrtg log files:

Code: Select all

ls -la /var/lib/mrtg/
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.
barry1946
Posts: 32
Joined: Wed Aug 14, 2013 11:29 am

Re: how to configure MRTG for multiple nodes

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

Re: how to configure MRTG for multiple nodes

Post 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?
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.
Locked