1
0

- 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
This commit is contained in:
Ruediger Oertel 2020-09-14 09:21:35 +00:00 committed by Git OBS Bridge
parent aa17aff8fb
commit 187627f6da
4 changed files with 100 additions and 8 deletions

View File

@ -0,0 +1,79 @@
From 6995b510759cf531d70745b7d0c6e8a0d9010b06 Mon Sep 17 00:00:00 2001
From: Christopher Odenbach <odenbach@uni-paderborn.de>
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 */

View File

@ -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.orig/plugins/check_swap.c
+++ monitoring-plugins-2.2/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; free_swap_mb += dskfree_mb;
if (allswaps) { if (allswaps) {
if (dsktotal_mb == 0) if (dsktotal_mb == 0)
- percent=100.0; - percent=100.0;
+ percent= 0.0; + percent = 0.0;
else else
percent = 100 * (((double) dskused_mb) / ((double) dsktotal_mb)); 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));

View File

@ -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 Mon Jul 15 08:05:45 UTC 2019 - lars@linux-schulserver.de - 2.2

View File

@ -1,7 +1,7 @@
# #
# spec file for package monitoring-plugins # 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 # All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed # remain the property of their copyright owners, unless otherwise agreed
@ -22,7 +22,7 @@ Release: 0
Summary: The Monitoring Plug-Ins Summary: The Monitoring Plug-Ins
License: GPL-2.0-or-later AND GPL-3.0-only License: GPL-2.0-or-later AND GPL-3.0-only
Group: System/Monitoring Group: System/Monitoring
Url: http://monitoring-plugins.org/ URL: http://monitoring-plugins.org/
Source0: %{name}-%{version}.tar.bz2 Source0: %{name}-%{version}.tar.bz2
Source1: %{name}-rpmlintrc Source1: %{name}-rpmlintrc
Source11: %{name}-permissions Source11: %{name}-permissions
@ -70,12 +70,14 @@ Patch6: %{name}-1.4.6-no_chown.patch
Patch11: %{name}.check_snmp.arrayaddress.patch Patch11: %{name}.check_snmp.arrayaddress.patch
# PATCH-FIX-UPSTREAM print out all arguments out a Group if in verbose mode # PATCH-FIX-UPSTREAM print out all arguments out a Group if in verbose mode
Patch15: %{name}-too_few_arguments_for_check_disk.patch 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 # PATCH-FIX-UPSTREAM port should be integer, not character
Patch118: %{name}.check_hpjd.c-64bit-portability-issue.patch Patch118: %{name}.check_hpjd.c-64bit-portability-issue.patch
# PATCH-FIX-UPSTREAM kstreitova@suse.com -- fix build with MariaDB 10.2 # PATCH-FIX-UPSTREAM kstreitova@suse.com -- fix build with MariaDB 10.2
Patch119: monitoring-plugins-2.2-mariadb_102_build_fix.patch 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: bind-utils
BuildRequires: dhcp-devel BuildRequires: dhcp-devel
BuildRequires: fping BuildRequires: fping
@ -1114,9 +1116,10 @@ done
%patch11 -p1 %patch11 -p1
%patch15 -p1 %patch15 -p1
# Debian patches # Debian patches
%patch116 -p1
%patch118 -p1 %patch118 -p1
%patch119 -p1 %patch119 -p1
%patch120 -p1
%patch121 -p1
find -type f -exec chmod 644 {} + find -type f -exec chmod 644 {} +
%build %build