unless ($restart || $kill || $nosleep || $debug);
&handle_signals(); # Set up handlers, and signal the current server if asked
+
%CHECKFUNCS = ();
&load_checks();
+&debug("Done loading check modules",1);
# Pretty simple program, check the stuff that we are looking at, report it to
# the server, sleep, and do it all again...
+$0 = "spong-client";
+
while( 1 ) {
my ($check);
exit(0);
}
+ # Check to see if we are already running
+ &already_running();
+
# Write our pid to the spong tmp directory.
system( "echo $$ >$SPONGTMP/spong-client.pid" ) unless $nosleep;
}
+# This routine check to see if another instance of spong-server is already
+# running. If there is another instance, this instance will complain and die
+
+sub already_running {
+ # if there is a PID file
+ if ( -f "$SPONGTMP/spong-client.pid" ) {
+ # Read the pid
+ open( PID, "$SPONGTMP/spong-client.pid" ) || die "Can't open pid: $!";
+ my $pid = <PID>; chomp $pid;
+ close PID;
+
+ if ( kill 0,$pid ) {
+ &error("Spong-client is already running as pid $pid");
+ exit 1;
+ }
+ }
+}
+
+
# Output functions, one for debugging information, the other for errors.
};
foreach $check (split / /,$CHECKS) {
- &debug( "Loading client check $check" );
+ &debug( "Loading client check $check", 3 );
eval "require 'Spong/Client/plugins/check_$check';";
if ( $@ ) { &error( "Could not load $check check plugin" ); }
}