Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
You have 2 monitoring options, one is a daemon which tests the existence of the server's process. Like intelli-monitor.pl.

Here is something I did a while back in a similar vein, maybe it will give you some ideas. Maybe a 2 pronged approach, a daemon and an lwp script to test if the apache is locked up, or overloaded.

#!/usr/bin/perl -w #just run it. The first time it starts the daemon. If you try to start + it #a second time, it gives an error msg. Run it with any commandline arg +ument, # like "k" will kill all instances of the script use strict; use IO::Handle; use Proc::ProcessTable; use Proc::Daemon; my $t1 = new Proc::ProcessTable; my @pids; my $pid; foreach my $p (@{$t1->table}){ if($p->cmndline =~ /apache-monitor/){ $pid = $p->pid; #print "$pid\n"; push(@pids,$pid); #unless $pid == $$; } } ################################################### if (exists $ARGV[0]) { foreach $pid (@pids){ print "killing pid $pid\n"; kill 9,$pid; } } #################################################### if ($#pids > 0) { print "@pids already running!\n"; exit; } #################################################### Proc::Daemon::Init; #open(LOG,">>/var/log/apache-monitor.log") or die $!; #when run as roo +t open(LOG,">>/tmp/apache-monitor.log") or die $!; #for testing while (1){ my $ok =0; my $t = new Proc::ProcessTable; foreach my $p (@{$t->table}){ if($p->cmndline =~ /\/usr\/sbin\/httpd/){ print LOG time(),' ',$p->cmndline," already running!\n"; $ok=1;last; } } if ($ok == 0) {print LOG time(),' ',"failed!\n";} LOG->flush; sleep(15); }

I'm not really a human, but I play one on earth. flash japh

In reply to Re: [OT] Server Monitoring by zentara
in thread [OT] Server Monitoring by Jaap

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2021-10-24 18:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (89 votes). Check out past polls.

    Notices?