Clear questions and runnable code
get the best and fastest answer
Re: How do you check the status of a given server?by techgrrl (Sexton)
|on Feb 20, 2013 at 04:51 UTC||Need Help??|
I think roboticus said it fairly well, check the services it provides.
Without knowing more about the server it is hard to get more specific.
To add a little more detail. You can ping most servers to see if they have a healthy network stack, either by using system calls or backticks (not my first choice) or by using Net::ICMP. To use the `backtick` method enclose any valid system command in backticks and the output of the command will be assigned to the variable. It is messy, and you often lose return codes from the commands, but it is simple.
To use any of the ICMP modules such as Net::Ping let your friend CPAN explain everything, but feel free to ask again when you have a more specific question.
You can also monitor a server via SNMP. Most servers respond to the OID system.sysuptime.0.
If you don't know what an OID is, read the Net::SNMP documentation. In order to use SNMP, you'll need to find a SNMP package and read the docs, something like Net::SNMP or SNMP::Simple. From a Unix host you can also call the Net-SNMP using the system call or `snmpget $args` like in the above code example, but again, that is probably not the best way to do it. Generally I prefer to use modules like Net::SNMP.
If the server has a web server running, using LWP::Simple to get a test document is pretty easy.
If you have CGI enabled on the web server, you can write a CGI to run some health checks, and then use LWP::Simple to get the web page.
For example if you have a perl script called health.cgi, you can run any commands you want to check the servers health and print out valid html, and then from another machine run a perl script using LWP::Simple to get http://your-server.com/health.cgi
Think about those things to get started, and if you have more specific questions, feel free to ask again.
I hope this helps you get started.