[monitoring-plugins] fix timeout issue with check_disk_smb

Sven Nierlein git at monitoring-plugins.org
Mon Mar 13 11:50:12 CET 2017


 Module: monitoring-plugins
 Branch: master
 Commit: 3b962208e790e859ce68346379020ca92251c0a2
 Author: Sven Nierlein <sven at nierlein.de>
   Date: Fri Mar 10 19:37:23 2017 +0100
    URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=3b96220

fix timeout issue with check_disk_smb

check_disk_smb hangs if the smbclient is still running. So send a sigint to all
childs and exit cleanly.

Signed-off-by: Sven Nierlein <sven at nierlein.de>

---

 plugins-scripts/check_disk_smb.pl | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/plugins-scripts/check_disk_smb.pl b/plugins-scripts/check_disk_smb.pl
index 9899226..28c49e8 100755
--- a/plugins-scripts/check_disk_smb.pl
+++ b/plugins-scripts/check_disk_smb.pl
@@ -19,7 +19,7 @@
 #
 
 require 5.004;
-use POSIX;
+use POSIX qw(setsid);
 use strict;
 use Getopt::Long;
 use vars qw($opt_P $opt_V $opt_h $opt_H $opt_s $opt_W $opt_u $opt_p $opt_w $opt_c $opt_a $verbose);
@@ -28,6 +28,9 @@ use FindBin;
 use lib "$FindBin::Bin";
 use utils qw($TIMEOUT %ERRORS &print_revision &support &usage);
 
+# make us session leader which makes all childs exit if we do
+setsid;
+
 sub print_help ();
 sub print_usage ();
 
@@ -175,6 +178,8 @@ my @lines = undef;
 # Just in case of problems, let's not hang the monitoring system
 $SIG{'ALRM'} = sub { 
 	print "No Answer from Client\n";
+    $SIG{'INT'} = 'IGNORE';
+    kill(-2, $$);
 	exit $ERRORS{"UNKNOWN"};
 };
 alarm($TIMEOUT);



More information about the Commits mailing list