MRTG Config

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
KOUMNI
Posts: 5
Joined: Sun Oct 27, 2019 3:03 am

MRTG Config

Post 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
Attachments
MRTG.PNG
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: MRTG Config

Post 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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: MRTG Config

Post by cdienger »

I would also look at the /etc/mrtg/mrtg.cfg file which will have information about the log location and format.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
KOUMNI
Posts: 5
Joined: Sun Oct 27, 2019 3:03 am

Re: MRTG Config

Post 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
Attachments
ls-l.txt
ls -l /var/lib/mrtg
(9.63 KiB) Downloaded 163 times
KOUMNI
Posts: 5
Joined: Sun Oct 27, 2019 3:03 am

Re: MRTG Config

Post 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
Attachments
mrtg.cfg
(39.82 KiB) Downloaded 148 times
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: MRTG Config

Post 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.
Be sure to check out our Knowledgebase for helpful articles and solutions!
KOUMNI
Posts: 5
Joined: Sun Oct 27, 2019 3:03 am

Re: MRTG Config

Post 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
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: MRTG Config

Post by tgriep »

Your Nagios check is setup to use this file to gather the Bandwidth but is does not exist on your system.

Code: Select all

/var/lib/mrtg/172.20.232.1_1.log
The closest file I saw in the ls output is this named this.

Code: Select all

/var/lib/mrtg/172.20.232.1.log
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.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked