Hi ..I have an urgent requirement to implement below logic:
-Create a daemon
-Daemon reads i/p file containing list of hosts on which checks are to be executed and picks up 10 hosts at a time.
-Daemon runs ping command via scp on remote host (a new thread is started for this host with some PID). If this check fails, the thread simply exits and doesn't proceed with the remaining checks.
-In case ping works fine, the thread initiates other checks one by one each of which invoke a wrapper script on the remote host. The wrapper script in turn chooses appropriate script to run based on the host architecture and platform.
-Output of all the checks is logged in a log file on the remote host. Warnings / Errors may be logged in a separate file for convenience.
-Daemon parallely initiates threads on remaining servers as well. At any given time, not more than 10 threads will be active.
-Once the daemon has completed one cycle of polling, eror log from every node will be conslidated and a mail will be sent.
I am not sure of how to implement above logic. All I know is how to create a basic daemon. Here is a code:
if($pid=fork()){
#This is parent#
#do some work#
exit 0;
}
elsif(!defined $pid){
#fork failed#
}
else{
#this is the child that will run as daemon#
setpgrp(0,0);
chdir('/');
#implement some additional logic
}
Could someone please provide me a basic framework in which I can implement my logic??
Any help is appreciated.