From d57bff6ef64af2fd1a55dc961d7aa0f2d9123aa9 Mon Sep 17 00:00:00 2001 From: hadaq Date: Wed, 28 Jan 2009 12:48:29 +0000 Subject: [PATCH] put in daemonize option. Sergey. --- plugins/check_lustre.pl | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/plugins/check_lustre.pl b/plugins/check_lustre.pl index 3d8ba4f..cf49ce2 100755 --- a/plugins/check_lustre.pl +++ b/plugins/check_lustre.pl @@ -24,8 +24,8 @@ use threads::shared; use IO::Socket; use IO::Select; -our ($opt_s, $opt_h); -getopts('hs'); +our ($opt_s, $opt_d, $opt_h); +getopts('hsd'); if($opt_h){ &showHelp(); @@ -39,7 +39,19 @@ my $sleep_time : shared = 600; # 10 minutes our $server_port = '50502'; our $protocol = 'tcp'; +#--- Daemonize +if($opt_d){ + open( STDIN, '/dev/null' ); + open( STDOUT, '>/dev/null' ); + open( STDERR, '>/dev/null' ); + + my $pid = fork(); + exit( 0 ) if ($pid); + die "ERROR: Cannot fork to background: $!\n" unless (defined( $pid )); +} + threads->new( \&statusServer ); + &main(); exit(0); @@ -185,8 +197,9 @@ sub showHelp a local machine. The script also runs a status server in a separate thread for reporting the status to Nagios. - Usage: check_lustre.pl [-s] [-h] + Usage: check_lustre.pl [-d] [-s] [-h] + -d : Run as a daemon. -s : Check also a disk space used on Lustre file system. -h : Print this help. -- 2.43.0