File: 23_check_snmp_int_interface_speed

package info (click to toggle)
nagios-snmp-plugins 2.1.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,732 kB
  • sloc: perl: 7,609; sh: 309; makefile: 50
file content (138 lines) | stat: -rw-r--r-- 7,545 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
diff --git a/doc/04-Plugins.md b/doc/04-Plugins.md
index c08fe9c..bf2a593 100644
--- a/doc/04-Plugins.md
+++ b/doc/04-Plugins.md
@@ -207,13 +207,13 @@ Usage: ./check_snmp_int.pl [-v] -H <host> -C <snmp_community> [-2] | (-l login -
    -G : Make the warning and critical levels in Gbps (with -B) or GBps
    -M : Make the warning and critical levels in Mbps (with -B) or MBps
    -u : Make the warning and critical levels in % of reported interface speed.
--w, --warning=input,output[,error in,error out,discard in,discard out]
+-w, --warning=input,output[,error in,error out,discard in,discard out,interface speed]
    warning level for input / output bandwidth (0 for no warning)
-     unit depends on B,M,G,u options
+     unit depends on B,M,G,u options and interface speed is in bps
    warning for error & discard input / output in error/min (need -q)
--c, --critical=input,output[,error in,error out,discard in,discard out]
+-c, --critical=input,output[,error in,error out,discard in,discard out,interface speed]
    critical level for input / output bandwidth (0 for no critical)
-     unit depends on B,M,G,u options
+     unit depends on B,M,G,u options and interface speed is in bps
    critical for error & discard input / output in error/min (need -q)
 -s, --short=int
    Make the output shorter : only the first <n> chars of the interface(s)
diff --git a/doc/html/nagios.manubulon.com/snmp_int.html b/doc/html/nagios.manubulon.com/snmp_int.html
index 8274a05..1c5f68f 100644
--- a/doc/html/nagios.manubulon.com/snmp_int.html
+++ b/doc/html/nagios.manubulon.com/snmp_int.html
@@ -337,13 +337,14 @@
             <p class="SectionBody">When the extended checks are activated (-q 
               option), the warning levels are <br>
               -w <i>&lt;In bytes&gt;</i>,<i>&lt;Out bytes&gt;</i>,<i>&lt;In error&gt;</i>,<i>&lt;Out 
-              error&gt;,<i>&lt;In disc&gt;</i>,<i>&lt;Out disc&gt;</i></i> -c 
+              error&gt;,<i>&lt;In disc&gt;</i>,<i>&lt;Out disc&gt;</i>,<i>&lt;Interface speed&gt;</i></i> -c 
               <i>&lt;In warn&gt;</i>,<i>&lt;Out warn&gt;</i>, .....<br>
               In error : warn/crit level in inboud <b>error/minute<br>
               </b>Out error : warn/crit level in outbound error/minute<b> </b><br>
               In disc : warn/crit level in inboud <b>discarded packets/minute<br>
-              </b>Out disc : warn/crit level in outbound discarded packets/minute<b> 
-              </b><br>
+              </b>Out disc : warn/crit level in outbound discarded packets/minute<b> </b><br>
+              Interface speed : warn/crit level of Interface speed <b>discarded bits/second<br>
+              </b>
             </p>
             <p class="SectionBody"><b>-k</b> : activates the standard usage feature<br>
               <b>-q</b> : activates the extended usage<br>
diff --git a/plugins/check_snmp_int.pl b/plugins/check_snmp_int.pl
index 71f8d14..d978c66 100755
--- a/plugins/check_snmp_int.pl
+++ b/plugins/check_snmp_int.pl
@@ -262,11 +262,11 @@ sub help {
    -G : Make the warning and critical levels in Gbps (with -B) or GBps
    -M : Make the warning and critical levels in Mbps (with -B) or MBps
    -u : Make the warning and critical levels in % of reported interface speed.
--w, --warning=input,output[,error in,error out,discard in,discard out]
+-w, --warning=input,output[,error in,error out,discard in,discard out,interface speed]
    warning level for input / output bandwidth (0 for no warning)
      unit depends on B,M,G,u options
    warning for error & discard input / output in error/min (need -q)
--c, --critical=input,output[,error in,error out,discard in,discard out]
+-c, --critical=input,output[,error in,error out,discard in,discard out,interface speed]
    critical level for input / output bandwidth (0 for no critical)
      unit depends on B,M,G,u options
    critical for error & discard input / output in error/min (need -q)
@@ -452,8 +452,8 @@ sub check_options {
     }
     if (defined($o_checkperf)) {
         @o_warn = split(/,/, $o_warn_opt);
-        if (defined($o_ext_checkperf) && ($#o_warn != 5)) {
-            print "6 warning levels for extended checks \n";
+        if (defined($o_ext_checkperf) && (($#o_warn < 5) || ($#o_warn > 6))) {
+            print "6 or 7 warning levels for extended checks err val: $#o_warn \n";
             print_usage();
             exit $ERRORS{"UNKNOWN"};
         }
@@ -465,8 +465,8 @@ sub check_options {
         @o_crit = split(/,/, $o_crit_opt);
 
         #verb(" $o_crit_opt :: $#o_crit : @o_crit");
-        if (defined($o_ext_checkperf) && ($#o_crit != 5)) {
-            print "6 critical levels for extended checks \n";
+        if (defined($o_ext_checkperf) && (($#o_crit < 5) || ($#o_crit > 6))) {
+            print "6 or 7 critical levels for extended checks err val: $#o_crit \n";
             print_usage();
             exit $ERRORS{"UNKNOWN"};
         }
@@ -476,10 +476,18 @@ sub check_options {
             exit $ERRORS{"UNKNOWN"};
         }
         for (my $i = 0; $i <= $#o_warn; $i++) {
-            if (($o_crit[$i] != 0) && ($o_warn[$i] > $o_crit[$i])) {
-                print "Warning must be < Critical level \n";
-                print_usage();
-                exit $ERRORS{"UNKNOWN"};
+            if ($i != 6) {
+                if (($o_crit[$i] != 0) && ($o_warn[$i] > $o_crit[$i])) {
+                    print "Warning must be < Critical level \n";
+                    print_usage();
+                    exit $ERRORS{"UNKNOWN"};
+                }
+            } else {
+                if (($o_crit[$i] != 0) && ($o_warn[$i] < $o_crit[$i])) {
+                    print "Warning must be > Critical level \n";
+                    print_usage();
+                    exit $ERRORS{"UNKNOWN"};
+                }
             }
         }
         if (   (defined($o_meg) && defined($o_gig))
@@ -946,6 +954,18 @@ sub check_options {
                 }
                 if ($l == 0 || $l == 1) { $print_out .= $speed_unit; }
             }
+            if (defined($o_perfs) && defined($o_ext_checkperf)) {
+                $print_out .= "/";
+                if (defined($o_crit[6]) && ($o_crit[6] != 0) && ($speed_real < $o_crit[6])) {
+                    $final_status = 2;
+                    $print_out .= sprintf("CRIT %.0fbps", $speed_real);
+                } elsif (defined($o_warn[6]) && ($o_warn[6] != 0) && ($speed_real < $o_warn[6])) {
+                    $final_status = ($final_status == 2) ? 2 : 1;
+                    $print_out .= sprintf("WARN %.0fbps", $speed_real);
+                } else {
+                    $print_out .= sprintf("%.0fbps", $speed_real);
+                }
+            }
             $print_out .= ")";
         } else {    # Return unknown when no data
             $print_out .= " No usable data on file (" . $n_rows . " rows) ";
@@ -1039,7 +1059,10 @@ sub check_options {
         }
         if (defined($o_perfs)) {
 	    $speed_real = "" unless (defined($speed_real));
-            $perf_out .= "'" . $descr[$i] . "_speed_bps'=" . $speed_real . " ";
+            $perf_out .= "'" . $descr[$i] . "_speed_bps'=" . $speed_real . ";";
+            $perf_out .= defined($o_warn[6]) ? $o_warn[6] . ";" : ";";
+            $perf_out .= defined($o_crit[6]) ? $o_crit[6] . ";" : ";";
+            $perf_out .= "; ";
         }
         if (defined($o_weather) && $usable_data == 1) {
             $perf_out .= "in=" . sprintf("%.0f", $checkperf_out_raw[0]) . ";;;0;" . sprintf("%.0f", $speed_real / 8) . " ";