From 187627f6da1e337c598fa90ffba039bf16b05591fb360ebd3ca436ae7361a4e7 Mon Sep 17 00:00:00 2001 From: Ruediger Oertel Date: Mon, 14 Sep 2020 09:21:35 +0000 Subject: [PATCH] - add patch monitoring-plugins-check_swap-fix-n.patch check_swap fix behaviour for "-n" if 0 free swap is left from git commit 6995b510759cf531d70745b7d0c6e8a0d9010b06 (bug#1175828) - updated context in monitoring-plugins-wrong_return_in_check_swap.patch OBS-URL: https://build.opensuse.org/package/show/server:monitoring/monitoring-plugins?expand=0&rev=71 --- monitoring-plugins-check_swap-fix-n.patch | 79 +++++++++++++++++++ ...g-plugins-wrong_return_in_check_swap.patch | 6 +- monitoring-plugins.changes | 10 +++ monitoring-plugins.spec | 13 +-- 4 files changed, 100 insertions(+), 8 deletions(-) create mode 100644 monitoring-plugins-check_swap-fix-n.patch diff --git a/monitoring-plugins-check_swap-fix-n.patch b/monitoring-plugins-check_swap-fix-n.patch new file mode 100644 index 0000000..860d97c --- /dev/null +++ b/monitoring-plugins-check_swap-fix-n.patch @@ -0,0 +1,79 @@ +From 6995b510759cf531d70745b7d0c6e8a0d9010b06 Mon Sep 17 00:00:00 2001 +From: Christopher Odenbach +Date: Wed, 31 May 2017 14:15:47 +0200 +Subject: [PATCH] repaired "-n" behaviour. If run with "-n ok" a host which ran + completely out of swap space would return "ok" which is not desired. It + should only return "ok" if there is no swap space configured at all. + + +diff --git a/plugins/check_swap.c b/plugins/check_swap.c +index 4d5a4071..0ff0c770 100644 +--- a/plugins/check_swap.c ++++ b/plugins/check_swap.c +@@ -51,7 +51,7 @@ const char *email = "devel@monitoring-plugins.org"; + # define SWAP_CONVERSION 1 + #endif + +-int check_swap (int usp, float free_swap_mb); ++int check_swap (int usp, float free_swap_mb, float total_swap_mb); + int process_arguments (int argc, char **argv); + int validate_arguments (void); + void print_usage (void); +@@ -128,7 +128,7 @@ main (int argc, char **argv) + percent=100.0; + else + percent = 100 * (((double) dskused_mb) / ((double) dsktotal_mb)); +- result = max_state (result, check_swap (percent, dskfree_mb)); ++ result = max_state (result, check_swap (percent, dskfree_mb, dsktotal_mb)); + if (verbose) + xasprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent); + } +@@ -227,7 +227,7 @@ main (int argc, char **argv) + free_swap_mb += dskfree_mb; + if (allswaps) { + percent = 100 * (((double) dskused_mb) / ((double) dsktotal_mb)); +- result = max_state (result, check_swap (percent, dskfree_mb)); ++ result = max_state (result, check_swap (percent, dskfree_mb, dsktotal_mb)); + if (verbose) + xasprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent); + } +@@ -289,7 +289,7 @@ main (int argc, char **argv) + + if(allswaps && dsktotal_mb > 0){ + percent = 100 * (((double) dskused_mb) / ((double) dsktotal_mb)); +- result = max_state (result, check_swap (percent, dskfree_mb)); ++ result = max_state (result, check_swap (percent, dskfree_mb, dsktotal_mb)); + if (verbose) { + xasprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent); + } +@@ -328,7 +328,7 @@ main (int argc, char **argv) + + if(allswaps && dsktotal_mb > 0){ + percent = 100 * (((double) dskused_mb) / ((double) dsktotal_mb)); +- result = max_state (result, check_swap (percent, dskfree_mb)); ++ result = max_state (result, check_swap (percent, dskfree_mb, dsktotal_mb)); + if (verbose) { + xasprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent); + } +@@ -355,7 +355,7 @@ main (int argc, char **argv) + status = "- Swap is either disabled, not present, or of zero size. "; + } + +- result = max_state (result, check_swap (percent_used, free_swap_mb)); ++ result = max_state (result, check_swap (percent_used, free_swap_mb, total_swap_mb)); + printf (_("SWAP %s - %d%% free (%d MB out of %d MB) %s|"), + state_text (result), + (100 - percent_used), (int) free_swap_mb, (int) total_swap_mb, status); +@@ -372,10 +372,10 @@ main (int argc, char **argv) + + + int +-check_swap (int usp, float free_swap_mb) ++check_swap (int usp, float free_swap_mb, float total_swap_mb) + { + +- if (!free_swap_mb) return no_swap_state; ++ if (!total_swap_mb) return no_swap_state; + + int result = STATE_UNKNOWN; + float free_swap = free_swap_mb * (1024 * 1024); /* Convert back to bytes as warn and crit specified in bytes */ diff --git a/monitoring-plugins-wrong_return_in_check_swap.patch b/monitoring-plugins-wrong_return_in_check_swap.patch index 563b6a7..76436ca 100644 --- a/monitoring-plugins-wrong_return_in_check_swap.patch +++ b/monitoring-plugins-wrong_return_in_check_swap.patch @@ -33,12 +33,12 @@ Index: monitoring-plugins-2.2/plugins/check_swap.c =================================================================== --- monitoring-plugins-2.2.orig/plugins/check_swap.c +++ monitoring-plugins-2.2/plugins/check_swap.c -@@ -125,7 +125,7 @@ main (int argc, char **argv) +@@ -125,7 +125,7 @@ free_swap_mb += dskfree_mb; if (allswaps) { if (dsktotal_mb == 0) - percent=100.0; -+ percent= 0.0; ++ percent = 0.0; else percent = 100 * (((double) dskused_mb) / ((double) dsktotal_mb)); - result = max_state (result, check_swap (percent, dskfree_mb)); + result = max_state (result, check_swap (percent, dskfree_mb, dsktotal_mb)); diff --git a/monitoring-plugins.changes b/monitoring-plugins.changes index ababde1..97149ad 100644 --- a/monitoring-plugins.changes +++ b/monitoring-plugins.changes @@ -1,3 +1,13 @@ +------------------------------------------------------------------- +Mon Sep 14 10:57:53 CEST 2020 - ro@suse.de + +- add patch monitoring-plugins-check_swap-fix-n.patch + check_swap fix behaviour for "-n" if 0 free swap is left + from git commit 6995b510759cf531d70745b7d0c6e8a0d9010b06 + (bug#1175828) +- updated context in + monitoring-plugins-wrong_return_in_check_swap.patch + ------------------------------------------------------------------- Mon Jul 15 08:05:45 UTC 2019 - lars@linux-schulserver.de - 2.2 diff --git a/monitoring-plugins.spec b/monitoring-plugins.spec index cb5f2f5..0b205af 100644 --- a/monitoring-plugins.spec +++ b/monitoring-plugins.spec @@ -1,7 +1,7 @@ # # spec file for package monitoring-plugins # -# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2020 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -22,7 +22,7 @@ Release: 0 Summary: The Monitoring Plug-Ins License: GPL-2.0-or-later AND GPL-3.0-only Group: System/Monitoring -Url: http://monitoring-plugins.org/ +URL: http://monitoring-plugins.org/ Source0: %{name}-%{version}.tar.bz2 Source1: %{name}-rpmlintrc Source11: %{name}-permissions @@ -70,12 +70,14 @@ Patch6: %{name}-1.4.6-no_chown.patch Patch11: %{name}.check_snmp.arrayaddress.patch # PATCH-FIX-UPSTREAM print out all arguments out a Group if in verbose mode Patch15: %{name}-too_few_arguments_for_check_disk.patch -# PATCH-FIX-UPSTREAM see https://bugzilla.redhat.com/512559 -Patch116: %{name}-wrong_return_in_check_swap.patch # PATCH-FIX-UPSTREAM port should be integer, not character Patch118: %{name}.check_hpjd.c-64bit-portability-issue.patch # PATCH-FIX-UPSTREAM kstreitova@suse.com -- fix build with MariaDB 10.2 Patch119: monitoring-plugins-2.2-mariadb_102_build_fix.patch +# PATCH-FIX-UPSTREAM git 6995b510759cf531d70745b7d0c6e8a0d9010b06 +Patch120: monitoring-plugins-check_swap-fix-n.patch +# PATCH-FIX-UPSTREAM see https://bugzilla.redhat.com/512559 +Patch121: %{name}-wrong_return_in_check_swap.patch BuildRequires: bind-utils BuildRequires: dhcp-devel BuildRequires: fping @@ -1114,9 +1116,10 @@ done %patch11 -p1 %patch15 -p1 # Debian patches -%patch116 -p1 %patch118 -p1 %patch119 -p1 +%patch120 -p1 +%patch121 -p1 find -type f -exec chmod 644 {} + %build