919 - 926 - 9847

Quick and dirty uptime monitor

Although we use FusionReactor to determine the health of our servers on our team, the environment as a whole is still monitored by another group. And they cannot access FusionReactor. Our previous method of monitoring just a URL worked fine when the servers were not clustered. Now, however, you can't really be sure what instance you're on. Therefore, we get false up/down messages for a specific instance.

What I've done is this, I've got a new monitor.cfm file such as the one below:

    System = createObject("java","java.lang.System");
JRun = createObject("java","jrunx.kernel.JRun");
<cfset this_servername = JRun.getServerName()>
    Instance: #this_servername#<br>
    Server Name: #cgi.Server_Name#<br>
<!--- Change timeout behavior if more than one instance is displayed --->
<cfif isdefined('url.all')>
    <cfset timeoutBehavior=15>
    <cfset timeoutBehavior=28>
<!--- Ensure that url.instance is defined --->
<cfparam name="url.instance" default="all">

<cfif url.instance EQ 'someinstance' or url.instance EQ 'all'>
<cfset sStatus="">
<cfhttp method="get"

        <cfcatch type="any"><cfset sStatus="bad"></cfcatch>
<b>SOMEINSTANCE 1 - status</b> <cfif sStatus EQ "bad">Down<cfelse>Up</cfif>
<cfif sStatus EQ "" OR sStatus EQ "good">

This code calls out to a file sitting within the instances built-in web server path. Since I need to leave this enabled to effectively manage the instance anyway, it's a good way to test that it's "alive". That monitor.cfm file contains:

    System = createObject("java","java.lang.System");
JRun = createObject("java","jrunx.kernel.JRun");

<cfinclude template="Duration.cfm">
<cfset uptime = duration(server.coldfusion.expiration,now())><br>
<cfoutput>#uptime.days# Day(s) #uptime.hours# Hour(s) #uptime.minutes# Minute(s)</cfoutput><br>

<cfset this_servername = JRun.getServerName()>
<cfoutput>Instance: #this_servername#</cfoutput>

This display the instance information, and uses the UDF duration call (from CFLIB) to get the uptime count for the server. This information is then used within the first monitor call to display uptime status.

Why bother? Well, I need some type of text on the page to tell the monitor (soon to be Nagios) that my instances are up. And near as I can tell, this is the only accurate way to do so. It's not pretty, I admit, but it gets the job done.

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)