That way you can start proactive monitoring of the machine (see problems before they make the server crash). If you change the html document into a php document, and make de php script test things like the database connection, filesystems etc., you can even test more aspects of the server. (2) If you use this on the local machine and the network is down or something between this box and it's edge server or something, you won't get the email and or it won't know there is an issue. Sendemail -s mailserverip -f -t -u 'Webserver down' -m 'The webserver is down' (1) if you are calling this on the local machine I guess it will tell you that apache died, though I wouldn't do it this way. If it is a webserver, it would look something like this: #!/bin/bash In the below example a page is requested from the webserver. Pinging is an option, but on many occasions a machine will be able to send a ping reply, while the actual server that it is all about is down. If your server is a publicly accessible webserver, there are some free services to monitor your website and alert you if it's down, search the web for free website monitoring to find some. For example, with AT&T, if you send an email to it will send the email to your phone. If your carrier provides an SMS email address, you can send the email to that address. If you don't have mailx, you'll have to replace that line with whatever command line email program you have and probably change the options. You can cron the script to run periodically. Mailx -s "Server $SERVERIP is down" -t "$NOTIFYEMAIL" < /dev/null If you have a separate server to run your check script on, something like this would do a simple Ping test to see if the server is alive: -c 3 $SERVERIP > /dev/null 2>&1
0 Comments
Leave a Reply. |