#!/bin/bash
#########################################################################
#
# File: check_traffic.sh
# Description: Nagios check plugins to check network interface traffic with SNMP run in *nix.
# Language: GNU Bourne-Again SHell
# Version: 1.4.0
# Date: 2013-11-05
# Corp.: Chenlei
# Author: [email protected], [email protected] (U can msn me with this), QQ 31017671
# WWW: http://www.itnms.info
# Perl Version: U Can find the perl/Net::SNMP Version in the same site.
#########################################################################
# Bugs:
# The Latest Version will be released in http://bbs.itnms.info.
# You can send bugs to http://bbs.itnms.info,
# or email to me directly: [email protected] or [email protected]
#########################################################################
# Todo:
# Do not use unit at performance data, for pnp/rrd graphing better.
# Add the History performance data file support.(maybe)
# Multi hosts and mult interfaces check function is a quick release, \
# need to review and process the code.
#########################################################################
# ChangeLog:
#
# Version 1.4.0
# 2013-11-05
# Fix bug for Conter64 check.
#
# Version 1.3.11
# 2013-10-09
# Add -Oa option to all snmplwak/snmpget command.
#
# Version 1.3.10
# 2013-01-29
# Set the Default TIMEOUT. Thanks to martin.leeyd.
#
# Version 1.3.9
# 2012-12-05
# Use 'id --user --name' instead of '$USER'
#
# Version 1.3.8
# 2012-09-28
# Add -Oa option to snmplwak command with List Interface function.
#
# Version 1.3.7
# 2012-09-25
# Fix spelling mkstakes of help msgs.
#
# Version 1.3.6
# 2012-09-25
# Fix bug of Conversion K to M. With bps use 1000, with B/s use 1024;
#
# Version 1.3.5
# 2012-09-04
# Give out more suitable help messages when can not get the interface index. Thanks to Jack.
#
# Version 1.3.4
# 2012-08-17
# Fix some spelling mistake. Thanks, Jack.
#
# Version 1.3.3
# 2012-08-16
# 1)Fix some spelling mistake;
# 2)Add support with multi hosts and multi interfaces checks.
#
# Version 1.3.2
# 2012-08-15
# Add -N args support with multi interface checks
#
# Version 1.3.1
# 2012-08-13
# Fix history data time update bug.
#
# Version 1.3.0
# 2012-08-10
# Add support with the -N args, with interface name when to check the single interface.
#
# Version 1.2.12
# 2012-05-20
# Fix bugs for message output.
#
# Version 1.2.11
# 2012-05-20
# Use snmpget instead of snmpwalk for reducing CPU footprint.
#
# Version 1.2.10
# 2012-05-12
# 1)bug fix for debug log
# 2)add "J" to suffix when Jitter option was set
# 3)add "R" to suffix when Range option was set
# 4)some tips in help messages fix
#
# Version 1.2.9
# 2012-05-10
# Fix bugs of the Same host Multi interfaces traffic aggregating and jitter calculating.
#
# Version 1.2.8
# 2012-04-26
# 1) Add the support for multi interfaces checking (in the same host/device) and traffic aggregation.
# Example: -I 2,3 or -I 10,12,16,18
# 2) Add the default suffix "itnms"
# 3) Check bc command
#
# Version 1.2.7
# 2012-04-05
# 1) Add "exit $Severity" at line 927. fix bug for Jitter exit value. Thanks gouldchu.
# 2) U can use "-F s/S" to control the format and get less output.
#
# Version 1.2.6
# 2011-12-13
# Spelling fix, from itnms.net to itnms.info.
#
# Version 1.2.5
# 2011-10-18
# Spelling fix.
#
# Version 1.2.4
# 2011-10-12
# Add snmp v3 support.
#
# Version 1.2.3
# 2011-09-05
# Fix bugs when high traffic occurs -- ifSpeed check error
#
# Version 1.2.2
# 2011-03-11
# Fix bugs with overflow detection. Thanks for jans1086.
#
# Version 1.2.1
# 2010-11-19
# Fix some spelling mistake;
#
# Version 1.2.0
# 2010-04-26
# Change default Scale value from 4 to 2, for more friendly output. If you want more excat value, U can change it for youself.
# Fix the Min Interval check bugs, move the check before write the current data to data hist file.
# Add the Max Interval var, default value is 1800, if the hist data file is too old, drop the result.
# Fix the for output "Maybe 32 bit counter overflow, because we got a negative value here." when check too frequent. And set Min_Interval to 30 as default.
# Add the -F option for simple or more simple(s/S) output format.
# Add the -i option for the individual suffix with the CF/STAT_HIST_DATA if necessary.
# Use the 64bit counter as default, when snmp version is v2c. If the system not support it, use 32bit counter instead.
# Get the interface's IF-MIB::ifSpeed, if the traffic value is bigger than it, drop it and output with OOPS and exit with Unkown.
# Modify the CF_HIST_DATA file name from "/var/tmp/check_traffic_${Host}_${Interface}.hist_dat" to
# "/var/tmp/check_traffic_${Host}_${Interface}.hist_dat_${USER}_64|32" for resolving
# 1)user and
# 2)64/32bit
# transfer problem which make
# 1)the hist data file read/write error and
# 2)with huge error traffic value.
# Add the function for testing Traffic Jitter(The orginal idea come from msn chat wiht [email protected]).
# Add a option -p N, N(suggest values is from 4 to 12) is a number that we comare this time value with the average value of previos N times
# we had been checked.
# If the value we checked this time is not in our defined scope(a % value) with -w/-c option specified(such as -w 20,20 -c30,30 ),
# we think that it is a traffic jitter.
# For this option, add a file for storing the hist data to stat: /var/tmp/check_traffic_${Host}_${Interface}.hist_dat_${USER}_64|32_ctj_$Num"
#
# Version 1.1.6
# 2009-02-20
# Fix some mistake at perfdata output format with Warning and Critical Value. (thanks for Jiang Shan)
# Remove the redundant code, merge code for --range option.
# Write data before the exit(for the reason of IsFirst), for the next time use.
# When write or read file error, use Unknow instead of Warning severity.
# If get a negative netflow or time interval value here, exit with unknow.
#
# Version 1.1.5
# 2008-09-28
# Fix bug on perfdata output format;
# Fix some spelling mistake;
# Add the Default Value for UseRange as "False";
#
# Version 1.1.4
# 2008-09-18
# Add -r options, Use Range instead of single value in warning and critical Threshold;
# This option suggestion by [email protected] at http://www.itnms.info/thread-1220-1-1.html
#
# Version 1.1.3
# 2008-09-17
# Set the default Interval as 12 seconds;
#
# Version 1.1.2
# 2008-08-19
# Check the snmp agent support the 64 bit counter or not;
# Check the interface status, if not OK, exit with Critical status;
# Get the interface name with Interface Index Value;
#
# Version 1.1.1
# 2008-08-06
# Fix some bugs in version compare.
# Use -6 option, use 64 bit counter.
#
# Version 1.1.0
# 2008-06-11
# In snmp v2c, use counters ifHC* instead of if*;
#
# Version 1.0.9
# 2008-04-22
# More friendly output when getting snmp info error.
#
# Version 1.0.8
# 2008-03-31
# Correct some spelling mistake
#
# Version 1.0.7
# 2008-03-28
# If it's the first time to touch hist_dat, echo OK and Tips out;
# Test the hist_dat can be read and write;
# Use the Vars for $OutPut and $PerfData
# Fix some output format.
#
# Version 1.0.6
# 2008-03-25
# Correct Performance data output with Warning and Critical Value of Total and Interval for pnp graphing.
#
# Version 1.0.5
# 2008-03-24
# Correct Performance data output for pnp graphing.
#
# Version 1.0.4
# 2008-03-21
# Correct Performance data output to "Nagios plug-in development guidelines",
# for Graphing the performance data in the web with PNP.
# The standard is: 'label'=value[UOM];[warn];[crit];[min];[max]
#
# Version 1.0.3
# 2008-03-20
# More friendly output with function list_interface().
#
# Version 1.0.2
# 2008-03-06
# Fix some coding bugs;
# Add the -L support;
# -K/-M to speicify in K or M (bps,B/s);
# -B/-b switch to B/s or bps;
# Add Total traffic value in output
#
# Version 1.0.1
# 2008-02-28
# Fix two cacl bugs at line 212 and 244.
# In print_full_help_msg(), '$$' instead $$.
#
# Version 1.0
# 2008-02-27
# Original Version.
##################################################################

12小白
- 粉丝: 47
最新资源
- 单片机的C语言程序设计.ppt
- 大数据在反洗钱工作中的应用和策略分析.docx
- CATIA注塑模具设计与数控铣削编程技术.doc
- 卫生系统安全隐患排查表.doc
- 国际石油上游项目管理.ppt
- 浅析人工智能对主持人的影响.docx
- 网络工程贺蒙蒙NET公交查询系统.doc
- 电气控制与PLC.doc
- 简单版微信公众号接入大模型自动回复 DeepSeek、千问、豆包、Kimi 等
- 2017-2018学年高中数学-第一章-算法初步-1.1.1-算法的概念-新人教B版必修3.ppt
- 人工智能60周年:看智能时代的博弈与重生.docx
- 小波阈值去噪及MATLAB仿真.doc
- 全融合网络虚拟化技术.docx
- 实时时钟日历芯片与单片机接口电路实施方案.doc
- 自动化技术在机械设计制作的应用探究.docx
- 专科师范院校计算机硬件课程整合的研究与思考.docx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈


