- Install packages
Yum-y Install net-snmp*
Chconfig Nrpe on
Chconfig SNMPD on
Chkconfig Nagios on
- Modify the SNMP parameters, vi/etc/snmp/snmpd.conf (can back up the snmpd.conf, modify the following localhost-ip as the server IP, save this file)
com2sec notconfiguser localhost-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 and none Noneview all included.1 thesyslocation Unknown (Edit/etc/snmp/snmpd.conf) syscontact Root<[email protected]> (configure/etc/snmp/snmp.local.conf)
snmpd.conf
-
Copy check_traffic.sh to/usr/lib64/nagios/plugins/check_traffic.sh
check_traffic.sh file GitHub:https://github.com/cloved/check_traffic/blob/master/check_traffic.sh
wget Https://github.com/cloved/check_traffic/archive/master.zip
-
Give execute permission and test:
chmod +x check_traffic.sh
./check_traffic.sh-v 2c-c public-h your_ip-i 2-w 1200,1500-c 1700,1800-k–b
./check_traffic.sh-v 2c-c Public-h your_ip–l
-
example:
./check_traffic.sh-v 2c-c public-h your_ip-n eth0-w 8,7-c 16,14-m-B
-v SNMP version
-c authentication information
-h host IP
-n network card
-w 8,7 downstream/upstream traffic exceeding 8,7 Mbit/s warning
-c 16,14 downlink/upstream traffic exceeds 16,14 Mbit/s critical
-m MB
-b bits
-
Edit the/etc/nagios/objects/command.cfg file, append:
' check_traffic ' command definitiondefine command{ command_name check_traffic command_line $USER 1$/check _traffic. sh -v 2c-c public-h $HOSTADDRESS $-I $ARG 1$-w $ARG 2$-C $ARG 3$-M-b }Check _traffic Code
-
Edit/etc/nagios/objects/localhost.cfg File
define service{use local -service; Name of service template to use host_name localhost service_description Ch Eck_trafffic Check_command check_traffic ! 2 ! 12 , 15 ! 20 , 1 Normal_ Check_interval 5 Retry_interval 1 }
localhost.cfg
and modify the IP address in the Localhost.cfg file (127.0.0.1) to the native IP!!!!!!! (Pit me for 2 days)
- Delete temporary files
/var/tmp/check_traffic_${host}_${interface}.hist_dat file
- Restarting the Nagios service
- Refer to some of the links below:
http://2860664.blog.51cto.com/2850664/1567068
Nagios Configuration check_traffic Module (Server side)