Nagios Monitors traffic

Source: Internet
Author: User

Client

1, first install the NET-SNMP package and RRDtool

#yum-y Install net-snmp*

2. Modify the snmpd.conf file

Line 41st modified to com2sec notconfiguser localhost public

Line 62nd is modified to: Access Notconfiggroup "" Any noauth exact mib2 none None

89th line view Mib2 included. Iso.org.dod.internet.mgmt.mib-2 FC Front comments removed

3. Start SNMPD Service

#service snmpd Restart

4. Upload plugins and authorize

1) Upload check_traffic.sh to/usr/local/nagios/libexec

2) #chown Nagios.nagios check_traffic.sh

#chmod +x check_traffic.sh

5, network card parameter detection

#/usr/local/nagios/libexec/check_traffic.sh-v 2c-c public-h 127.0.0.1-l

List Interface for host 127.0.0.1.

Interface index 1 orresponding to Lo

Interface index 2 orresponding to eth0

Interface index 3 orresponding to eth1

See which NIC you want to monitor, and if it's eth0, the parameter is 2.

6. Test whether the data can be collected normally

#/usr/local/nagios/libexec/check_traffic.sh-v 2c-c zhezi-h 127.0.0.1-i 2-w 1,50-c 180,200-m–b

Note:

-V SNMP Protocol version

-C Community Name

The-I parameter corresponds to the network card of the above-l output index value. Flag to monitor the appropriate network card

Return the result correctly:

Ok-the traffic in are 356Kbps, out are 414Kbps, Total is 770Kbps. The Check Interval is 30s | In=356kbps;1200;1700;0;0 Out=414kbps;1500;1800;0;0 Total=770kbps;2700;3500;0;0 Interval=30s;1200;1800;0;0

The IP in the client's SNMP profile and in the Nrpe file should be written to the client itself, not the server's IP, because Nagios obtains the data through Nrpe, which is not obtained through SNMP, i.e. the SNMP data will only be generated natively. It collects its own data and is then transmitted by the Nrpe plugin to the Nagios server front end (the data file is in this computer).

6. Modify the configuration file for Nagios client

#vim/usr/local/nagios/etc/nrpe.cfg

Add the following content

Command[check_traffic]=/usr/local/nagios/libexec/check_traffic.sh-v 2c-c zhezi-h 127.0.0.1-i 2-w 1,50-c 180,200-m– B

Note: Two values after-W and-C, one is in flow value, one is the out traffic value

7. Delete cache files

#cd/var/tmp/

#rm-RF *

8. Restart Nrpe

#ps-ef |grep Nrpe

Root 9227 25212 0 16:18 pts/0 00:00:00 grep Nrpe

Test 29963 1 0 15:45? 00:00:00/usr/local/nagios/bin/nrpe-c/usr/local/nagios/etc/nrpe.cfg-d

#kill 29963

#/usr/local/nagios/bin/nrpe-c/usr/local/nagios/etc/nrpe.cfg-d

"Service Side"

1. Modify the Host configuration file

#vim/usr/local/nagios/etc/objects/1.1.1.1.cfg

Add the following on the last side

Define Service{

Use Local-service; Name of service template to use

HOST_NAME 1.1.1.1//IP Address

Service_description Liuliang//service Name

Check_command check_nrpe!check_traffic

Notifications_enabled 1

}

2. Verify that the configuration file is correct

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

The following prompt indicates that the configuration file is correct

Total warnings:0

Total errors:0

3. Restart the Nagios server

#service Nagios Restart

Frequently asked Questions to resolve the method:

#./check_nrpe-h xx-c check_traffic

Ok-the traffic in are 1.25KB, out are 3.37KB, Total is 4.62KB. The Check Interval is 298s | In=1.25kb;300;500;0;0 Out=3.37kb;400;600;0;0 Total=4.62kb;700;1100;0;0 Interval=298s;1200;1800;0;0

# #错误

When you run the check_traffic.sh script, it appears:

./check_traffic.sh-v 2c-c public-h 127.0.0.1-i 1-w 1200,1500-c 1700,1800-k-B

./check_traffic.sh:line 449:bc:command Not found

./check_traffic.sh:line 454:bc:command Not found

./check_traffic.sh:line 457:bc:command Not found

./check_traffic.sh:line 458:bc:command Not found

./check_traffic.sh:line 461: [: Too many arguments

./check_traffic.sh:line 576:bc:command Not found

./check_traffic.sh:line 577:bc:command Not found

Unknown-can not found data in the history data file. Please check the file/var/tmp/check_traffic_127.0.0.1_3.hist_dat_root__64, or use verbose mode and check the debug File

--Solve:

Bc:command not found

Yum Search BC, the results appear a lot, and then find that there is such a need to install

Bc.x86_64 0:1.06.95-1.el6

Decisive execution yum-y install BC

Another error:

Unknown is due to the first execution, because the history data file does not exist, so you will be prompted to ignore it.

If each execution is ignored, check for/var/tmp/check_traffic_${host}_${interface}.hist_dat file generation under/var/tmp.

The contents of the file are the current time of the system, in and out current values.


This article from "Ma Zhenguo" blog, declined reprint!

Nagios Monitors traffic

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.