check_mrtgtraf: MRTG data has expired

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
Bone8Head
Posts: 106
Joined: Tue Nov 10, 2015 2:39 am

check_mrtgtraf: MRTG data has expired

Post by Bone8Head »

Hi,

I'm trying to monitor some switches with mrtg (on Centos 6.7), everything is ok but I have some problem with the cron task.

Code: Select all

MRTG data has expired (xxx days old)
my crontab -e is:

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

I got a lot of Mail in /var/spoon/mail/root:

Code: Select all

From: [email protected] (Cron Daemon)
To: [email protected]
Subject: Cron <root@nagioscorefx> /usr/bin/env LANG=C /usr/bin/mrtg /etc/mrtg/mymrtg.cfg –logging /var/log/mrtg.log
Content-Type: text/plain; charset=UTF-8
Auto-Submitted: auto-generated
X-Cron-Env: <LANG=it_IT.UTF-8>
X-Cron-Env: <SHELL=/bin/sh>
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: Thu,  5 May 2016 15:45:01 +0200 (CEST)

Use of uninitialized value $first in pattern match (m//) at /usr/bin/../lib64/mrtg2/MRTG_lib.pm line 611.
Use of uninitialized value $dir in concatenation (.) or string at /usr/bin/mrtg line 2531.
Use of uninitialized value $dir in concatenation (.) or string at /usr/bin/mrtg line 2549.
Use of uninitialized value $dir in concatenation (.) or string at /usr/bin/mrtg line 2565.
ERROR: "WorkDir" not specified in mrtg config file

From [email protected]  Thu May  5 15:50:02 2016
Return-Path: <[email protected]>
X-Original-To: root
Delivered-To: [email protected]
Received: by nagioscorefx.finance.com (Postfix, from userid 0)
        id 13A121014F7; Thu,  5 May 2016 15:50:02 +0200 (CEST)
From: [email protected] (Cron Daemon)
To: [email protected]
Subject: Cron <root@nagioscorefx> /usr/bin/env LANG=C /usr/bin/mrtg /etc/mrtg/mymrtg.cfg –logging /var/log/mrtg.log
Content-Type: text/plain; charset=UTF-8
Auto-Submitted: auto-generated
X-Cron-Env: <LANG=it_IT.UTF-8>
X-Cron-Env: <SHELL=/bin/sh>
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: Thu,  5 May 2016 15:50:02 +0200 (CEST)

Use of uninitialized value $first in pattern match (m//) at /usr/bin/../lib64/mrtg2/MRTG_lib.pm line 611.
Use of uninitialized value $dir in concatenation (.) or string at /usr/bin/mrtg line 2531.
Use of uninitialized value $dir in concatenation (.) or string at /usr/bin/mrtg line 2549.
Use of uninitialized value $dir in concatenation (.) or string at /usr/bin/mrtg line 2565.
ERROR: "WorkDir" not specified in mrtg config file
My Mrtg files (the .html files) are in this Directory: /var/www/html/mrgt.

For "create" the mrgt configuration files I used:

Code: Select all

cfgmaker --global 'WorkDir: /var/www/html/mrtg' --global 'Options[_]: bits,growright' --output /etc/httpd/conf/mrtg.cfg [email protected]
Anyone can help me out?

Thank you very much.
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: check_mrtgtraf: MRTG data has expired

Post by tgriep »

In your emails, the WorkDir says it is not in your /etc/mrtg/mymrtg.cfg file.
Try adding the following line to that file and see if the files in the WorkDir folder start to update.

Code: Select all

WorkDir: /var/www/html/mrtg
Be sure to check out our Knowledgebase for helpful articles and solutions!
Bone8Head
Posts: 106
Joined: Tue Nov 10, 2015 2:39 am

Re: check_mrtgtraf: MRTG data has expired

Post by Bone8Head »

tgriep wrote:In your emails, the WorkDir says it is not in your /etc/mrtg/mymrtg.cfg file.
Try adding the following line to that file and see if the files in the WorkDir folder start to update.

Code: Select all

WorkDir: /var/www/html/mrtg
Actually my mymrtg.cfg file is empty :cry:
But there is another file called mrtg.cfg with this code inside (I added the WorkDir):

Code: Select all

HtmlDir: /var/www/mrtg
ImageDir: /var/www/mrtg
LogDir: /var/lib/mrtg
ThreshDir: /var/lib/mrtg
WorkDir: /var/www/html/mrtg
#Target[r1]: 2:[email protected]
#MaxBytes[r1]: 1250000
#Title[r1]: Traffic Analysis
#PageTop[r1]: <H1>Stats for our Ethernet</H1>
Nothing changed. Maybe he is saearching for the mymrtg.cfg file anyway?
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: check_mrtgtraf: MRTG data has expired

Post by tgriep »

In your crontab file, you have 2 entries, you should delete the bad entry and that should fix the email errors.
Can you post how your check_mrtgtraf command is defined and also your service check that is generating the error.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Bone8Head
Posts: 106
Joined: Tue Nov 10, 2015 2:39 am

Re: check_mrtgtraf: MRTG data has expired

Post by Bone8Head »

tgriep wrote:In your crontab file, you have 2 entries, you should delete the bad entry and that should fix the email errors.
Can you post how your check_mrtgtraf command is defined and also your service check that is generating the error.

Code: Select all

# 'check_local_mrtgtraf' command definition
define command{
	command_name		check_local_mrtgtraf
	command_line		$USER1$/check_mrtgtraf -F $ARG1$ -a $ARG2$ -w $ARG3$ -c $ARG4$ -e $ARG5$
	}

Code: Select all

define service{
	use								  generic-service,srv-pnp	; Inherit values from a template
	host_name						  Switch - Allied Telesis 247
	service_description				  7° Porta Bandwidth - Server 230
	check_command					  check_local_mrtgtraf!/var/www/html/mrtg/192.168.50.247_7.log!AVG!1000000,1000000!5000000,5000000!10
	check_interval					  5
	retry_interval					  5
	max_check_attempts				  10
	check_period					  24x7
	notification_interval			  300
	notification_period				  24x7
	notification_options			  w,c,r
	servicegroups					  Switches	
	}
Bone8Head
Posts: 106
Joined: Tue Nov 10, 2015 2:39 am

Re: check_mrtgtraf: MRTG data has expired

Post by Bone8Head »

I think that I found the problem.
In another site I found that the mrgt can update only 1 Switch at time (I got 3 Switch to Monitor).

Code: Select all

The only thing I had to do was modify some of the file location paths. Since I am monitoring multiple switches I had to modify some things. 

Using the "env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg" command would not work for multiple switches. I had to change the output to look something like this "env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg_252.cfg". This was done for each switch so that I knew which output file to point the nagios check_mrtgtraf command to in the switch.cfg file.

I also had to make the appropriate change within the crontab file as well. Other wise it would not update that file and it would give the error "MRTG data has expired". 
Now I have to study how to make this actually work
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: check_mrtgtraf: MRTG data has expired

Post by tgriep »

MRTG can monitor multiple devices at once, all you would do is create separate config files for each device

What you would to is to add this line to your /etc/mrtg/mrtg.cfg file

Code: Select all

Include: conf.d/*.cfg
Then create this folder /etc/mrtg/conf.d and put your separate config files in there. One for each device.

Make sure your crontab is as follows.

Code: Select all

*/5 * * * * root LANG=C LC_ALL=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg
When MRTG runs, it will look on the /etc/mrtg/conf.d folder for any config files and then process them.

Are the log files showing up in this folder?

Code: Select all

/var/www/html/mrtg/
Be sure to check out our Knowledgebase for helpful articles and solutions!
Bone8Head
Posts: 106
Joined: Tue Nov 10, 2015 2:39 am

Re: check_mrtgtraf: MRTG data has expired

Post by Bone8Head »

tgriep wrote:Are the log files showing up in this folder?

Code: Select all

/var/www/html/mrtg/
Yes, all in the same Folder.

The problem is that with your configuration and cron task now no one of the 3 Switches is updating the mrtg.log files.
So I reused the old one:

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
Now I'll show you what I did:

1) I create the conf.d folder (/etc/mrtg/conf.d) with the 3 mrtg_247.cfg - 248 and 249 files.

2) Added in the mrt.cfg in /etc/mrgt the "Include: conf.d/*.cfg" line.

