Nagios monitors Linux network card traffic (check_traffic.sh)

Source: Internet
Author: User
Tags snmp install perl

1. Install the required components

Yum Install Perl perl-devel perl-cpan BC SNMPD-Y

Perl-mcpan-eshell & cpan> Install BUNDLE::LWP

Compile and install Nrpe (refer to Tutorial:http://2860664.blog.51cto.com/2850664/1559056)


The following are the monitored side settings

2. Download check_nginx_status.pl Script

: Https://github.com/cloved/check_traffic/archive/v1.3.11.zip

After extracting the files, upload check_traffic.sh to/usr/local/nagios/libexec

chmod +x check_traffic.sh

Chown Nagios.nagcmd check_traffic.sh

3. Setting SNMP parameters

Vi/etc/snmp/snmpd.conf

com2sec notconfiguser   is monitored by the end ip  publicgroup   notconfiggroup v1            notConfigUsergroup    Notconfiggroup v2c           notconfiguserview     systemview    included   .1.3.6.1.2.1.1view     systemview    included   .1.3.6.1.2.1.25.1.1access   notConfigGroup  ""       any        noauth    exact  all none noneview all     included  .1                                 80syslocation unknown  (edit /etc/snmp/snmpd.conf) syscontact root <[email protected]>  (configure /etc/snmp/ snmp.local.conf)

Service SNMPD Start

Chkconfig snmpd on

4. Test script on monitored side

Cd/usr/local/nagios/libexec

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

Ok-the traffic in are 0.72KB, out are 0.60KB, Total is 1.32KB. The Check Interval is 43s | In=0.72kb;1200;1700;0;0 Out=0.60kb;1500;1800;0;0 Total=1.32kb;2700;3500;0;0 Interval=43s;1200;1800;0;0

Where red is the IP address of the monitored end.

4,vi/usr/local/nagios/etc/nrpe.cfg Add

Command[check_traffic]=/usr/local/nagios/libexec/check_traffic.sh-v 2c-c public-h 192.168.1.247 -I 2-w 1200 , 1500-c 1700,1800-k-B

The following are the settings for the Nagios host

5. Server-Side testing

/usr/local/nagios/libexec/check_nrpe-h 192.168.1.247-c check_traffic

Ok-the traffic in are 0.48KB, out are 0.11KB, Total is 0.59KB. The Check Interval is 28s | In=0.48kb;1200;1700;0;0 Out=0.11kb;1500;1800;0;0 Total=0.59kb;2700;3500;0;0 Interval=28s;1200;1800;0;0


Vi/usr/local/nagios/etc/nagios.cfg add

cfg_file=/usr/local/nagios/etc/objects/nginx.cfg

6, Touch/usr/local/nagios/etc/objects/nginx.cfg

Vi/usr/local/nagios/etc/objects/nginx.cfg (Note to modify the IP on the monitored side) the content is as follows   

**************************************** I'm a split line ************************************

define host{           use              linux-server           host_name     nginx           alias         nginx           address        Monitored end ip         }define service{        use                        generic-service        host_name              nginx         service_description     check-swap        check_command         check_nrpe!check_swap                }define service{         use                       generic-service        host_name              nginx         service_description     check-load        check_command         check_nrpe!check_load                }define service {        use                       generic-service        host_name              nginx        service_description     check-disk        check_command        check_nrpe!check_sda1                }define service{         use                       generic-service         host_name              nginx       service_description     check-users        check_command        check_nrpe!check_users                }define service{         use                     generic-service         host_name           nginx         service_description  otal_procs         check_command     check_nrpe!check_total_procs}define service{         use                              generic-service          ; name of service template to use         host_name                        nginx         service_description              PING        check_command                    check_ping! 100.0,20%!500.0,60%        }define service{     use                      generic-service    host_name                nginx    service_description     nginx_status     check_command           check_ nrpe!check_nginx!        notifications_enabled            0        }define  service{    use                      generic-service    host_name                nginx     service_description     network_traffic    check_command            check_nrpe!check_traffic!         NOTIFICATIONS_ENABLED&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;0}

I'm also a split line ************************************

Error message

7. Nagios Server Error

unknown-read or Write file/var/tmp/check_traffic_192.168.1.247_2__itnms.hist_dat_64 Error with User uid=501 (Nagios) G id=503 (Nagcmd) groups=502 (Nagios), 503 (nagcmd).

Workaround:chmod nagios.nagcmd /var/tmp/check_traffic_192.168.1.247_2__itnms.hist_dat_64


This article is from the "Linux related sharing" blog, make sure to keep this source http://2860664.blog.51cto.com/2850664/1567068

Nagios monitors Linux network card traffic (check_traffic.sh)

Related Article

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.