Page 2 of 4
Re: Monitoring Network Bandwidth
Posted: Mon Mar 27, 2017 10:12 am
by rhonorio
Thanks a lot for your reply. The only problema I have, so far, is that I can't access that post you included as a context for the script...it shows a message saying "You are not authorised to read this forum."
Re: Monitoring Network Bandwidth
Posted: Mon Mar 27, 2017 11:30 am
by dwhitfield
Apologies for that. It's part of the Customer Forum. If you are a customer, please email
[email protected] with your forum username, and they can give you access.
Unfortunately, it's a 6-page forum thread, so copying and pasting all of the content isn't going to happen.
@BanditBBS is the user who wrote the script. Here's what he said in the post that contained the script:
Very ugly script, but here ya go!
Call it whatever you want, for this example, we'll go with "banditisawesome.sh".
Call it like this, ./banditisawesome.sh totalsize warn crit IP, for example: ./banditisawesome.sh 10000000000 80 90 10.197.0.1
Note: I did not try it in action actually using the $4 for IP. I was testing with your example output, but I think my code is good.
Example output:
WARNING - Total traffic above threshold - 80 | 'total'=80%;80;99;0;100 'inbound'=38%;;;0;100 'outbound'=42%;;;0;100
The script was written almost two years ago, so it may be dated. but I don't suspect a lot of changes in SNMP or bash. Also, for clarity, Bandit uses "Call" in two different ways in the quote. That may be obvious, but we have a lot of non-native English speakers here, so maybe that will help you. In the first "Call" he essentially means "Name".
It's possible there may be updates to the script at
http://www.bandits-home-on-the-web.com/nagios/ or
https://github.com/Bandits-Home
Re: Monitoring Network Bandwidth
Posted: Mon Apr 17, 2017 11:24 am
by rhonorio
Hi all.
I came back to this topic as I tried to monitor the traffic of the interfaces of a Cisco switch and it didn't work. I received support from Nagios, they recommended to run the wizard, but it didn't work. The agent didn't mention anything about writing my own plugin (it makes sense I don't have to do that).
He also mentioned I may have issues with mrtg. Can you help me find out if I do have issue with mrtg?
What info do you need me to include in this post?
Thanks in advance,
Rodrigo.
Re: Monitoring Network Bandwidth
Posted: Mon Apr 17, 2017 3:20 pm
by tgriep
If you ran the Network Switch / Router Wizard in Nagios XI but the interfaces are showing 0 bandwidth information, the following 2 links are possible solutions to fix the problem with MRTG.
https://support.nagios.com/kb/article.php?id=511
https://support.nagios.com/kb/article.php?id=512
Try those out and post if this resolved the issue for you.
Re: Monitoring Network Bandwidth
Posted: Tue Apr 18, 2017 8:21 am
by rhonorio
Thanks for your reply.
I ran the command suggested "LANG=C LC_ALL=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg" and it didn't give any error message. Anyways, Nagios is still showing 0Mpbs on each interface.
To add more information, I installed mrtg a couple of times, so maybe I messed ir up...
For example, if I follow the instructions I was given by Nagios support (via chat) I should run the following command (it also shows the output):
[root@localhost /]# /usr/local/mrtg-2/bin/mrtg /home/mrtg/cfg/mrtg.cfg
-----------------------------------------------------------------------
ERROR: Mrtg will most likely not work properly when the environment
variable LANG is set to UTF-8. Please run mrtg in an environment
where this is not the case. Try the following command to start:
env LANG=C /usr/local/mrtg-2/bin/mrtg /home/mrtg/cfg/mrtg.cfg
-----------------------------------------------------------------------
When I ran the command as suggested ("env LANG=C /usr/local/mrtg-2/bin/mrtg /home/mrtg/cfg/mrtg.cfg"), the output was this:
2017-04-18 10:20:35: ERROR: Creating templock /home/mrtg/cfg/mrtg.cfg_l_16340: No such file or directory at /usr/local/mrtg-2/bin/mrtg line 1961.
By the way, the link for the instructions Nagios support suggested is:
http://oss.oetiker.ch/mrtg/doc/mrtg-unix-guide.en.html
Re: Monitoring Network Bandwidth
Posted: Tue Apr 18, 2017 9:50 am
by tgriep
I would uninstall the copy from the
http://oss.oetiker.ch site and re-install it using the instructions below.
https://support.nagios.com/kb/article.php?id=511
The cron job that collects the bandwidth information is not using that path / config files so it will not work.
After that, run the following commands and is should printout the version of MRTG "mrtg-2.17.4 - Multi Router Traffic Grapher" and then run the configuration files to generate the bandwidth info.
Code: Select all
LANG=C LC_ALL=C /usr/bin/mrtg
LANG=C LC_ALL=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg
Post any errors that are generated.
Re: Monitoring Network Bandwidth
Posted: Tue Apr 18, 2017 11:48 am
by rhonorio
Here are the outputs:
[root@localhost mrtg]# 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@localhost mrtg]# LANG=C LC_ALL=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg
ERROR: unable to open config file: /etc/mrtg/mrtg.cfg
**********************
I uninstalled and then re-installed mrtg, after that i rebooted the server...
Re: Monitoring Network Bandwidth
Posted: Tue Apr 18, 2017 12:58 pm
by tgriep
If the file /etc/mrtg/mrtg.cfg does not exist on your system, create it and add the following to the file.
Code: Select all
######################################################################
# 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
Save the file and run the following to setup the permissions.
Code: Select all
chown apache.nagios /etc/mrtg/mrtg.cfg
chmod 775 /etc/mrtg/mrtg.cfg
After that, run this command and see if the error is resolved.
Code: Select all
LANG=C LC_ALL=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg
After 15 minutes, the Network Bandwidth information should start to populate with data, is that happening now?
Re: Monitoring Network Bandwidth
Posted: Tue Apr 18, 2017 2:22 pm
by rhonorio
Unfortunately, it's still zero (see attached image).
Is there another file I should check to see if it should be working?
Re: Monitoring Network Bandwidth
Posted: Tue Apr 18, 2017 3:04 pm
by tgriep
Can you run the following command as root and post the /tmp/mrtg.txt file?
Code: Select all
LANG=C LC_ALL=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg -debug=cfg,base &> /tmp/mrtg.txt