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.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.