Re: Untitled

By Melodic Tapir, 11 Years ago, written in Perl, viewed 521 times. This paste is a reply to Untitled by Cream Coyote
URL http://pb.stoleyour.com/view/5fe4a72e 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. my $in_traffic_perf = $in_traffic;
  351. my $out_traffic_perf = $out_traffic;
  352.  
  353. if ( $in_traffic > 1024 ) {
  354.         $in_traffic = sprintf( "%.2f", $in_traffic / 1024 );
  355.         $in_prefix = "M";
  356. }
  357. if ( $out_traffic > 1024 ) {
  358.         $out_traffic = sprintf( "%.2f", $out_traffic / 1024 );
  359.         $out_prefix = "M";
  360. }
  361. if ( $in_traffic > 1024 * 1024 ) {
  362.         $in_traffic = sprintf( "%.2f", $in_traffic / 1024 * 1024 );
  363.         $in_prefix = "G";
  364. }
  365. if ( $out_traffic > 1024 * 1024 ) {
  366.         $out_traffic = sprintf( "%.2f",$out_traffic / 1024 * 1024 );
  367.         $out_prefix = "G";
  368. }
  369.  
  370. # Convert from kiloBytes to megaBytes
  371. $in_bytes  = sprintf( "%.2f", $in_bytes / 1024 );
  372. $out_bytes = sprintf( "%.2f", $out_bytes / 1024 );
  373.  
  374. $state = "OK";
  375.  
  376. # Added 20091209 by gj
  377. if ( $if_status != 1 ) {
  378.         $output = "Interface $iface_descr is down!";
  379.        
  380. }else{
  381.         $output =
  382.         "Average IN: "
  383.           . $in_traffic . $in_prefix . $suffix . " (" . $in_usage . "%), "
  384.           . "Average OUT: " . $out_traffic . $out_prefix . $suffix . " (" . $out_usage . "%) ";
  385.         $output .= "Total RX: $in_bytes $label, Total TX: $out_bytes $label";
  386. }
  387.  
  388. # Changed 20091209 gj
  389. if ( ( $in_usage > $crit_usage ) or ( $out_usage > $crit_usage ) or ( $if_status != 1 ) ) {
  390.         $state = "CRITICAL";
  391. }
  392.  
  393. if (   ( $in_usage > $warn_usage )
  394.         or ( $out_usage > $warn_usage ) && $state eq "OK" )
  395. {
  396.         $state = "WARNING";
  397. }
  398.  
  399. # Changed 20091209 gj
  400. $output = "$state - $output"
  401.   if ( $state ne "OK" );
  402.  
  403. # Changed 20091214 gj - commas should have been semi colons
  404. $output .=
  405. "|inBandwidth=" . $in_traffic_perf . "K" . $suffix . " outBandwidth=" . $out_traffic_perf . "K" . $suffix;
  406.  
  407. stop($output, $state);
  408.  
  409.  
  410. sub fetch_Ip2IfIndex {
  411.         my $state;
  412.         my $response;
  413.  
  414.         my $snmpkey;
  415.         my $answer;
  416.         my $key;
  417.  
  418.         my ( $session, $host ) = @_;
  419.  
  420.  
  421.         # Determine if we have a host name or IP addr
  422.         if ( $host =~ /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/ ){
  423.                 #print "\nI found an IP address\n\n";
  424.         } else {
  425.                 $host = get_ip ( $host );
  426.                 #print "\nWe have a host name $host\n\n";
  427.         }
  428.  
  429.         # Quit if results not found
  430.         if ( !defined( $response = $session->get_table($snmpIPAdEntIfIndex) ) ) {
  431.                 $answer = $session->error;
  432.                 $session->close;
  433.                 $state = 'CRITICAL';
  434.                 $session->close;
  435.                 exit $STATUS_CODE{$state};
  436.         }
  437.  
  438.        
  439.         my %resp = %{$response};
  440. #       foreach $key ( keys %{$response} ) {
  441.  
  442.                 if ( $index_list ){
  443.                         print ("\nInterfaces found:\n");
  444.                         print ("  IP Addr\tIndex\n");
  445.                         print ("------------------------\n");
  446.                 }              
  447.         # Check each returned value
  448.         foreach $key ( keys %resp ) {
  449.  
  450.                 if ( $index_list ){
  451.                         my $index_addr = substr $key, 21;
  452.                         print ($index_addr,"\t ",$resp{$key},"\n");
  453.                 }
  454.  
  455.                 # Check for ip address mathcin in returned index results
  456.                 if ( $key =~ /$host$/ ) {
  457.                         $snmpkey = $resp{$key};
  458.                 }
  459.         }
  460.         unless ( defined $snmpkey ) {
  461.                 $session->close;
  462.                 $state = 'CRITICAL';
  463.                 printf "$state: Could not match $host \n";
  464.                 exit $STATUS_CODE{$state};
  465.         }
  466.         return $snmpkey;
  467. }
  468.  
  469. sub fetch_ifdescr {
  470.         my $state;
  471.         my $response;
  472.  
  473.         my $snmpkey;
  474.         my $answer;
  475.         my $key;
  476.  
  477.         my ( $session, $ifdescr ) = @_;
  478.  
  479.         if ( !defined( $response = $session->get_table($snmpIfDescr) ) ) {
  480.                 $answer = $session->error;
  481.                 $session->close;
  482.                 $state = 'CRITICAL';
  483.                 $session->close;
  484.                 exit $STATUS_CODE{$state};
  485.         }
  486.  
  487.         foreach $key ( keys %{$response} ) {
  488.  
  489.                 # added 20070816 by oer: remove trailing 0 Byte for Windows :-(
  490.                 my $resp=$response->{$key};
  491.                 $resp =~ s/\x00//;
  492.  
  493.  
  494.                 my $test = defined($use_reg)
  495.                       ? $resp =~ /$ifdescr/
  496.                       : $resp eq $ifdescr;
  497.  
  498.                 if ($test) {
  499.  
  500.                 ###if ( $resp =~ /^$ifdescr$/ ) {
  501.                 ###if ( $resp =~ /$ifdescr/ ) {
  502.                 ### print "$resp  \n";
  503.                 ###if ( $response->{$key} =~ /^$ifdescr$/ ) {
  504.  
  505.                         $key =~ /.*\.(\d+)$/;
  506.                         $snmpkey = $1;
  507.  
  508.                         # print "$ifdescr = $key / $snmpkey \n";  #debug
  509.                 }
  510.         }
  511.         unless ( defined $snmpkey ) {
  512.                 $session->close;
  513.                 $state = 'CRITICAL';
  514.                 printf "$state: Could not match $ifdescr \n";
  515.                 exit $STATUS_CODE{$state};
  516.         }
  517.         return $snmpkey;
  518. }
  519.  
  520. #added 20050416 by mw
  521. #Converts an input value to value in bits
  522. sub bits2bytes {
  523.         return unit2bytes(@_) / 8;
  524. }
  525.  
  526. #added 20050416 by mw
  527. #Converts an input value to value in bytes
  528. sub unit2bytes {
  529.         my ( $value, $unit ) = @_;
  530.  
  531.         if ( $unit eq "g" ) {
  532.                 return $value * 1024 * 1024 * 1024;
  533.         }
  534.         elsif ( $unit eq "m" ) {
  535.                 return $value * 1024 * 1024;
  536.         }
  537.         elsif ( $unit eq "k" ) {
  538.                 return $value * 1024;
  539.         }
  540.         elsif ( $unit eq "b" ) {
  541.                 return $value * 1;
  542.         }
  543.         else {
  544.                 print "You have to supply a supported unit\n";
  545.                 exit $STATUS_CODE{'UNKNOWN'};
  546.         }
  547. }
  548.  
  549. #added 20050414 by mw
  550. #This function detects if an overflow occurs. If so, it returns
  551. #a computed value for $bytes.
  552. #If there is no counter overflow it simply returns the origin value of $bytes.
  553. #IF there is a Counter reboot wrap, just use previous output.
  554. sub counter_overflow {
  555.         my ( $bytes, $last_bytes, $max_bytes ) = @_;
  556.  
  557.         $bytes += $max_bytes if ( $bytes < $last_bytes );
  558.         $bytes = $last_bytes  if ( $bytes < $last_bytes );
  559.         return $bytes;
  560. }
  561.  
  562. # Added 20100202 by gj
  563. # Print results and exit script
  564. sub stop {
  565.         my $result = shift;
  566.         my $exit_code = shift;
  567.         print $result . "\n";
  568.         exit ( $STATUS_CODE{$exit_code} );
  569. }
  570.  
  571. # Added 20100405 by gj
  572. # Lookup hosts ip address
  573. sub get_ip {
  574.         use Net::DNS;
  575.  
  576.         my ( $host_name ) = @_;
  577.  
  578.         my $res = Net::DNS::Resolver->new;
  579.         my $query = $res->search($host_name);
  580.  
  581.         if ($query) {
  582.                 foreach my $rr ($query->answer) {
  583.                         next unless $rr->type eq "A";
  584.                         #print $rr->address, "\n";
  585.                         return $rr->address;
  586.                 }
  587.         } else {
  588.                
  589.                 stop("Error: IP address not resolved\n","UNKNOWN");
  590.         }
  591. }
  592.  
  593. #cosmetic changes 20050614 by mw
  594. #Couldn't sustain "HERE";-), either.
  595. sub print_usage {
  596.         print <<EOU;
  597.     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 ]
  598.  
  599.     Example 1: check_iftraffic3.pl -H host1 -C sneaky
  600.     Example 2: check_iftraffic3.pl -H host1 -C sneaky -i "Intel Pro" -r -B  
  601.     Example 3: check_iftraffic3.pl -H host1 -C sneaky -i 5
  602.     Example 4: check_iftraffic3.pl -H host1 -C sneaky -i 5 -B -b 100 -u m
  603.     Example 5: check_iftraffic3.pl -H host1 -C sneaky -i 5 -B -b 20 -O 5 -u m
  604.     Example 6: check_iftraffic3.pl -H host1 -C sneaky -A 192.168.1.1 -B -b 100 -u m
  605.  
  606.     Options:
  607.  
  608.     -H, --host STRING or IPADDRESS
  609.         Check interface on the indicated host.
  610.     -B, --bits
  611.         Display results in bits per second b/s (default: Bytes/s)
  612.     -C, --community STRING
  613.         SNMP Community.
  614.     -r, --regexp
  615.         Use regexp to match NAME in description OID
  616.     -i, --interface STRING
  617.         Interface Name
  618.     -b, --bandwidth INTEGER
  619.     -I, --inBandwidth INTEGER
  620.         Interface maximum speed in kilo/mega/giga/bits per second.  Applied to
  621.         both IN and OUT if no second (-O) max speed is provided.
  622.     -O, --outBandwidth INTEGER
  623.         Interface maximum speed in kilo/mega/giga/bits per second.  Applied to
  624.         OUT traffic.  Uses the same units value given for -b.
  625.     -u, --units STRING
  626.         g=gigabits/s,m=megabits/s,k=kilobits/s,b=bits/s.  Required if -b, -I, or
  627.         -O are used.
  628.     -w, --warning INTEGER
  629.         % of bandwidth usage necessary to result in warning status (default: 85%)
  630.     -c, --critical INTEGER
  631.         % of bandwidth usage necessary to result in critical status (default: 98%)
  632.     -M, --max INTEGER
  633.         Max Counter Value of net devices in kilo/mega/giga/bytes.
  634.     -A, --address STRING (IP Address)
  635.         IP Address to use when determining the interface index to use.  Can be
  636.         used when the index changes frequently or as in the case of Windows
  637.         servers the index is different depending on the NIC installed.
  638.     -L, --list FLAG (on/off)
  639.         Tell plugin to list available interfaces. This is not supported inside
  640.         of Nagios, but may be useful from the command line.
  641. EOU
  642.  
  643. }

Reply to "Re: Untitled"

Here you can reply to the paste above