Search Exchange

Search All Sites

Nagios Live Webinars

Let our experts show you how Nagios can help your organization.

Contact Us

Phone: 1-888-NAGIOS-1


Remember Me

Directory Tree


4 votes
Current Version
Last Release Date
Compatible With
  • Nagios 1.x
  • Nagios 2.x
  • Nagios 3.x
Network Monitoring Software - Download Nagios XI
Log Management Software - Nagios Log Server - Download
Netflow Analysis Software - Nagios Network Analyzer - Download
almost the same as original check_mrtgtraf but this one works and is "fine tuned" to give detailed output on which IN or OUT threshold was exceeded, it is also "fine tuned" to present the output in Mbyte and/or Kbytes depending on how much traffic there was.

You can tell the program what "unit" the WARNING or CRITICAL thresholds will be in. The script supports input as kbytes, mbytes, gbytes or tbytes.

Don't forget to edit the file to point to the directory where your is located. Find and Change below line.
use lib "/usr/local/nagios/libexec"; 1.0.1
Usage: -|--f|F|FUN|function|FUNCTION -|--l|L|log|LOG|logfile|LOGFILE
-|--w|W|warn|WARN|warning|WARNING Warning threshold in bytes ,
-|--c|C|crit|CRIT|critical|CRITICAL critical threshold in bytes ,
-|--u|un|UNIT unit for , thresholds
-|--v|V|VERSION |version -|--he|HE|help|HELP -|--d|D|DEBUG|debug [debug]

./ -F MAX -L /scripts/test.log -w 9,9 -c 9999999999,999999999
./ -FUNC MAX -LOG /scripts/test.log -WARN 1048576,2097152 -CRIT 2097152,3145728
./ -function MAX -logfile /scripts/test.log -warning 1048576 -critcal 2097152 --debug
./ -F AVG -L /scripts/test.log -w 9,9 -c 9999999999,999999999
./ -FUNCT AVG -LOG /scripts/test.log -WARN 1048576,2097152 -CRIT 2097152,3145728
./ -function AVG -logfile /scripts/test.log -warning 1048576 -critical 2097152 --debug
./ -FUNCT AVG -LOG /scripts/test.log -WARN 100,100 -CRIT 200,2000 -u kilobytes
./ -FUNCT AVG -LOG /scripts/test.log -WARN 100,100 -CRIT 200,2000 -u megabytes
./ -FUNCT AVG -LOG /scripts/test.log -WARN 100,100 -CRIT 200,2000 -u gigabytes
./ -FUNCT AVG -LOG /scripts/test.log -WARN 100,100 -CRIT 200,2000 -u terabytes
./ --help
./ --version

-|--f|F|FUN|FUNCTION|function Can be either AVG or MAX. where AVG = "The average incoming transfer rate in bytes per second"
AND MAX = "The maximum incoming transfer rate in bytes per second since last MRTG poll"

-|--w|W|warn|WARN|warning|WARNING This will tell Nagios when to send a WARNING message.
WARNING Threshold expects bytes input as default(unless you use the -u flag) and needs to be supplied as
a "warning threshold pair" ,.
If there is only one value passed in it will use that value in both pairs.

-|--c|C|crit|CRIT|critical|CRITICAL This will tell Nagios when to send a CRITCAL message.
CRITCAL Threshold expects bytes input as default(unless you use the -u flag) and needs to be supplied as
a "critical threshold pair" ,.
If there is only one value passed in it will use that value in both pairs.

-|--|u|un|UNIT If you don't want to pass in WARNING and CRITICAL threshold pairs using default "bytes input" then use this flag to
change it to suit your need. This script understands Kilobytes, Megabytes, Gigabytes and Terabytes.
Input is regexped so can be anything from or or or .
If this flag is not used THEN scripts expects input for WARNING and CRITICAL thresholds to be in bytes.

-d|D|DEBUG|debug : Enable debugging (DEFAULT disabled)

-|--he|HE|help|HELP Prints this help screen

-|--v|V|VERSION|version Prints program version

