Bobcares

Add MRTG Graph to Nagios: Explained

by | Sep 25, 2022

Let us take a closer look at how to add mrtg graph to Nagios in a few simple steps with the assistance of our Server management support services at Bobcares.

 

MRTG graph Configuration for Nagios

add mrtg graph to nagios

MRTG setup files example The mrtg.cfg file in the sample-config/ subdirectory of the Nagios package contains snippets for graphing various Nagios performance information.

 

We can make graphs of other performance data if desired; the samples only serve as a nice starting point.      

 

We should see some new graphs the next time we run MRTG after we add these example entries to the MRTG configuration file (/etc/mrtg/mrtg.cfg).

 

Add MRTG to Nagios

Mrtg software may be installed during the initial installation; we can tell if MRTG is installed by using the following RPM command as the initial stepto add mrtg graph to Nagios:

 

rpm -qa | grep mrtg

 

Then, use rpmfind.net to locate MRTG RPMs or the up2date command to install MRTG software:

 

# up2date -v -i mrtg

 

To install MRTG on Fedora Linux, execute the yum command as follows:

 

# yum install mrtg

 

 Commands to Configure mrtg

We have to configure the mrtg graph to add it to Nagios. Follow the steps given below for configurations:

 
  • Make a document root in which to store mrtg graphs/html pages:
     

    # mkdir -p /var/www/html/mymrtg/

     
  • Use any of the following cfgmaker commands to generate a mrtg configuration file:
     

    —global 'WorkDir: /var/www/html/mymrtg' —output /etc/mrtg/mymrtg.cfg public@localhost

     

    OR (we must ensure that the FQDN resolves; in the following example, I’m using rh9.test.com, which is my router’s FQDN address).

     

    # cfgmaker 'WorkDir: /var/www/html/mymrtg' —output /etc/mrtg/mymrtg1.cfg public@rh9.test.com

     
  • Create the MRTG configuration’s default index page with indexmaker:
     

    # indexmaker —output=/var/www/html/mymrtg/index.html /etc/mrtg/mymrtg.cfg.

     
  • Copy the following tiny png files to the mrtg path:
     

    # cp -av /var/www/html/mrtg/*.png /var/www/html/mymrtg/ /var/www/html/mymrtg/

     

    Using the configuration file, run the mrtg command from the command line:

     

    # mrtg /etc/mrtg/mymrtg.cfg

 For the first time, we may receive a few caution messages con the configurations for adding the mrtg graph to Nagios; disregard them.

 

We can use our preferred web browser (such as FireFox:D) and type http://www.user.com/mymrtg/ or http://your-ip/mymrtg/ into the address bar.

 


Now Your MRTG is running fine. Integrate it to Nagios.

 

Procedure to monitor Bandwidth Usage in Nagios:

1. Nagios’s default installation directory is /usr/local/nagios/.

 

2. Open the switch.cfg configuration file by typing in the following:

 

vi /usr/local/nagios/etc/objects/switch.cfg

 

3. Make the necessary adjustments in accordance with the router’s requirements. Follow the commands given below:

 

define host{
use generic-switch
host_name Router_1
alias Router 1
address 172.17.42.22
hostgroups switches
}

 

4. We may also configure PING, Uptime, Ports Link Status, and so on. Make sure to go through all of the configuration steps for addibng mrtg graph to nagios quickly.

 

define service{
use generic-service ; Inherit values from a template
host_name Router_1 ; The name of the host the service is associated with
service_description PING ; The service description
check_command check_ping!200.0,20%!600.0,60% ; The command used to monitor the service
normal_check_interval 5 ; Check the service every 5 minutes under normal conditions
retry_check_interval 1 ; Re-check the service every minute until its final/hard state is determined
}

 

define service{
use generic-service ; Inherit values from a template
host_name Router_1
service_description Uptime
check_command check_snmp!-C public -o sysUpTime.0 -H 172.17.42.22
}

 

define service{
use generic-service ; Inherit values from a template
host_name Router_1
service_description Port 2 Link Status
check_command check_snmp!-C public -o ifOperStatus.2 -r 1 -H 172.17.42.22
}

 

define service{
use generic-service ; Inherit values from a template
host_name Router_1
service_description Port 2 Bandwidth Usage
check_command check_local_mrtgtraf!/var/www/html/mrtg/172.17.42.22_2.log!AVG!1000000,1000000!5000000,5000000
!10
}

 

5. Check the Nagios configuration.

 

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

 

6. Finally restart the Nagios service by typing in the following command line:

 

/etc/init.d/nagios restart

 

[Need assistance with similar queries? We are here to help]

 

Conclusion

To conclude we have now learned more about how to add mrtg graph to Nagios and the configuration steps necessary to add it to add the mrtg graph to Nagios with the assistance of our Server Management Support Services at Bobcares.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

     

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF