Posted in ColdFusion | Posted on 07-25-2007 | 3,806 views
So this isn't exactly old news, but while I've played quite a bit with the new Server Monitor in ColdFusion 8, I never really took a good look at the Alerts section. This week I finally took some time to play with alerts. Alerts are a great way to monitor your box without having to have the Server Monitor constantly running in a browser window. As you can guess, alerts will monitor various different things on your server and let you know if something goes wrong.
Out of the box you can monitor the following:
- Unresponsive Server: Checks your server to see if it is acting up and not responding well.
- Slow Server: Lets you see if the average response time for a request is more than a threshold amount.
- JVM Memory: Let's you throw an alert if the amount of memory being used goes over a certain amount.
- Timeouts: This is an interesting one. It lets you fire an alert if you have X amount of timeouts within Y seconds.
When an alert is fired, you have a variety of options. Some of the alert types have slightly different options, but in general they all allow for:
- Sending an Email.
- Dumping a snapshot. This is the same as the manual snapshots you can perform in the Server Monitor.
- Kill threads that take longer than a certain amount.
- Reject new requests
There is also another option which is pretty darn cool. An alert can trigger an "Alert CFC." This is a CFC that you write that contains two methods: onAlertStart and onAlertEnd. This allows you to do any custom handling of the alert that you want. You could log to the database. You could use the Instant Messenger Event Gateway to send you an IM. You can send an SMS message. The point is - you aren't limited to the options listed above. You can basically handle the alert with anything ColdFusion can do.
You can browse alerts in the Server Monitor as well:

The above screen shows that I have one alert. Double clicking on the alert lets me see the snapshot since I enabled that option. ColdFusion will also alert you when the status reverts to normal:

In order for snapshots to work, you must enable Server Monitoring, which as Charlie has blogged will add minimal overhead to your server. I also pinged Adobe about any impact from alerts in general and was told there was no impact that folks would need to be concerned about.
I'm currently using this myself - mainly to monitor the issues I've had lately with ColdFusionBloggers but also for curiosity's sake as well. Is anyone out there using this yet? Anyone written a custom alert CFC? (Would folks like to see an example of one?)


If the number of threads specified by Hung Thread Count execute for longer than the time specified by Busy Thread Time, the server is considered to be unresponsive.
So I think the idea is that the server is up - just acting badly.
a) the screen does not tell you which directory to place your .cfc in. After many trials it worked in \jrun4\bin
b) onAlertEnd() is working for me, i just do a CFDUMP of #arguments.theAlert# where theAlert is an argument that i defined and passed into the function. (the data type is a structure)
c) i'm having problems getting onAlertStart() event to trigger; this would be useful to me so I don't have to wait for the GC to finish before getting text'd
<cffunction name="onAlertEnd" access="public" returntype="string">
<cfargument name="structAlert" type="struct" required="yes">
<cfset vServerAlias = "DEVBOX")>
<cfmail from="CFIDE [#vServerAlias#]"
to="jchahine@bcbsm.com"
subject="JVM GC is FINISHED on #UCASE(vServerAlias)#"
type="html"
>
<p>JVM garbage cleanup on #UCASE(vServerAlias)# is finished.<p>
<cfdump var="#ARGUMENTS.structAlert#">
</cfmail>
<cfset myResult="1">
<cfreturn myResult>
</cffunction>
</cfcomponent>
I'm not showing the onAlertStart() because I didn't get it to kickoff yet. Still troubleshooting that.
mystuff.mycfcname
as your CFC.
i got onAlertStart() to work... (it turns out i had a typo in my email address so I didn't get the alert)
I also configured a CF Mapping "BIN" to where the .cfc resides (in jrun4\bin), but when I referenced BIN.CFCNAME in the alert config screen, nothing happened. No biggie though, as long as I share with my team where the .cfc resides we're good to go!
[Add Comment] [Subscribe to Comments]