HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials

HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials (http://www.howtoforge.com/forums/index.php)
-   Installation/Configuration (http://www.howtoforge.com/forums/forumdisplay.php?f=4)
-   -   check_mrtgtraf: Unable to open MRTG log file (http://www.howtoforge.com/forums/showthread.php?t=48484)

gads 2nd September 2010 08:18

check_mrtgtraf: Unable to open MRTG log file
 
hi, I have installed nagios on centOS and I monitor switch but the Port1 Bandwidth Usage has this error "check_mrtgtraf: Unable to open MRTG log file ". I had already installed mrtg but it has the same error.
do anyone can help me about this problem? thanks in advance...

here is the script of my switch.cfg:

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

Mark_NL 2nd September 2010 09:10

Code:

ls -al /var/lib/mrtg/192.168.1.253_1.log
Code:

ps flax | grep nagios

gads 2nd September 2010 10:16

thanks for the reply Mark_NL, when I try the code you gave this is the result:

[root@localhost ~]# ls -al /var/lib/mrtg/192.168.1.253_1.log
ls: /var/lib/mrtg/192.168.1.253_1.log: No such file or directory
[root@localhost ~]# ps flax | grep nagios
0 0 18909 12276 17 0 3916 664 stext S+ pts/0 0:00 | \_ grep nagios
1 100 2860 1 18 0 6780 484 335550 Ss ? 0:00 /usr/sbin/ndo2db -c /etc/nagios/ndo2db.cfg
1 100 16191 2860 15 0 6780 1268 - S ? 0:01 \_ /usr/sbin/ndo2db -c /etc/nagios/ndo2db.cfg
1 100 16188 1 15 0 13716 984 stext Ssl ? 0:00 /usr/bin/nagios -d /etc/nagios/nagios.cfg

I wonder what is 192.168.1.253_1.log because when i go to /var/lib/mrtg/ directory, it is not there? what should i do about this?

thanks in advance..

Mark_NL 2nd September 2010 10:28

what IS in that mrtg dir?

Code:

ls -al /var/lib/mrtg/

kheimbuch 2nd September 2010 17:52

Hey Mark I am having the same problem as Gads. The only file I have in the /var/lib/mrtg/ directory is:

_etc_mrtg.cfg

gads 3rd September 2010 04:22

hi Mark, thanks for the reply, sorry for the late response... here is the result of the command " ls -al /var/lib/mrtg/ " :

[root@localhost ~]# ls -al /var/lib/mrtg/
total 12
drwxr-xr-x 2 root root 4096 Jan 10 2007 .
drwxrwxr-x 22 apache nagios 4096 Sep 1 13:21 ..
-rw-r--r-- 1 nagios nagios 0 Sep 3 10:15 mrtg.ok
[root@localhost ~]#

what should I do next? thanks in advance...

falko 3rd September 2010 15:26

Can you try
Code:

chown nagios:nagios /var/lib/mrtg/
?

kheimbuch 3rd September 2010 20:32

Nothing for me. Still the same error. I had even tried creating the file itself and giving nagios full access to it.

falko 4th September 2010 12:38

Does a
Code:

chmod 777 /var/lib/mrtg/
work?

gads 6th September 2010 11:49

hi, i have solved this problem, this is the things that i did:

Install MRTG:
To monitor bandwidth usages of router/switch you must have mrtg installed on system. Before installation please make sure you have install gd, libpng, zlib packages.

1. Download MRTG using yum install mrtg

2. Now you need not to create mrtg configuration file. Use cfgmaker.
cfgmaker --global 'WorkDir: /var/www/html/mymrtg' --global 'Options[_]: bits,growright' --output /etc/httpd/conf/mrtg.cfg public@<ip address of the switch>
6. Go to respective location and make sure that above command has created respective files.
cd /var/www/html/mrtg;
ls -al /etc/httpd/conf/mrtg.cfg

7. Run this command to update mrtg log file.
env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg


10. Set cron to run above command every 5 minute.
crontab -e

11. insert the code below and save,
*/5 * * * * /usr/bin/env LANG=C /usr/bin/mrtg /etc/mrtg/mymrtg.cfg –logging /var/log/mrtg.log
*/5 * * * * /usr/bin/env LANG=C /usr/bin/mrtg /etc/httpd/conf/mrtg.cfg --logging /var/log/mrtg.log

12. Restart cron service.
/etc/init.d/crond restart

13. Confirm that it is been configured.
http://localhost/mymrtg/{name of html file}

Actually when you run mrtg command it searches for respective router community collects all data from router. Accordingly it creates log file. Like in my case it has found port 2 running on router and hence created file 172.17.42.22_2.log, 172.17.42.22_2.html. So I can access my graph through this link,
http://localhost/mymrtg/<ip address of the switch>_2.html

Procedure to monitor Bandwidth Usages in Nagios:
1. Default installation directory of nagios is /usr/local/nagios/.

2. Open switch.cfg file
nano /etc/nagios/objects/switch.cfg

3. Make changes according to your router specifications. Like,
define host{
use generic-switch
host_name Router_1
alias Router 1
address 172.17.42.22
hostgroups switches
}
4. You can also set PING, Uptime, Ports Link Status etc.
define service{
use generic-service ; Inherit values from a template
host_name Router_1 ; The name of the host the service is associated with
service_description PING ; The service description
check_command check_ping!200.0,20%!600.0,60% ; The command used to monitor the service
normal_check_interval 5 ; Check the service every 5 minutes under normal conditions
retry_check_interval 1 ; Re-check the service every minute until its final/hard state is determined
}

define service{
use generic-service ; Inherit values from a template
host_name Router_1
service_description Uptime
check_command check_snmp!-C public -o sysUpTime.0 -H 172.17.42.22
}

define service{
use generic-service ; Inherit values from a template
host_name Router_1
service_description Port 2 Link Status
check_command check_snmp!-C public -o ifOperStatus.2 -r 1 -H 172.17.42.22
}

define service{
use generic-service ; Inherit values from a template
host_name Router_1
service_description Port 2 Bandwidth Usage
check_command check_local_mrtgtraf!/var/www/html/mymrtg/172.17.42.22_2.log!AVG!1000000,1000000!5000000,500 0000!10
}

5. Verify the configuration of nagios
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

6. Restart nagios service.
/etc/init.d/nagios restart


All times are GMT +2. The time now is 08:12.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.