[nmglug] Script to check Apache

Andrew Farnsworth farnsaw at stonedoor.com
Thu Apr 17 05:40:58 PDT 2008


I don't normally respond to my own posts, but here is a perl one liner I 
googled up.

perl -MLWP -e 'print LWP::UserAgent->new->request(HTTP::Request->new(G
+ET=>"http://example.com"))->is_success()?"up\n":"down\n"'

Andrew Farnsworth

Andrew Farnsworth wrote:
> Perl has a complete http request module.  Just use it and then check the 
> return code and act based on that.  If not, you should use something 
> like wget or curl but you will need to RTFM to be sure you are checking 
> the correct results.
>
> Andrew Farnsworth
>
>
>
> Deepan wrote:
>   
>> Hi All,
>> I am looking for a script to check if Apache is up
>> and running, if not the script should send an
>> email automatically. The script has to be run from
>> a different machine (not from the machine that
>> runs apache). So it has to query for a http
>> address and if it receives any other reply that
>> 200 OK, it should send the email. Can you guys
>> suggest on how to go about ? Should I use curl ?
>> or wget ? or ping ? I can handle the email part
>> and cron part. If you guys have a similar script
>> please share it if possible.
>> Regards 
>> Deepan 
>> Sudoku Solver: http://www.sudoku-solver.net/ 
>>
>>
>> _______________________________________________
>> nmglug mailing list
>> nmglug at nmglug.org
>> https://nmglug.org/mailman/listinfo/nmglug
>>
>>   
>>     
>
> _______________________________________________
> nmglug mailing list
> nmglug at nmglug.org
> https://nmglug.org/mailman/listinfo/nmglug
>
>   




More information about the nmglug mailing list