Untitled

By Cream Coyote, 11 Years ago, written in Perl, viewed 950 times.
URL http://pb.stoleyour.com/view/2f04536a Embed
Download Paste or View RawExpand paste to full width of browser
  1. #!/usr/bin/perl -w
  2. #
  3. # check_iftraffic.pl - Nagios(r) network traffic monitor plugin
  4. # Copyright (C) 2004 Gerd Mueller / Netways GmbH
  5. # $Id: check_iftraffic.pl 1119 2006-02-09 10:30:09Z gmueller $
  6. #
  7. # mw = Markus Werner mw+nagios@wobcom.de
  8. # Remarks (mw):
  9. #
  10. #       I adopted as much as possible the programming style of the origin code.
  11. #
  12. #       There should be a function to exit this programm,
  13. #       instead of calling print and exit statements all over the place.
  14. #
  15. #
  16. # minor changes by mw
  17. #       The snmp if_counters on net devices can have overflows.
  18. #       I wrote this code to address this situation.
  19. #       It has no automatic detection and which point the overflow
  20. #       occurs but it will generate a warning state and you
  21. #       can set the max value by calling this script with an additional
  22. #       arg.
  23. #
  24. # minor cosmetic changes by mw
  25. #       Sorry but I couldn't sustain to clean up some things.
  26. #
  27. # gj = Greg Frater gregATfraterfactory.com
  28. # Remarks (gj):
  29. # minor (gj):
  30. #
  31. #       * fixed the performance data, formating was not to spec
  32. #       * Added a check of the interfaces status (up/down).
  33. #         If down the check returns a critical status.
  34. #       * Allow either textual or the numeric index value.
  35. #       * If the interface speed is not specified on the command line
  36. #         it gets it automatically from IfSpeed
  37. #       * Added option for second ifSpeed to allow for asymetrcal links
  38. #         such as a DSL line or cable modem where the download and upload
  39. #         speeds are different
  40. #       * Added -B option to display results in bits/sec instead of Bytes/sec
  41. #       * Added the current usage in Bytes/s (or bit/s) to the perfdata output
  42. #       * Added ability for plugin to determine interface to query by matching IP
  43. #         address of host with entry in ipAdEntIfIndex (.1.3.6.1.2.1.4.20.1.2)
  44. #       * Added -L flag to list entries found in the ipAdEntIfIndex table
  45. #       Otherwise, it works as before.
  46. #
  47. #
  48. #
  49. #
  50. # based on check_traffic from Adrian Wieczorek, <ads (at) irc.pila.pl>
  51. #
  52. # Send us bug reports, questions and comments about this plugin.
  53. # Latest version of this software: http://www.nagiosexchange.org
  54. #
  55. #
  56. # This program is free software; you can redistribute it and/or
  57. # modify it under the terms of the GNU General Public License
  58. # as published by the Free Software Foundation; either version 2
  59. # of the License, or (at your option) any later version.
  60. #
  61. # This program is distributed in the hope that it will be useful,
  62. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  63. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  64. # GNU General Public License for more details.
  65. #
  66. # You should have received a copy of the GNU General Public License
  67. # along with this program; if not, write to the Free Software
  68. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307
  69.  
  70. use strict;
  71.  
  72. use Net::SNMP;
  73. use Getopt::Long;
  74. &Getopt::Long::config('bundling');
  75.  
  76. use Data::Dumper;
  77.  
  78. my $host_ip;
  79. my $host_address;
  80. my $iface_number;
  81. my $iface_descr;
  82. my $iface_speed;
  83. my $iface_speedOut;
  84. my $index_list;
  85. my $opt_h;
  86. my $units;
  87.  
  88. my $session;
  89. my $error;
  90. my $port         = 161;
  91. my $snmp_version = 1;
  92.  
  93. my @snmpoids;
  94.  
  95. # SNMP OIDs for Traffic
  96. my $snmpIfOperStatus    = '1.3.6.1.2.1.2.2.1.8';
  97. my $snmpIfInOctets      = '1.3.6.1.2.1.2.2.1.10';
  98. my $snmpIfOutOctets     = '1.3.6.1.2.1.2.2.1.16';
  99. my $snmpIfDescr         = '1.3.6.1.2.1.2.2.1.2';
  100. my $snmpIfSpeed         = '1.3.6.1.2.1.2.2.1.5';
  101. my $snmpIPAdEntIfIndex  = '1.3.6.1.2.1.4.20.1.2';
  102.  
  103. my $response;
  104.  
  105. # Path to  tmp files
  106. my $TRAFFIC_FILE = "/tmp/traffic";
  107.  
  108. # changes sos 20090717 UNKNOWN must bes 3
  109. my %STATUS_CODE =
  110.   ( 'UNKNOWN' => '3', 'OK' => '0', 'WARNING' => '1', 'CRITICAL' => '2' );
  111.  
  112. #default values;
  113. my $state = "UNKNOWN";
  114. my $if_status = '4';
  115. my ( $in_bytes, $out_bytes ) = 0;
  116. my $warn_usage = 85;
  117. my $crit_usage = 98;
  118. my $COMMUNITY  = "public";
  119. my $use_reg    =  undef;  # Use Regexp for name
  120. my $output = "";
  121. my $bits = undef;
  122. my $suffix = "Bs";
  123. my $label = "MBytes";
  124.  
  125. #added 20050614 by mw
  126. my $max_value;
  127. my $max_bytes;
  128.  
  129. #cosmetic changes 20050614 by mw, see old versions for detail
  130. # Added options for bits and second max ifspeed 20100202 by gj
  131. # Added options for specificy IP addr to match 20100405 by gj
  132. my $status = GetOptions(
  133.         "h|help"        => \$opt_h,
  134.         'B'             => \$bits,
  135.         'bits'          => \$bits,
  136.         "C|community=s" => \$COMMUNITY,
  137.         "w|warning=s"   => \$warn_usage,
  138.         "c|critical=s"  => \$crit_usage,
  139.         "b|bandwidth|I|inBandwidth=i" => \$iface_speed,
  140.         "O|outBandwidth=i" => \$iface_speedOut,
  141.         'r'             => \$use_reg,          
  142.         'noregexp'      => \$use_reg,
  143.         "p|port=i"      => \$port,
  144.         "u|units=s"     => \$units,
  145.         "i|interface=s" => \$iface_descr,
  146.         "A|address=s"   => \$host_ip,
  147.         "H|hostname=s"  => \$host_address,
  148.         'L'             => \$index_list,
  149.         'list'          => \$index_list,
  150.  
  151.         #added 20050614 by mw
  152.         "M|max=i" => \$max_value
  153. );
  154.  
  155. if ( $status == 0 ) {
  156.         print_help();
  157.         exit $STATUS_CODE{'OK'};
  158. }
  159.  
  160. # Changed 20091214 gj
  161. # Check for missing options
  162. #if ( ( !$host_address ) or ( !$iface_descr ) ) {
  163. if ( !$host_address )  {
  164.         print  "\nMissing host address!\n\n";
  165.         stop(print_usage(),"OK");
  166. } elsif ( ( $iface_speed ) and ( !$units ) ){
  167.         print "\nMissing units!\n\n";
  168.         stop(print_usage(),"OK");
  169. } elsif ( ( $units ) and ( ( !$iface_speed ) and  ( !$iface_speedOut ) ) ) {
  170.         print "\nMissing interface maximum speed!\n\n";
  171.         stop(print_usage(),"OK");
  172. } elsif ( ( $iface_speedOut ) and ( !$units ) ) {
  173.         print "\nMissing units for Out maximum speed!\n\n";
  174.         stop(print_usage(),"OK");
  175. }
  176.  
  177.  
  178. if ($bits) {
  179.         $suffix = "bs"
  180. }
  181.  
  182. if ( !$iface_speed ) {
  183.         # Do nothing
  184. }else{
  185.  
  186.         #change 20050414 by mw
  187.         # Added iface_speedOut 20100202 by gj
  188.         # Convert interface speed to kiloBytes
  189.         $iface_speed = bits2bytes( $iface_speed, $units ) / 1024;
  190.         if ( $iface_speedOut ) {
  191.                 $iface_speedOut = bits2bytes( $iface_speedOut, $units ) / 1024;
  192.         }
  193.         if ( !$max_value ) {
  194.        
  195.                 # If no -M Parameter was set, set it to 32Bit Overflow
  196.                 $max_bytes = 4194304 ;    # the value is (2^32/1024)
  197.         }
  198.         else {
  199.                 $max_bytes = unit2bytes( $max_value, $units );
  200.         }
  201. }
  202.  
  203. if ( $snmp_version =~ /[12]/ ) {
  204.         ( $session, $error ) = Net::SNMP->session(
  205.                 -hostname  => $host_address,
  206.                 -community => $COMMUNITY,
  207.                 -port      => $port,
  208.                 -version   => $snmp_version
  209.         );
  210.  
  211.         if ( !defined($session) ) {
  212.                 stop("UNKNOWN: $error","UNKNOWN");
  213.         }
  214. }
  215. elsif ( $snmp_version =~ /3/ ) {
  216.         $state = 'UNKNOWN';
  217.         stop("$state: No support for SNMP v3 yet\n",$state);
  218. }
  219. else {
  220.         $state = 'UNKNOWN';
  221.         stop("$state: No support for SNMP v$snmp_version yet\n",$state);
  222. }
  223.  
  224. # Neither Interface Index nor Host IP address were specified
  225. if ( !$iface_descr ) {
  226.         if ( !$host_ip ){
  227.                 # try to resolve host name and find index from ip addr
  228.                 $iface_descr = fetch_Ip2IfIndex( $session, $host_address );
  229.         } else {
  230.                 # Use ip addr to find index
  231.                 $iface_descr = fetch_Ip2IfIndex( $session, $host_ip );
  232.         }      
  233. }
  234.  
  235. #push( @snmpoids, $snmpIPAdEntIfIndex . "." . $host_address );
  236.  
  237. # Added 20091209 gj
  238. # Detect if a string description was given or a numberic interface index number
  239. if ( $iface_descr =~ /[^0123456789]+/ ) {
  240.         $iface_number = fetch_ifdescr( $session, $iface_descr );
  241. }else{
  242.         $iface_number = $iface_descr;
  243. }
  244.  
  245. push( @snmpoids, $snmpIfSpeed . "." . $iface_number );
  246. push( @snmpoids, $snmpIfOperStatus . "." . $iface_number );
  247. push( @snmpoids, $snmpIfInOctets . "." . $iface_number );
  248. push( @snmpoids, $snmpIfOutOctets . "." . $iface_number );
  249.  
  250. if ( !defined( $response = $session->get_request(@snmpoids) ) ) {
  251.         my $answer = $session->error;
  252.         $session->close;
  253.  
  254.         stop("WARNING: SNMP error: $answer\n", "WARNING");
  255. }
  256.  
  257. # Added 20091209 gj
  258. # Get interface speed from device if not provided on command line
  259. # Convert to kiloBytes
  260. if ( !$iface_speed ) {
  261.         $iface_speed = $response->{ $snmpIfSpeed . "." . $iface_number };
  262.         $units = "b";
  263.         $iface_speed = bits2bytes( $iface_speed, $units ) / 1024;
  264. }
  265.  
  266. # Added 20100201 gj
  267. # Check if Out max speed was provided, use same if speed for both if not
  268. if (!$iface_speedOut) {
  269.         $iface_speedOut = $iface_speed;
  270. }
  271.  
  272. $if_status = $response->{ $snmpIfOperStatus . "." . $iface_number };
  273. $in_bytes  = $response->{ $snmpIfInOctets . "." . $iface_number } / 1024; # in kiloBytes
  274. $out_bytes = $response->{ $snmpIfOutOctets . "." . $iface_number } / 1024; # in kiloBytes
  275.  
  276. $session->close;
  277.  
  278. my $row;
  279. my $last_check_time = time - 1;
  280. my $last_in_bytes   = $in_bytes;
  281. my $last_out_bytes  = $out_bytes;
  282.  
  283. if (
  284.         open( FILE,
  285.                 "<" . $TRAFFIC_FILE . "_if" . $iface_number . "_" . $host_address
  286.         )
  287.   )
  288. {
  289.         while ( $row = <FILE> ) {
  290.  
  291.                 #cosmetic change 20050416 by mw
  292.                 #Couldn't sustain;-)
  293. ##              chomp();
  294.                 ( $last_check_time, $last_in_bytes, $last_out_bytes ) =
  295.                   split( ":", $row );
  296.  
  297.                 ### by sos 17.07.2009 check for last_bytes
  298.                 if ( ! $last_in_bytes  ) { $last_in_bytes=$in_bytes;  }
  299.                 if ( ! $last_out_bytes ) { $last_out_bytes=$out_bytes; }
  300.  
  301.                 if ($last_in_bytes !~ m/\d/) { $last_in_bytes=$in_bytes; }
  302.                 if ($last_out_bytes !~ m/\d/) { $last_out_bytes=$out_bytes; }
  303.         }
  304.         close(FILE);
  305. }
  306.  
  307. my $update_time = time;
  308.  
  309. open( FILE, ">" . $TRAFFIC_FILE . "_if" . $iface_number . "_" . $host_address )
  310.   or die "Can't open $TRAFFIC_FILE for writing: $!";
  311.  
  312. printf FILE ( "%s:%.0ld:%.0ld\n", $update_time, $in_bytes, $out_bytes );
  313. close(FILE);
  314.  
  315. my $db_file;
  316.  
  317. #added 20050614 by mw
  318. #Check for and correct counter overflow (if possible).
  319. #See function counter_overflow.
  320. $in_bytes  = counter_overflow( $in_bytes,  $last_in_bytes,  $max_bytes );
  321. $out_bytes = counter_overflow( $out_bytes, $last_out_bytes, $max_bytes );
  322.  
  323. # Calculate traffic since last check (RX\TX) in kiloBytes
  324. my $in_traffic = sprintf( "%.2lf",
  325.         ( $in_bytes - $last_in_bytes ) / ( time - $last_check_time ) );
  326. my $out_traffic = sprintf( "%.2lf",
  327.         ( $out_bytes - $last_out_bytes ) / ( time - $last_check_time ) );
  328.  
  329. # sos 20090717 changed  due to rrdtool needs bytes
  330. my $in_traffic_absolut  = $in_bytes * 1024 ;
  331. my $out_traffic_absolut = $out_bytes * 1024;
  332.  
  333. # Calculate usage percentages
  334. my $in_usage  = sprintf( "%.2f", ( 1.0 * $in_traffic * 100 ) / $iface_speed );
  335. my $out_usage = sprintf( "%.2f", ( 1.0 * $out_traffic * 100 ) / $iface_speedOut );
  336.  
  337.  
  338. if ($bits) {
  339.         # Convert output from Bytes to bits
  340.         $in_bytes = $in_bytes * 8;
  341.         $out_bytes = $out_bytes * 8;
  342.         $in_traffic = $in_traffic * 8;
  343.         $out_traffic = $out_traffic * 8;       
  344.         $label = "Mbits";
  345. }
  346.  
  347. my $in_prefix  = "K";
  348. my $out_prefix = "K";
  349.  
  350. if ( $in_traffic > 1024 ) {
  351.         $in_traffic = sprintf( "%.2f", $in_traffic / 1024 );
  352.         $in_prefix = "M";
  353. }
  354. if ( $out_traffic > 1024 ) {
  355.         $out_traffic = sprintf( "%.2f", $out_traffic / 1024 );
  356.         $out_prefix = "M";
  357. }
  358. if ( $in_traffic > 1024 * 1024 ) {
  359.         $in_traffic = sprintf( "%.2f", $in_traffic / 1024 * 1024 );
  360.         $in_prefix = "G";
  361. }
  362. if ( $out_traffic > 1024 * 1024 ) {
  363.         $out_traffic = sprintf( "%.2f",$out_traffic / 1024 * 1024 );
  364.         $out_prefix = "G";
  365. }
  366.  
  367. # Convert from kiloBytes to megaBytes
  368. $in_bytes  = sprintf( "%.2f", $in_bytes / 1024 );
  369. $out_bytes = sprintf( "%.2f", $out_bytes / 1024 );
  370.  
  371. $state = "OK";
  372.  
  373. # Added 20091209 by gj
  374. if ( $if_status != 1 ) {
  375.         $output = "Interface $iface_descr is down!";
  376.        
  377. }else{
  378.         $output =
  379.         "Average IN: "
  380.           . $in_traffic . $in_prefix . $suffix . " (" . $in_usage . "%), "
  381.           . "Average OUT: " . $out_traffic . $out_prefix . $suffix . " (" . $out_usage . "%) ";
  382.         $output .= "Total RX: $in_bytes $label, Total TX: $out_bytes $label";
  383. }
  384.  
  385. # Changed 20091209 gj
  386. if ( ( $in_usage > $crit_usage ) or ( $out_usage > $crit_usage ) or ( $if_status != 1 ) ) {
  387.         $state = "CRITICAL";
  388. }
  389.  
  390. if (   ( $in_usage > $warn_usage )
  391.         or ( $out_usage > $warn_usage ) && $state eq "OK" )
  392. {
  393.         $state = "WARNING";
  394. }
  395.  
  396. # Changed 20091209 gj
  397. $output = "$state - $output"
  398.   if ( $state ne "OK" );
  399.  
  400. # Changed 20091214 gj - commas should have been semi colons
  401. $output .=
  402. "|inBandwidth=" . $in_traffic . $in_prefix . $suffix . " outBandwidth=" . $out_traffic . $out_prefix . $suffix;
  403.  
  404. stop($output, $state);
  405.  
  406.  
  407. sub fetch_Ip2IfIndex {
  408.         my $state;
  409.         my $response;
  410.  
  411.         my $snmpkey;
  412.         my $answer;
  413.         my $key;
  414.  
  415.         my ( $session, $host ) = @_;
  416.  
  417.  
  418.         # Determine if we have a host name or IP addr
  419.         if ( $host =~ /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/ ){
  420.                 #print "\nI found an IP address\n\n";
  421.         } else {
  422.                 $host = get_ip ( $host );
  423.                 #print "\nWe have a host name $host\n\n";
  424.         }
  425.  
  426.         # Quit if results not found
  427.         if ( !defined( $response = $session->get_table($snmpIPAdEntIfIndex) ) ) {
  428.                 $answer = $session->error;
  429.                 $session->close;
  430.                 $state = 'CRITICAL';
  431.                 $session->close;
  432.                 exit $STATUS_CODE{$state};
  433.         }
  434.  
  435.        
  436.         my %resp = %{$response};
  437. #       foreach $key ( keys %{$response} ) {
  438.  
  439.                 if ( $index_list ){
  440.                         print ("\nInterfaces found:\n");
  441.                         print ("  IP Addr\tIndex\n");
  442.                         print ("------------------------\n");
  443.                 }              
  444.         # Check each returned value
  445.         foreach $key ( keys %resp ) {
  446.  
  447.                 if ( $index_list ){
  448.                         my $index_addr = substr $key, 21;
  449.                         print ($index_addr,"\t ",$resp{$key},"\n");
  450.                 }
  451.  
  452.                 # Check for ip address mathcin in returned index results
  453.                 if ( $key =~ /$host$/ ) {
  454.                         $snmpkey = $resp{$key};
  455.                 }
  456.         }
  457.         unless ( defined $snmpkey ) {
  458.                 $session->close;
  459.                 $state = 'CRITICAL';
  460.                 printf "$state: Could not match $host \n";
  461.                 exit $STATUS_CODE{$state};
  462.         }
  463.         return $snmpkey;
  464. }
  465.  
  466. sub fetch_ifdescr {
  467.         my $state;
  468.         my $response;
  469.  
  470.         my $snmpkey;
  471.         my $answer;
  472.         my $key;
  473.  
  474.         my ( $session, $ifdescr ) = @_;
  475.  
  476.         if ( !defined( $response = $session->get_table($snmpIfDescr) ) ) {
  477.                 $answer = $session->error;
  478.                 $session->close;
  479.                 $state = 'CRITICAL';
  480.                 $session->close;
  481.                 exit $STATUS_CODE{$state};
  482.         }
  483.  
  484.         foreach $key ( keys %{$response} ) {
  485.  
  486.                 # added 20070816 by oer: remove trailing 0 Byte for Windows :-(
  487.                 my $resp=$response->{$key};
  488.                 $resp =~ s/\x00//;
  489.  
  490.  
  491.                 my $test = defined($use_reg)
  492.                       ? $resp =~ /$ifdescr/
  493.                       : $resp eq $ifdescr;
  494.  
  495.                 if ($test) {
  496.  
  497.                 ###if ( $resp =~ /^$ifdescr$/ ) {
  498.                 ###if ( $resp =~ /$ifdescr/ ) {
  499.                 ### print "$resp  \n";
  500.                 ###if ( $response->{$key} =~ /^$ifdescr$/ ) {
  501.  
  502.                         $key =~ /.*\.(\d+)$/;
  503.                         $snmpkey = $1;
  504.  
  505.                         # print "$ifdescr = $key / $snmpkey \n";  #debug
  506.                 }
  507.         }
  508.         unless ( defined $snmpkey ) {
  509.                 $session->close;
  510.                 $state = 'CRITICAL';
  511.                 printf "$state: Could not match $ifdescr \n";
  512.                 exit $STATUS_CODE{$state};
  513.         }
  514.         return $snmpkey;
  515. }
  516.  
  517. #added 20050416 by mw
  518. #Converts an input value to value in bits
  519. sub bits2bytes {
  520.         return unit2bytes(@_) / 8;
  521. }
  522.  
  523. #added 20050416 by mw
  524. #Converts an input value to value in bytes
  525. sub unit2bytes {
  526.         my ( $value, $unit ) = @_;
  527.  
  528.         if ( $unit eq "g" ) {
  529.                 return $value * 1024 * 1024 * 1024;
  530.         }
  531.         elsif ( $unit eq "m" ) {
  532.                 return $value * 1024 * 1024;
  533.         }
  534.         elsif ( $unit eq "k" ) {
  535.                 return $value * 1024;
  536.         }
  537.         elsif ( $unit eq "b" ) {
  538.                 return $value * 1;
  539.         }
  540.         else {
  541.                 print "You have to supply a supported unit\n";
  542.                 exit $STATUS_CODE{'UNKNOWN'};
  543.         }
  544. }
  545.  
  546. #added 20050414 by mw
  547. #This function detects if an overflow occurs. If so, it returns
  548. #a computed value for $bytes.
  549. #If there is no counter overflow it simply returns the origin value of $bytes.
  550. #IF there is a Counter reboot wrap, just use previous output.
  551. sub counter_overflow {
  552.         my ( $bytes, $last_bytes, $max_bytes ) = @_;
  553.  
  554.         $bytes += $max_bytes if ( $bytes < $last_bytes );
  555.         $bytes = $last_bytes  if ( $bytes < $last_bytes );
  556.         return $bytes;
  557. }
  558.  
  559. # Added 20100202 by gj
  560. # Print results and exit script
  561. sub stop {
  562.         my $result = shift;
  563.         my $exit_code = shift;
  564.         print $result . "\n";
  565.         exit ( $STATUS_CODE{$exit_code} );
  566. }
  567.  
  568. # Added 20100405 by gj
  569. # Lookup hosts ip address
  570. sub get_ip {
  571.         use Net::DNS;
  572.  
  573.         my ( $host_name ) = @_;
  574.  
  575.         my $res = Net::DNS::Resolver->new;
  576.         my $query = $res->search($host_name);
  577.  
  578.         if ($query) {
  579.                 foreach my $rr ($query->answer) {
  580.                         next unless $rr->type eq "A";
  581.                         #print $rr->address, "\n";
  582.                         return $rr->address;
  583.                 }
  584.         } else {
  585.                
  586.                 stop("Error: IP address not resolved\n","UNKNOWN");
  587.         }
  588. }
  589.  
  590. #cosmetic changes 20050614 by mw
  591. #Couldn't sustain "HERE";-), either.
  592. sub print_usage {
  593.         print <<EOU;
  594.     Usage: check_iftraffic3.pl -H host [ -C community_string ] [ -i if_index|if_descr ] [ -r ] [ -b if_max_speed_in | -I if_max_speed_in ] [ -O if_max_speed_out ] [ -u ] [ -B ] [ -A IP Address ] [ -L ] [ -M ] [ -w warn ] [ -c crit ]
  595.  
  596.     Example 1: check_iftraffic3.pl -H host1 -C sneaky
  597.     Example 2: check_iftraffic3.pl -H host1 -C sneaky -i "Intel Pro" -r -B  
  598.     Example 3: check_iftraffic3.pl -H host1 -C sneaky -i 5
  599.     Example 4: check_iftraffic3.pl -H host1 -C sneaky -i 5 -B -b 100 -u m
  600.     Example 5: check_iftraffic3.pl -H host1 -C sneaky -i 5 -B -b 20 -O 5 -u m
  601.     Example 6: check_iftraffic3.pl -H host1 -C sneaky -A 192.168.1.1 -B -b 100 -u m
  602.  
  603.     Options:
  604.  
  605.     -H, --host STRING or IPADDRESS
  606.         Check interface on the indicated host.
  607.     -B, --bits
  608.         Display results in bits per second b/s (default: Bytes/s)
  609.     -C, --community STRING
  610.         SNMP Community.
  611.     -r, --regexp
  612.         Use regexp to match NAME in description OID
  613.     -i, --interface STRING
  614.         Interface Name
  615.     -b, --bandwidth INTEGER
  616.     -I, --inBandwidth INTEGER
  617.         Interface maximum speed in kilo/mega/giga/bits per second.  Applied to
  618.         both IN and OUT if no second (-O) max speed is provided.
  619.     -O, --outBandwidth INTEGER
  620.         Interface maximum speed in kilo/mega/giga/bits per second.  Applied to
  621.         OUT traffic.  Uses the same units value given for -b.
  622.     -u, --units STRING
  623.         g=gigabits/s,m=megabits/s,k=kilobits/s,b=bits/s.  Required if -b, -I, or
  624.         -O are used.
  625.     -w, --warning INTEGER
  626.         % of bandwidth usage necessary to result in warning status (default: 85%)
  627.     -c, --critical INTEGER
  628.         % of bandwidth usage necessary to result in critical status (default: 98%)
  629.     -M, --max INTEGER
  630.         Max Counter Value of net devices in kilo/mega/giga/bytes.
  631.     -A, --address STRING (IP Address)
  632.         IP Address to use when determining the interface index to use.  Can be
  633.         used when the index changes frequently or as in the case of Windows
  634.         servers the index is different depending on the NIC installed.
  635.     -L, --list FLAG (on/off)
  636.         Tell plugin to list available interfaces. This is not supported inside
  637.         of Nagios, but may be useful from the command line.
  638. EOU
  639.  
  640. }

Replies to Untitled rss

Title Name When
Re: Untitled Melodic Tapir 11 Years ago.

Reply to "Untitled"

Here you can reply to the paste above