in reply to To know the server life or not

You could use something like Netsaint or NMAP before trying to write one of your own. After all, a monitoring system is no good if it has more bugs than the software it's monitoring.

Both of these programs can be extended with scripting, so if you need something specific done, you can usually make them do what you want with a bit of work.