Page 2 of 2

Re: Nagios not cleaning up old switch configs from mrtg?

Posted: Wed Feb 09, 2022 12:10 pm
by aclauss
pbroste wrote: Thanks for following up, want to verify the cron job is going off without issue. We see that every 5 minutes the following cron is run:
find /etc/cron* -type f -exec grep -Eri "mrtg" -A 2 -B 2 {} \;
*/5 * * * * root LANG=C LC_ALL=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg --lock-file /var/lib/mrtg/mrtg.lock --confcache-file /var/lib/mrtg/mrtg.ok --user=nagios --group=nagios
Confirmed. And, the incoming emails are at 5 minute intervals as well.
[root@nagios ~]# find /etc/cron* -type f -exec grep -Eri "mrtg" -A 2 -B 2 {} \;
*/5 * * * * root LANG=C LC_ALL=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg --lock-file /var/lib/mrtg/mrtg.lock --confcache-file /var/lib/mrtg/mrtg.ok --user=nagios --group=nagios
nagios_snmp_emails.PNG
pbroste wrote: Want to verify the cron status:

Code: Select all

systemctl status crond
Ran this, but didn't get any actual logs out of it.
[root@nagios ~]# systemctl status crond
● crond.service - Command Scheduler
Loaded: loaded (/usr/lib/systemd/system/crond.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2022-01-29 13:20:33 CST; 1 weeks 3 days ago
Main PID: 671 (crond)
CGroup: /system.slice/crond.service
└─671 /usr/sbin/crond -n

Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.
pbroste wrote: Manual run through to verify:

Code: Select all

LANG=C LC_ALL=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg --lock-file /var/lib/mrtg/mrtg.lock --confcache-file /var/lib/mrtg/mrtg.ok --user=nagios --group=nagios --debug="cfg,snpo" --check
Quick look at the logs that pop-up for any interesting messages:

Code: Select all

LANG=C LC_ALL=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg --lock-file /var/lib/mrtg/mrtg.lock --confcache-file /var/lib/mrtg/mrtg.ok --user=nagios --group=nagios --debug="cfg,snpo" --check
Gave VERY long output that looked like it processed through the various .cfg files, including some HTML-type output. I tried to pipe it out to a file, or even just to "less", but it still forced all the output to console immediately.
pbroste wrote: Send over the copy of your mrtg.cfg:

Code: Select all

/etc/mrtg/mrtg.cfg
It isn't too long.
[root@nagios ~]# cat /etc/mrtg/mrtg.cfg
######################################################################
# Multi Router Traffic Grapher -- Example Configuration File
######################################################################
# This file is for use with mrtg-2.0
#
# Note:
#
# * Keywords must start at the begin of a line.
#
# * Lines which follow a keyword line which do start
# with a blank are appended to the keyword line
#
# * Empty Lines are ignored
#
# * Lines starting with a # sign are comments.

# Where should the logfiles, and webpages be created?

# Minimal mrtg.cfg
#--------------------

HtmlDir: /var/www/mrtg
ImageDir: /var/www/mrtg
LogFormat: rrdtool
LogDir: /var/lib/mrtg
ThreshDir: /var/lib/mrtg
WorkDir: /var/lib/mrtg
Forks: 4
EnableSnmpV3: yes

Include: conf.d/*.cfg

EnableSNMPv3: yes
[root@nagios ~]#

Re: Nagios not cleaning up old switch configs from mrtg?

Posted: Thu Feb 10, 2022 12:58 pm
by pbroste
Hello @aclauss

Thanks for following up with the details, want to verify that you are receiving a list of devices that are no longer available by running with '--check'. Want to verify permission issue.

Code: Select all

LANG=C LC_ALL=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg --lock-file /var/lib/mrtg/mrtg.lock --confcache-file /var/lib/mrtg/mrtg.ok --check
compare with this:

Code: Select all

LANG=C LC_ALL=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg --lock-file /var/lib/mrtg/mrtg.lock --confcache-file /var/lib/mrtg/mrtg.ok --user=nagios --group=nagios --check
Let's get the version:

Code: Select all

LANG=C LC_ALL=C /usr/bin/mrtg

Thanks,
Perry

Re: Nagios not cleaning up old switch configs from mrtg?

Posted: Mon Feb 14, 2022 11:33 am
by aclauss
pbroste wrote: Thanks for following up with the details, want to verify that you are receiving a list of devices that are no longer available by running with '--check'. Want to verify permission issue.

Code: Select all

LANG=C LC_ALL=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg --lock-file /var/lib/mrtg/mrtg.lock --confcache-file /var/lib/mrtg/mrtg.ok --check
compare with this:

Code: Select all

LANG=C LC_ALL=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg --lock-file /var/lib/mrtg/mrtg.lock --confcache-file /var/lib/mrtg/mrtg.ok --user=nagios --group=nagios --check
No errors (or any other output for that matter) from running either of those commands.
pbroste wrote: Let's get the version:

Code: Select all

LANG=C LC_ALL=C /usr/bin/mrtg
That gave mrtg-2.17.4

Complete output:

Code: Select all

[root@nagios ~]# LANG=C LC_ALL=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg --lock-file /var/lib/mrtg/mrtg.lock --confcache-file /var/lib/mrtg/mrtg.ok --check
[root@nagios ~]# LANG=C LC_ALL=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg --lock-file /var/lib/mrtg/mrtg.lock --confcache-file /var/lib/mrtg/mrtg.ok --user=nagios --group=nagios --check
[root@nagios ~]# LANG=C LC_ALL=C /usr/bin/mrtg
Usage: mrtg <config-file>

mrtg-2.17.4 - Multi Router Traffic Grapher

Copyright 1995-2006 by Tobias Oetiker
Licensed under the Gnu GPL.

If you want to know more about this tool, you might want
to read the docs. You can find everything on the
mrtg website:

http://oss.oetiker.ch/mrtg/

[root@nagios ~]#

Re: Nagios not cleaning up old switch configs from mrtg?

Posted: Tue Feb 15, 2022 11:41 am
by pbroste
Hello @aclauss

Thanks for following up with the info.

I brought this support forum case up during our team meeting and consulted. I discovered that the Nagios XI system will not automatically delete 'MRTG' graph perf data when removing hosts from the environment. The recommendation is to continue manually removing the 'MRTG' data by design. One could get clever and devise a script to check if the host file is listed in the Nagios configs. If it is not, it will automatically remove the 'MRTG' perfdata using a cronjob to perform the script assessment daily or weekly. I apologize for the long-drawn-out case analysis; today, I learned valuable tech knowledge.

Thanks,
Perry