3) The 3 .cfg files in the conf.d folders are like that (only the Target is different from the 3 files):

Code: Select all

HtmlDir: /var/www/mrtg
ImageDir: /var/www/mrtg
LogDir: /var/lib/mrtg
ThreshDir: /var/lib/mrtg
WorkDir: /var/www/html/mrtg
Target[r1]: [email protected]
MaxBytes[r1]: 1250000
Title[r1]: Traffic Analysis
#PageTop[r1]: <H1>Stats for our Ethernet</H1>
4) I noticed that cron always updated the only Switch in /etc/httpd/conf/mrtg.cfg --->

Code: Select all

# Created by 
# /usr/bin/cfgmaker --global "WorkDir: /var/www/html/mrtg" --global "Options[_]: bits,growright" --output /etc/httpd/conf/mrtg.cfg [email protected]


### Global Config Options

#  for UNIX
# WorkDir: /home/http/mrtg

#  or for NT
# WorkDir: c:\mrtgdata

### Global Defaults

#  to get bits instead of bytes and graphs growing to the right
# Options[_]: growright, bits

EnableIPv6: no
WorkDir: /var/www/html/mrtg
Options[_]: bits,growright
Include: conf.d/*.cfg

######################################################################
# System: 
# Description: 48-Port Managed 10/100 Switch w/WebView
# Contact: 
# Location: 
######################################################################

### Interface 1 >> Descr: '' | Name: 'e1' | Ip: '' | Eth: '30-78-30-30-32-34-66-37-62-38-66-33-39-62' ###
Target[192.168.50.247_1]: 1:[email protected]:
SetEnv[192.168.50.247_1]: MRTG_INT_IP="" MRTG_INT_DESCR=""
MaxBytes[192.168.50.247_1]: 12500000
Title[192.168.50.247_1]: Traffic Analysis for 1 -- 
PageTop[192.168.50.247_1]: <h1>Traffic Analysis for 1 -- </h1>
		<div id="sysdetails">
etc...
5) So I create in /etc/httpd/conf another conf.d folder and added the include line in the mrtg.cfg file, but nothing changed again.

Actually I don't know what to do, I'm a little bit confused.
There are 2 mrtg.cfg files, one in /etc/httpd/conf and another one in /etc/mrgt
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: check_mrtgtraf: MRTG data has expired

Post by tgriep »

You should take a look at the MRTG web site for any guides / documents for the issues you are having.
http://oss.oetiker.ch/mrtg/doc/index.en.html
or
http://oss.oetiker.ch/mrtg/3party.en.html
I would need to see the full config files from all of the folders to help out in this issue.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked