0

I'm monitoring router's Bandwidth Usage in Nagios using MRTG. So if I'll not do this command periodically

env LANG=C /usr/bin/mrtg /etc/mrtg/mymrtg.cfg

I'll will get this warning in Nagios GUI

MRTG data has expired (11 minutes old) 

and the question is: how I can make it automatic?

Andriy
  • 115
  • 2
  • 8

1 Answers1

1

You could automate running your mrtg command with cron. If your system has a directory named /etc/cron.d/, create a new one-line file there with the following contents:

*/5 * * * * root LANG=C /usr/bin/mrtg /etc/mrtg/mymrtg.cfg >/dev/null 2>&1

This tells cron to run your command every 5 minutes, as the user root, with LANG=C in the environment.

If your system does not have a /etc/cron.d/, then you'll have to insert the above crontab line in an alternate place, such as the root user's crontab. You can do that by running crontab -e as root. In that case, your crontab line should omit the username field (root), but will otherwise be the same as before:

*/5 * * * * LANG=C /usr/bin/mrtg /etc/mrtg/mymrtg.cfg >/dev/null 2>&1
Steven Monday
  • 13,019
  • 4
  • 35
  • 45