INFO: WARNING THRESHOLDS must be exceeded before any checks are done on CRITICAL THRESHOLDS!
Also only use the debug flag from the CLI Nagios will be very confused by it.
If you find any BUGs or have a suggestion on a feature or improvments then please drop a line to

IMPORTANT!! For this scripts to work with Nagios! This script needs to be able to find nagios supplied file.
Edit this file at the top of the file change "use lib qw( /usr/local/nagios/libexec );" to point to where you Nagios
installation installed
IF you get errors looking like
"Global symbol "%ERRORS" requires explicit package name" Then it is a sure sign that your path to is wrong.

# '' command definition #
define command{
command_line $USER1$/ -L $ARG1$ -F $ARG2$ -w $ARG3$ -c $ARG4$ -u $ARG5$

# Define a host for the local machine

define host{
use unix-server ; Name of host template to use
host_name mrtghost1
alias mrtg.

define hostgroup{
hostgroup_name bandwidth-monitoring ; The name of the hostgroup
alias bw-monitoring
members mrtghost1

define service{
use local-service
host_name mrtghost1
service_description Check bandwidth router1 customer1
Reviews (3)
+1 for the user who submitted "script to obtain check_mrtgtraf performance data needed by NagiosGraph"

Using that, as is, even though it is written in Spanish, I was able to pop it in as a proxy script to check_mrtgtraf and it works out of the box for me using Graphite, Whipser, Grafana! Thanks for that contribution!!!
I wrote this script that modifies check_mrtgtraf output in order to obtain usable performance data usable by nagiosgraph.

I hope it will be useful.


# parche check_mrtgtraf para que salga en nagiosgraph v_1.2 3 dic 2014 Rodrigo Avila



#valor=`/usr/lib/nagios/plugins/check_mrtgtraf -F /srv/www/htdocs/mrtg/ -a AVG -c "175000,175000" -w "165000,165000"`


literal=`echo $valor | cut -d"|" -f1`

valorInKB=`echo $valor | cut -d"|" -f2 | cut -d"=" -f2 | cut -d "K" -f1`
valorIn=`echo "scale=4 ; $valorInKB * 1024 * 8 /1 "| bc`

valorOutKB=`echo $valor | cut -d"|" -f2 | cut -d"=" -f3 | cut -d "K" -f1`
valorOut=`echo "scale=4 ; $valorOutKB *1024 * 8 /1 "| bc`

# convert Bytes to bits

inCritiKB=`echo $CRITI | cut -d"," -f1`
inCriti=`echo "scale=2 ; $inCritiKB * $AJUSTE /1 "| bc`


outCritiKB=`echo $CRITI | cut -d"," -f2`
outCriti=`echo "scale=2 ;$outCritiKB * $AJUSTE /1"| bc`


inWarniKB=`echo $WARNI | cut -d"," -f1`
inWarni=`echo "scale=2 ; $inWarniKB * $AJUSTE /1"| bc`


outWarniKB=`echo $WARNI | cut -d"," -f2`
outWarni=`echo "scale=2 ;$outWarniKB * $AJUSTE /1"| bc`


esCritico=`echo $literal | grep "Traffic CRITICAL" | wc -l `
if [ $esCritico -eq "1" ]
echo "$literal|in=$valorIn;$inWarni;$inCriti;0 out=$valorOut;$outWarni;$outCriti;0"
exit 2;

esWarning=`echo $literal | grep "Traffic WARNING" | wc -l `
if [ $esWarning -eq "1" ]
echo "$literal|in=$valorIn;$inWarni;$inCriti;0 out=$valorOut;$outWarni;$outCriti;0"
exit 1;

echo "$literal|in=$valorIn;$inWarni;$inCriti;0 out=$valorOut;$outWarni;$outCriti;0"
exit 0;

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

define service{
use generic-service
host_name MYROUTER
service_description Uso de ancho de banda del Enlace ISP
check_command check_local_mrtgtraf!/srv/www/htdocs/mrtg/myrouter_192.168.1.1.log!AVG!276000,113750!256000,93750!10

I started to use this script, and it looks good to use easier than the original one. My only problem is, that the pnp4nagios stopped working and doesn't want to make the graphs anymore. Don't you have any idea about it?

Thank for the great script!