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();
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);
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.