1) Install prerequisites.
yum install -y net-snmp net-snmp-utils
2) Check to see whether ‘check_snmp’ and ‘check_mrtgtraf’ can be found under /usr/local/nagios/libexec/ folder. If not, you need to reinstall the nagios-plugin. (It can be found in my previous post on the Nagios Installation)
3) As the ‘check_mrtgtraf’ will retrieve the bandwidth utilization information from MRTG log, the MRTG has to been install.
yum install -y mrtg
mkdir /home/httpd/mrtg/
cfgmaker --global 'WorkDir: /home/httpd/mrtg' --output /etc/mrtg/dlink.cfg public@10.1.1.1
/usr/bin/mrtg /etc/mrtg/dlink.cfg --loging /var/log/mrtg.log
#Edit the crontab file to make MRTG run every 5 minutes:
crontab -e
*/5 * * * * /usr/bin/mrtg /etc/mrtg/dlink.cfg --logging /var/log/mrtg.log
4) Modify ‘switch.cfg’ file to customize the host and its interface that you want to monitor.
vi /usr/local/nagios/etc/objects/switch.cfg
- Change IP address in the host definition
- Change every host_name to the switch name that you want to monitor
- Find ‘# Monitor bandwidth via MRTG logs’ and change the MRTG log to fit your conditions.
check_command check_local_mrtgtraf!/home/httpd/mrtg/10.1.1.1_2.log!AVG!1000000,1000000!5000000,5000000!10
5) Modify the ‘nagios.cfg’ file.
vi /usr/local/nagios/etc/nagios.cfg
uncomment ‘cfg_file=/usr/local/nagios/etc/objects/switch.cfg’
6) Verify the nagios configuration file then reload the nagios service if it is correct.