Site going down in the middle of the night? Here is how to set up your own remote server monitor that will email your host support team (and even send you a text message!):
1. Install Coldfusion developer (it's free!) on one your development machines. It cannot go on the same server that is being monitored because if it goes down, so will the monitor (duh.) This step is easier said than done, but if you already have Coldfusion installed on a local machine then you don't have to worry about it.
2. Set up a mail server that coldfusion can access with the cfmail tag. The mail server cannot be located on the server that you are monitoring!
3. Copy & modify this simple code:
<!--- ServerMonitor.cfm --->
Testing the server...
<cftry>
<cfhttp url="http://www.yoursite.com" throwOnError="yes" redirect="no">
Success!
<cfcatch>
Monitor failure!
<!--- send email to host support team --->
<cfmail to="support@yourhost.com" from="youremail@yourOTHERhost.com" subject="Server Monitor Failure">
Our server, (INSERT YOUR SERVER NAME HERE), may be having troubles. Could you please check on it? Thank you!
</cfmail>
<!--- send text message to you --->
<cfmail to="SEE STEP 4" from="youremail@yourOTHERhost.com" subject="Server Monitor Failure">
Our server, (INSERT YOUR SERVER NAME HERE), may be having troubles. Could you please check on it? Thank you!
</cfmail>
</cfcatch>
</cftry>
4. Did you know you can send text messages with simple emails? You do now! Here is a list of providers and associated text-message email addresses:
AT&T Wireless
NUMBER@mmode.com
Cingular
NUMBER@mms.mycingular.com
Sprint
NUMBER@pm.sprint.com
T-Mobile
NUMBER@tmomail.net
Verizon
NUMBER@vzwpix.com
5. Schedule ServerMonitor.cfm (the above code) to run automatically every half hour (or something like that) in Coldfusion Administrator (or with Windows Task Sceduler). I say every half hour because if the server goes down you don't want to be recieving a million text messages or have your host support team get pissed at you. (p.s. it might be best to disable the text messaging option if you don't get unlimited text messages)
Now just remember to leave the machine on all night. That's it! No more worrying about checking your busy e-commerce site in the middle of the night, no more calling host support at 2am asking them to reboot the server :)
Sunday, October 14, 2007
Make your own remote server monitor!
Posted by Russ at 1:14 AM
Labels: coldfusion, server management
Subscribe to:
Post Comments (Atom)
1 comments:
Very cool! I am placing here in our Server of Test.
Post a Comment