Page 1 of 1
MRTG Config
Posted: Sun Oct 27, 2019 3:34 am
by KOUMNI
Hello,
I want to monitor my switch using MRTG, but something is not well configured, I followed some of the topics for the error that I have which is : "check_mrtgtraf: Unable to open MRTG log file "
knowing that /var/www/mrtg contains some interface logs
I read in some forums that /var/lib/mrtg/ must contain the log file that nagios reads, but in my case it contains only cfg files
can you guys help me through this config
Re: MRTG Config
Posted: Tue Oct 29, 2019 2:40 pm
by benjaminsmith
Hello
@koumni,
Have you checked permissions on that directory to make sure it is writable/accessible by the nagios account on the server? Please post the output to the following commands.
Code: Select all
ls -ld /var/lib/mrtg
ls -l /var/lib/mrtg
Re: MRTG Config
Posted: Tue Oct 29, 2019 2:41 pm
by cdienger
I would also look at the /etc/mrtg/mrtg.cfg file which will have information about the log location and format.
Re: MRTG Config
Posted: Thu Oct 31, 2019 8:47 am
by KOUMNI
benjaminsmith wrote:Hello
@koumni,
Have you checked permissions on that directory to make sure it is writable/accessible by the nagios account on the server? Please post the output to the following commands.
Code: Select all
ls -ld /var/lib/mrtg
ls -l /var/lib/mrtg
Code: Select all
nagios@sn-srv-nagios:~$ ls -ld /var/lib/mrtg
drwxrwxrwx 2 nagios nagios 12288 Oct 27 15:04 /var/lib/mrtg
Re: MRTG Config
Posted: Thu Oct 31, 2019 8:52 am
by KOUMNI
cdienger wrote:I would also look at the /etc/mrtg/mrtg.cfg file which will have information about the log location and format.
Here it is
Re: MRTG Config
Posted: Thu Oct 31, 2019 9:10 am
by tgriep
Can you post the Nagios configuration you are using for the Port 1 Bandwidth Usage check?
Did you setup a cron job to run the MRTG application which gathers the Bandwidth information the check_mrtgtraf plugin needs to calculate the bandwidth?
Check this link for instructions for MRTG.
https://oss.oetiker.ch/mrtg/doc/mrtg-unix-guide.en.html
If you run the following as root, it will run the MRTG application in debug mode which you can use to troubleshoot the MRTG application.
Re: MRTG Config
Posted: Sun Nov 03, 2019 6:00 am
by KOUMNI
tgriep wrote:Can you post the Nagios configuration you are using for the Port 1 Bandwidth Usage check?
Did you setup a cron job to run the MRTG application which gathers the Bandwidth information the check_mrtgtraf plugin needs to calculate the bandwidth?
Check this link for instructions for MRTG.
https://oss.oetiker.ch/mrtg/doc/mrtg-unix-guide.en.html
If you run the following as root, it will run the MRTG application in debug mode which you can use to troubleshoot the MRTG application.
This is the service conf
Code: Select all
# Monitor bandwidth via MRTG logs
define service {
use generic-service ; Inherit values from a template
host_name HP-DATA-CORE
service_description Port 1 Bandwidth Usage
check_command check_local_mrtgtraf!/var/lib/mrtg/172.20.232.1_1.log!AVG!1000000,1000000!5000000,5000000!10
}
this the command conf
Code: Select all
define command {
command_name check_local_mrtgtraf
command_line $USER1$/check_mrtgtraf -F $ARG1$ -a $ARG2$ -w $ARG3$ -c $ARG4$ -e $ARG5$
}
And this the crontab lines
Code: Select all
*/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
Re: MRTG Config
Posted: Mon Nov 04, 2019 9:31 am
by tgriep
Your Nagios check is setup to use this file to gather the Bandwidth but is does not exist on your system.
The closest file I saw in the ls output is this named this.
Is this the MRTG log file you should be using for that check?
If not, you will have to re-run the cfgmaker command to create a new entry for that interface and then the plugin will find the file.
Else, edit the check and remove the _1 from the filename.