-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding d/p/25_check_snmp_int_add_metrik from upsgtream
- Loading branch information
Showing
2 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
From a0f606c2c29d1f5588fab0b464a7e905f3872255 Mon Sep 17 00:00:00 2001 | ||
From: Patrick Grimm <patrick@lunatiki.de> | ||
Date: Mon, 11 Mar 2024 18:28:15 +0100 | ||
Subject: [PATCH] add metrik for Interface speed K|M|G Bits/s and more comments | ||
|
||
--- | ||
doc/04-Plugins.md | 2 ++ | ||
plugins/check_snmp_int.pl | 20 ++++++++++++-------- | ||
2 files changed, 14 insertions(+), 8 deletions(-) | ||
|
||
diff --git a/doc/04-Plugins.md b/doc/04-Plugins.md | ||
index bf2a593..21b672a 100644 | ||
--- a/doc/04-Plugins.md | ||
+++ b/doc/04-Plugins.md | ||
@@ -211,10 +211,12 @@ Usage: ./check_snmp_int.pl [-v] -H <host> -C <snmp_community> [-2] | (-l login - | ||
warning level for input / output bandwidth (0 for no warning) | ||
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) | ||
+ warning level for interface speed only in K|M|G Bits/s (0 for no warning) | ||
-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 and interface speed is in bps | ||
critical for error & discard input / output in error/min (need -q) | ||
+ critical level for interface speed only in K|M|G Bits/s (0 for no critical) | ||
-s, --short=int | ||
Make the output shorter : only the first <n> chars of the interface(s) | ||
If the number is negative, then get the <n> LAST caracters. | ||
diff --git a/plugins/check_snmp_int.pl b/plugins/check_snmp_int.pl | ||
index d978c66..fd45a61 100755 | ||
--- a/plugins/check_snmp_int.pl | ||
+++ b/plugins/check_snmp_int.pl | ||
@@ -266,10 +266,12 @@ sub help { | ||
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) | ||
+ warning level for interface speed only in K|M|G Bits/s (0 for no warning) | ||
-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) | ||
+ critical level for interface speed only in K|M|G Bits/s (0 for no critical) | ||
-s, --short=int | ||
Make the output shorter : only the first <n> chars of the interface(s) | ||
If the number is negative, then get the <n> LAST caracters. | ||
@@ -955,16 +957,18 @@ sub check_options { | ||
if ($l == 0 || $l == 1) { $print_out .= $speed_unit; } | ||
} | ||
if (defined($o_perfs) && defined($o_ext_checkperf)) { | ||
+ my $warn_factor = (defined($o_meg)) ? 1000000 : (defined($o_gig)) ? 1000000000 : 1000; | ||
$print_out .= "/"; | ||
- if (defined($o_crit[6]) && ($o_crit[6] != 0) && ($speed_real < $o_crit[6])) { | ||
+ if (defined($o_crit[6]) && ($o_crit[6] != 0) && ($speed_real / $warn_factor < $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])) { | ||
+ $print_out .= sprintf("CRIT %.0f", $speed_real / $warn_factor); | ||
+ } elsif (defined($o_warn[6]) && ($o_warn[6] != 0) && ($speed_real / $warn_factor < $o_warn[6])) { | ||
$final_status = ($final_status == 2) ? 2 : 1; | ||
- $print_out .= sprintf("WARN %.0fbps", $speed_real); | ||
+ $print_out .= sprintf("WARN %.0f", $speed_real / $warn_factor); | ||
} else { | ||
- $print_out .= sprintf("%.0fbps", $speed_real); | ||
+ $print_out .= sprintf("%.0f", $speed_real / $warn_factor); | ||
} | ||
+ $print_out .= (defined($o_meg)) ? "Mbps" : (defined($o_gig)) ? "Gbps" : "kbps"; | ||
} | ||
$print_out .= ")"; | ||
} else { # Return unknown when no data | ||
@@ -1058,10 +1062,10 @@ sub check_options { | ||
$perf_out .= "'" . $descr[$i] . "_out_discard'=" . $$result{ $oid_perf_outdisc[$i] } . "c "; | ||
} | ||
if (defined($o_perfs)) { | ||
- $speed_real = "" unless (defined($speed_real)); | ||
+ my $warn_factor = (defined($o_meg)) ? 1000000 : (defined($o_gig)) ? 1000000000 : 1000; | ||
$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 .= defined($o_warn[6]) ? $o_warn[6] * $warn_factor . ";" : ";"; | ||
+ $perf_out .= defined($o_crit[6]) ? $o_crit[6] * $warn_factor . ";" : ";"; | ||
$perf_out .= "; "; | ||
} | ||
if (defined($o_weather) && $usable_data == 1) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters