Search Exchange
Search All Sites
Nagios Live Webinars
Let our experts show you how Nagios can help your organization.Login
Directory Tree
check_traffic.sh
1.3.11
2013-10-09
- Nagios 1.x
- Nagios 2.x
- Nagios 3.x
- Nagios XI
- Nagios Fusion
GPL
124374
File | Description |
---|---|
ct_test.sh | ct_test.sh |
Meet The New Nagios Core Services Platform
Built on over 25 years of monitoring experience, the Nagios Core Services Platform provides insightful monitoring dashboards, time-saving monitoring wizards, and unmatched ease of use. Use it for free indefinitely.
Monitoring Made Magically Better
- Nagios Core on Overdrive
- Powerful Monitoring Dashboards
- Time-Saving Configuration Wizards
- Open Source Powered Monitoring On Steroids
- And So Much More!
1) a single interface on a single network device
2) multiple interfaces on a single network device
3) interface(s) on a single or multiple network devices
The amount of interfaces is not limited. However, aggregation of too many interfaces might make impact on accuracy. The value of amount less than 8 interfaces is recommended.
Both 32-bit and 64-bit counters are supported.
Usage:
check_traffic.sh [ -v ] [ -6 ] [ -i Suffix ] [ -F s|S ] [-p N] [ -r ] -V 1|2c|3 ( -C snmp-community | -A "AuthString" (when use snmp v3, U must give the AuthString)) -H host [ -L ] (-I interface|-N interface name) -w in,out-warning-value -c in,out-critical-value -K/M -B/b
Options:
-h (help)
Get the help message
-v (verbose)
Verbose mode, to debug some messages out to the /tmp directory with log file name check_traffic.$$.
-V (snmp version, protocol=[1|2c|3])
Specify the version of snmp
-C (community)
Specify the Community
-H (host)
Specify the host
-6 (use 64 bit)
Use 64 bit counter, ifHC* instead of if*.
-r (range)
Use Range instead of single value in warning and critical Threshold
-I (ifIndex of interface)
Specify ifIndex of each interface
-N (interface name)
Specify the interface name
-L (list)
List all Interfaces on specify host
-B/b (Bps/bps)
Switch to Bps(B/s) or bps(b/s), default is -b, bps
-K/M (kilo/mega)
Switch to K (kilo) or M (mega) Bps|bps, default is -K
-w (warning)
Set inbound and outbound warning threshold for traffic usage or traffic jitter value
-c (critical)
Set inbound and outbound critical threshold for traffic usage or traffic jitter value
-F (format, type=[s|S])
-F s (simple output format)
-F S (simpler output format)
-p (amount of traffic usage records preserved for comparison=INTEGER)
This option is the amount of traffic usage records preserved prior to current traffic usage check. The average of all these preserved values is compared with current check value to detect whether jitter happens. The value (amount) between 4 and 12 is suggested.
-i (suffix=STRING)
It's the individual suffix added to the CF/STAT_HIST_DATA if necessary.
Example:
./check_traffic.sh -V 2c -C public -H 127.0.0.1 -I 4 -w 200,100 -c 300,200 -K -B
Or
./check_traffic.sh -V 2c -C public -H 127.0.0.1 -N FastEthernet0/1 -w 200,100 -c 300,200 -K -B
Or -r to use Range Value Options:
./check_traffic.sh -V 2c -C public -H 127.0.0.1 -I 4 -r -w 200-300,100-200 -c 100-400,50-250 -K -B
Or
./check_traffic.sh -V 2c -C public -H 127.0.0.1 -N eth0 -r -w 200-300,100-200 -c 100-400,50-250 -K -B
Or -p N to use Traffic Jitter Options:
./check_traffic.sh -V 2c -C public -H 127.0.0.1 -I 4 -p 8 -w 45,45 -c 55,55
Or
./check_traffic.sh -V 2c -C public -H 127.0.0.1 -N eth0 -p 8 -w 45,45 -c 55,55
Or for single host and multiple interfaces checking (in the same host/device) and traffic aggregation:
./check_traffic.sh -V 2c -C public -H 127.0.0.1 -I 2,3,8,9 -w 200,100 -c 300,200 -K -B
./check_traffic.sh -V 2c -C public -H 127.0.0.1 -N FastEthernet0/1,FastEthernet0/2 -w 200,100 -c 300,200 -K -B
Or -r to use Range Value Options:
./check_traffic.sh -V 2c -C public -H 127.0.0.1 -I 2,3,8,9 -r -w 200-300,100-200 -c 100-400,50-250 -K -B
./check_traffic.sh -V 2c -C public -H 127.0.0.1 -I -N FastEthernet0/1,FastEthernet0/2 -r -w 200-300,100-200 -c 100-400,50-250 -K -B
Or -p N to use Traffic Jitter Options:
./check_traffic.sh -V 2c -C public -H 127.0.0.1 -I 2,3,8,9 -p 8 -w 45,45 -c 55,55
./check_traffic.sh -V 2c -C public -H 127.0.0.1 -N FastEthernet0/1,FastEthernet0/2 -p 8 -w 45,45 -c 55,55
Or for multiple hosts and multiple interfaces checking (in the same host/device) and traffic aggregation:
./check_traffic.sh -V 2c,1 -C public,private -H 127.0.0.1,192.168.1.1 -I 2,3 -w 200,100 -c 300,200 -K -B
./check_traffic.sh -V 2c,1 -C public,private -H 127.0.0.1,192,168.1.1 -N FastEthernet0/1,FastEthernet0/2 -w 200,100 -c 300,200 -K -B
Or -r to use Range Value Options:
./check_traffic.sh -V 2c,1 -C public,private -H 127.0.0.1,192.168.1.1 -I 2,3 -w 200-300,100-200 -c 100-400,50-250 -K -B
./check_traffic.sh -V 2c,1 -C public,private -H 127.0.0.1,192.168.1.1 -N FastEthernet0/1,FastEthernet0/2 -r -w 200-300,100-200 -c 100-400,50-250 -K -B
Or -p N to use Traffic Jitter Options:
./check_traffic.sh -V 2c,1 -C public,private -H 127.0.0.1,192.168.1.1 -I 2,3 -p 8 -w 45,45 -c 55,55
./check_traffic.sh -V 2c,1 -C public,private -H 127.0.0.1,192.168.1.1 -N FastEthernet0/1,FastEthernet0/2 -p 8 -w 45,45 -c 55,55
Or use ./check_traffic.sh [ -v ] -V 1|2c|3 -C snmp-community -H host -L
to list all interfaces on the host.
Or check for snmp v3 device:
./check_traffic.sh -V 3 -A "-u kschmidt -l authPriv -a MD5 -A mysecretpass -x DES -X mypassphrase" -H 127.0.0.1 -I 4 -w 200,100 -c 300,200 -K -B
Or
./check_traffic.sh -V 3 -A "-u kschmidt -l authPriv -a MD5 -A mysecretpass -x DES -X mypassphrase" -H 127.0.0.1 -N eth0 -w 200,100 -c 300,200 -K -B
Note:
1. If you don't use -K/M -B/b options, default -K -b, corresponding to Kbps.
Combination:
-K -b (kbps, kilobits per second)
-K -B (KBps, kilobytes per second)
-M -b (Mbps, megabits per second)
-M -B (MBps, megabytes per second)
2. Make sure that the check interval greater than 30 Seconds, or modify the Min_Interval's default value as you need. And, if you want in Verbose mode, use "-v" to check the debug messages in the file /tmp/check_traffic.$$.
Report bugs to: cloved@gmail.com
Home page:
Getting help: or Email to cloved@gmail.com
./check_traffic.sh -V 2c -C public -H 127.0.0.1 -I 4 -w 200,100 -c 300,200 -K -B
Or
./check_traffic.sh -V 2c -C public -H 127.0.0.1 -N FastEthernet0/1 -w 200,100 -c 300,200 -K -B
Or -r to use Range Value Options:
./check_traffic.sh -V 2c -C public -H 127.0.0.1 -I 4 -r -w 200-300,100-200 -c 100-400,50-250 -K -B
Or
./check_traffic.sh -V 2c -C public -H 127.0.0.1 -N eth0 -r -w 200-300,100-200 -c 100-400,50-250 -K -B
Or -p N to use Traffic Jitter Options:
./check_traffic.sh -V 2c -C public -H 127.0.0.1 -I 4 -p 8 -w 45,45 -c 55,55
Or
./check_traffic.sh -V 2c -C public -H 127.0.0.1 -N eth0 -p 8 -w 45,45 -c 55,55
Or for single host and multiple interfaces checking (in the same host/device) and traffic aggregation:
./check_traffic.sh -V 2c -C public -H 127.0.0.1 -I 2,3,8,9 -w 200,100 -c 300,200 -K -B
./check_traffic.sh -V 2c -C public -H 127.0.0.1 -N FastEthernet0/1,FastEthernet0/2 -w 200,100 -c 300,200 -K -B
Or -r to use Range Value Options:
./check_traffic.sh -V 2c -C public -H 127.0.0.1 -I 2,3,8,9 -r -w 200-300,100-200 -c 100-400,50-250 -K -B
./check_traffic.sh -V 2c -C public -H 127.0.0.1 -I -N FastEthernet0/1,FastEthernet0/2 -r -w 200-300,100-200 -c 100-400,50-250 -K -B
Or -p N to use Traffic Jitter Options:
./check_traffic.sh -V 2c -C public -H 127.0.0.1 -I 2,3,8,9 -p 8 -w 45,45 -c 55,55
./check_traffic.sh -V 2c -C public -H 127.0.0.1 -N FastEthernet0/1,FastEthernet0/2 -p 8 -w 45,45 -c 55,55
Or for multiple hosts and multiple interfaces checking (in the same host/device) and traffic aggregation:
./check_traffic.sh -V 2c,1 -C public,private -H 127.0.0.1,192.168.1.1 -I 2,3 -w 200,100 -c 300,200 -K -B
./check_traffic.sh -V 2c,1 -C public,private -H 127.0.0.1,192,168.1.1 -N FastEthernet0/1,FastEthernet0/2 -w 200,100 -c 300,200 -K -B
Or -r to use Range Value Options:
./check_traffic.sh -V 2c,1 -C public,private -H 127.0.0.1,192.168.1.1 -I 2,3 -w 200-300,100-200 -c 100-400,50-250 -K -B
./check_traffic.sh -V 2c,1 -C public,private -H 127.0.0.1,192.168.1.1 -N FastEthernet0/1,FastEthernet0/2 -r -w 200-300,100-200 -c 100-400,50-250 -K -B
Or -p N to use Traffic Jitter Options:
./check_traffic.sh -V 2c,1 -C public,private -H 127.0.0.1,192.168.1.1 -I 2,3 -p 8 -w 45,45 -c 55,55
./check_traffic.sh -V 2c,1 -C public,private -H 127.0.0.1,192.168.1.1 -N FastEthernet0/1,FastEthernet0/2 -p 8 -w 45,45 -c 55,55
Or use ./check_traffic.sh [ -v ] -V 1|2c|3 -C snmp-community -H host -L
to list all interfaces on the host.
Or check for snmp v3 device:
./check_traffic.sh -V 3 -A "-u kschmidt -l authPriv -a MD5 -A mysecretpass -x DES -X mypassphrase" -H 127.0.0.1 -I 4 -w 200,100 -c 300,200 -K -B
Or
./check_traffic.sh -V 3 -A "-u kschmidt -l authPriv -a MD5 -A mysecretpass -x DES -X mypassphrase" -H 127.0.0.1 -N eth0 -w 200,100 -c 300,200 -K -B
Note:
1. If you don't use -K/M -B/b options, default -K -b, corresponding to Kbps.
Combination:
-K -b (kbps, kilobits per second)
-K -B (KBps, kilobytes per second)
-M -b (Mbps, megabits per second)
-M -B (MBps, megabytes per second)
2. Make sure that the check interval greater than 30 Seconds, or modify the Min_Interval's default value as you need. And, if you want in Verbose mode, use "-v" to check the debug messages in the file /tmp/check_traffic.$$.
Report bugs to: cloved@gmail.com
Home page:
Getting help:
Reviews (2)
byPeer, May 16, 2017
I use this script for few years already and it is working fine!
I recently encounter problems when I monitored interface on Ubuntu 16. I checked and found the script used IF-MIB::ifDescr OID to look and query the interface name, which does not work for Ubuntu 16.
I guess it is a long runing bug or bad usage on this OID as there is a dedicated OID just for name: IF-MIB::ifName. after fixing it ubuntu 16 interfaces are monitored too so as the others that used to work with the previous OID. just replace the OID in the script.
FYI,
David
I recently encounter problems when I monitored interface on Ubuntu 16. I checked and found the script used IF-MIB::ifDescr OID to look and query the interface name, which does not work for Ubuntu 16.
I guess it is a long runing bug or bad usage on this OID as there is a dedicated OID just for name: IF-MIB::ifName. after fixing it ubuntu 16 interfaces are monitored too so as the others that used to work with the previous OID. just replace the OID in the script.
FYI,
David
Owner's reply
Got it.
Thanks very much.
I have used below command to get "Windows Interfaces".
./check_traffic.sh -V 1 -C nocgnr -H 172.16.1.105 -L
List Interface for host 172.16.1.105.
Interface index 1 orresponding to Software Loopback Interface 1.
Interface index 2 orresponding to WAN Miniport (SSTP).
Interface index 3 orresponding to WAN Miniport (L2TP).
Interface index 4 orresponding to WAN Miniport (PPTP).
Interface index 5 orresponding to WAN Miniport (PPPOE).
Interface index 6 orresponding to WAN Miniport (IPv6).
Interface index 7 orresponding to WAN Miniport (Network Monitor).
Interface index 8 orresponding to WAN Miniport (IP).
Interface index 9 orresponding to RAS Async Adapter.
Interface index 10 orresponding to WAN Miniport (IKEv2).
Interface index 11 orresponding to QLogic BCM57840 10 Gigabit Ethernet (NDIS VBD Client) #128.
Interface index 12 orresponding to Microsoft ISATAP Adapter.
Interface index 13 orresponding to QLogic BCM57840 10 Gigabit Ethernet (NDIS VBD Client) #131.
Interface index 14 orresponding to Microsoft ISATAP Adapter #2.
Interface index 15 orresponding to QLogic BCM57840 10 Gigabit Ethernet (NDIS VBD Client) #130.
Interface index 16 orresponding to QLogic BCM57840 10 Gigabit Ethernet (NDIS VBD Client) #135.
Interface index 17 orresponding to Microsoft ISATAP Adapter #3.
Interface index 18 orresponding to Microsoft ISATAP Adapter #4.
Interface index 19 orresponding to Microsoft 6to4 Adapter.
Interface index 20 orresponding to QLogic BCM57840 10 Gigabit Ethernet (NDIS VBD Client) #131-Trend Micro NDIS 6.0 Filter driver-0000.
Interface index 21 orresponding to QLogic BCM57840 10 Gigabit Ethernet (NDIS VBD Client) #128-QoS Packet Scheduler-0000.
Interface index 22 orresponding to QLogic BCM57840 10 Gigabit Ethernet (NDIS VBD Client) #128-WFP LightWeight Filter-0000.
Interface index 23 orresponding to QLogic BCM57840 10 Gigabit Ethernet (NDIS VBD Client) #131-QoS Packet Scheduler-0000.
Interface index 24 orresponding to QLogic BCM57840 10 Gigabit Ethernet (NDIS VBD Client) #131-WFP LightWeight Filter-0000.
Interface index 25 orresponding to QLogic BCM57840 10 Gigabit Ethernet (NDIS VBD Client) #130-Trend Micro NDIS 6.0 Filter driver-0000.
Interface index 26 orresponding to WAN Miniport (Network Monitor)-Trend Micro NDIS 6.0 Filter driver-0000.
Interface index 27 orresponding to QLogic BCM57840 10 Gigabit Ethernet (NDIS VBD Client) #130-QoS Packet Scheduler-0000.
Interface index 28 orresponding to QLogic BCM57840 10 Gigabit Ethernet (NDIS VBD Client) #130-WFP LightWeight Filter-0000.
Interface index 29 orresponding to WAN Miniport (IPv6)-Trend Micro NDIS 6.0 Filter driver-0000.
Interface index 30 orresponding to QLogic BCM57840 10 Gigabit Ethernet (NDIS VBD Client) #135-Trend Micro NDIS 6.0 Filter driver-0000.
Interface index 31 orresponding to QLogic BCM57840 10 Gigabit Ethernet (NDIS VBD Client) #135-QoS Packet Scheduler-0000.
Interface index 32 orresponding to QLogic BCM57840 10 Gigabit Ethernet (NDIS VBD Client) #135-WFP LightWeight Filter-0000.
Interface index 33 orresponding to WAN Miniport (Network Monitor)-QoS Packet Scheduler-0000.
Interface index 34 orresponding to QLogic BCM57840 10 Gigabit Ethernet (NDIS VBD Client) #128-Trend Micro NDIS 6.0 Filter driver-0000.
Interface index 35 orresponding to WAN Miniport (IP)-QoS Packet Scheduler-0000.
Interface index 36 orresponding to WAN Miniport (IP)-Trend Micro NDIS 6.0 Filter driver-0000.
Interface index 37 orresponding to WAN Miniport (IPv6)-QoS Packet Scheduler-0000.
But, don't know which "Interface Index" I need to mention in command line to generate output.
The error is,
./check_traffic.sh -V 1 -C nocgnr -H 172.16.1.105 -N "Interface index 20"
Can not get the interface index with Interface index 20 at 172.16.1.105.
Same error for Linux OS. Please see below.
#########################
./check_traffic.sh -V 1 -C public -H 172.16.1.73 -L
List Interface for host 172.16.1.73.
Interface index 1 orresponding to lo
Interface index 2 orresponding to enP4p1s0f0
Interface index 3 orresponding to enP4p1s0f1
Interface index 4 orresponding to eth1
Interface index 5 orresponding to eth2
Interface index 6 orresponding to virbr0
Interface index 7 orresponding to virbr0-nic
#########################
Please Guide.
Nishith N.Vyas
./check_traffic.sh -V 1 -C nocgnr -H 172.16.1.105 -L
List Interface for host 172.16.1.105.
Interface index 1 orresponding to Software Loopback Interface 1.
Interface index 2 orresponding to WAN Miniport (SSTP).
Interface index 3 orresponding to WAN Miniport (L2TP).
Interface index 4 orresponding to WAN Miniport (PPTP).
Interface index 5 orresponding to WAN Miniport (PPPOE).
Interface index 6 orresponding to WAN Miniport (IPv6).
Interface index 7 orresponding to WAN Miniport (Network Monitor).
Interface index 8 orresponding to WAN Miniport (IP).
Interface index 9 orresponding to RAS Async Adapter.
Interface index 10 orresponding to WAN Miniport (IKEv2).
Interface index 11 orresponding to QLogic BCM57840 10 Gigabit Ethernet (NDIS VBD Client) #128.
Interface index 12 orresponding to Microsoft ISATAP Adapter.
Interface index 13 orresponding to QLogic BCM57840 10 Gigabit Ethernet (NDIS VBD Client) #131.
Interface index 14 orresponding to Microsoft ISATAP Adapter #2.
Interface index 15 orresponding to QLogic BCM57840 10 Gigabit Ethernet (NDIS VBD Client) #130.
Interface index 16 orresponding to QLogic BCM57840 10 Gigabit Ethernet (NDIS VBD Client) #135.
Interface index 17 orresponding to Microsoft ISATAP Adapter #3.
Interface index 18 orresponding to Microsoft ISATAP Adapter #4.
Interface index 19 orresponding to Microsoft 6to4 Adapter.
Interface index 20 orresponding to QLogic BCM57840 10 Gigabit Ethernet (NDIS VBD Client) #131-Trend Micro NDIS 6.0 Filter driver-0000.
Interface index 21 orresponding to QLogic BCM57840 10 Gigabit Ethernet (NDIS VBD Client) #128-QoS Packet Scheduler-0000.
Interface index 22 orresponding to QLogic BCM57840 10 Gigabit Ethernet (NDIS VBD Client) #128-WFP LightWeight Filter-0000.
Interface index 23 orresponding to QLogic BCM57840 10 Gigabit Ethernet (NDIS VBD Client) #131-QoS Packet Scheduler-0000.
Interface index 24 orresponding to QLogic BCM57840 10 Gigabit Ethernet (NDIS VBD Client) #131-WFP LightWeight Filter-0000.
Interface index 25 orresponding to QLogic BCM57840 10 Gigabit Ethernet (NDIS VBD Client) #130-Trend Micro NDIS 6.0 Filter driver-0000.
Interface index 26 orresponding to WAN Miniport (Network Monitor)-Trend Micro NDIS 6.0 Filter driver-0000.
Interface index 27 orresponding to QLogic BCM57840 10 Gigabit Ethernet (NDIS VBD Client) #130-QoS Packet Scheduler-0000.
Interface index 28 orresponding to QLogic BCM57840 10 Gigabit Ethernet (NDIS VBD Client) #130-WFP LightWeight Filter-0000.
Interface index 29 orresponding to WAN Miniport (IPv6)-Trend Micro NDIS 6.0 Filter driver-0000.
Interface index 30 orresponding to QLogic BCM57840 10 Gigabit Ethernet (NDIS VBD Client) #135-Trend Micro NDIS 6.0 Filter driver-0000.
Interface index 31 orresponding to QLogic BCM57840 10 Gigabit Ethernet (NDIS VBD Client) #135-QoS Packet Scheduler-0000.
Interface index 32 orresponding to QLogic BCM57840 10 Gigabit Ethernet (NDIS VBD Client) #135-WFP LightWeight Filter-0000.
Interface index 33 orresponding to WAN Miniport (Network Monitor)-QoS Packet Scheduler-0000.
Interface index 34 orresponding to QLogic BCM57840 10 Gigabit Ethernet (NDIS VBD Client) #128-Trend Micro NDIS 6.0 Filter driver-0000.
Interface index 35 orresponding to WAN Miniport (IP)-QoS Packet Scheduler-0000.
Interface index 36 orresponding to WAN Miniport (IP)-Trend Micro NDIS 6.0 Filter driver-0000.
Interface index 37 orresponding to WAN Miniport (IPv6)-QoS Packet Scheduler-0000.
But, don't know which "Interface Index" I need to mention in command line to generate output.
The error is,
./check_traffic.sh -V 1 -C nocgnr -H 172.16.1.105 -N "Interface index 20"
Can not get the interface index with Interface index 20 at 172.16.1.105.
Same error for Linux OS. Please see below.
#########################
./check_traffic.sh -V 1 -C public -H 172.16.1.73 -L
List Interface for host 172.16.1.73.
Interface index 1 orresponding to lo
Interface index 2 orresponding to enP4p1s0f0
Interface index 3 orresponding to enP4p1s0f1
Interface index 4 orresponding to eth1
Interface index 5 orresponding to eth2
Interface index 6 orresponding to virbr0
Interface index 7 orresponding to virbr0-nic
#########################
Please Guide.
Nishith N.Vyas
Owner's reply
./check_traffic.sh -V 1 -C nocgnr -H 172.16.1.105 -I 2,
or
./check_traffic.sh -V 1 -C nocgnr -H 172.16.1.105 -N eth0
You can get the full usage at: https://github.com/cloved/check_traffic/blob/master/README.md