Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there a way to list currently executing templates? 2

Status
Not open for further replies.

silverspecv

Programmer
Oct 31, 2003
125
US
I am getting occassional 100% cpu usage, which I suspect is just bad code. Is there a way to track it down? Maybe list currently loaded/executing templates?
 
ecobb wrote an faq about 100% processor. try here to see if this helps: faq232-3662

A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools.
-Douglas Adams (1952-2001)
 
I have read that, but I am still leaning toward bad code, or maybe not bad code, but excessively intense code. If there were a way to list currently executing CFM files, that would be very helpful. Especially if it also indicated how long each one had been loaded. If you're at 100% and a single cfm file has been running for 30 minutes, there is probably a bug. It could really be anything. This is under MX, btw.
 
In the CF Admin you can set your Timeout Requests, and it will keep a log of every query that runs longer than the timeout setting. It will also tell you the template that it was running.



Hope This Helps!

Ecobb
Beer Consumption Analyst

"My work is a game, a very serious game." - M.C. Escher
 
How about that, a solution so simple I have probably looked at the option twice a day for 3 years and hadn't even considered it.
 
I actually found it by accident, I had it turned on and just happend to see a log file entry for it one day.



Hope This Helps!

Ecobb
Beer Consumption Analyst

"My work is a game, a very serious game." - M.C. Escher
 
Yep, I wiped the logs, turned on the option, and now I will sit back and wait. Thanks for the tip!
 
Coming back to an old thread here.. well the log file idea didn't work. This app is written in fusebox 2 methodology, so all requests start out with the index.cfm file, and that is what it gives as the filename for all long requests. Any other ideas on determining which template is stuck in a loop?
 
silverspecv, I use two methods in trying to see which one of my cfm files are causing a server strain.

METHOD 1:
(which i wrote a FAQ for: faq232-5696)
I wrap each query in gettickcount() function. I log the begin time and the end time to see how long the query took. Sometimes it may be the query that is timing out and causing the page (or the site) to stall.

METHOD 2:
Create a table in your dB to log the values and place this file in your "Application.cfm". I found this snippet online but added some of my own code to make it slightly better.

Code:
<!--- pagetracker.cfm --->

<cfset currentpage = "#SCRIPT_NAME#">
<cfset nowdate = "#CreateODBCDateTime(Now())#">
<cfset yourdomain = "yourdomainname.com">

<cftry>
<cfif isDefined('http_user_agent')>
  <cfset browsertype = http_user_agent>
<cfelse>
  <cfset browsertype = 'unknown'>
</cfif>

<CFQUERY DATASOURCE="pagetracker" NAME="addnewpage">
  INSERT INTO pagetracker (pagename,dateloaded,browsertype)
  VALUES ('#currentpage#',#nowdate#,'#browsertype#')
</CFQUERY>

<cfcatch>
  <!--- used for error processing --->
  <cfset sendto = "webmaster@#yourdomain#">
  <cfset sendfrom = "webmaster@#yourdomain#">
  <cfset sendtitle = "problem with pagetracker">
  <cfset sendtext = "Current Page: #currentpage# Date:  #nowdate#">

    <CFMAIL FROM="#trim(sendfrom)#" TO="#trim(sendto)#" SUBJECT="#trim(sendtitle)#" type="html">
      <CFMAILPARAM name="Content-Transfer-Encoding" value="8bit">
      <CFMAILPARAM name="Mailer" value="#yourdomain#">
      <cfmailparam name="Message-id" value="<#CreateUUID()#@#yourdomain#>">
      <CFMAILPARAM Name="Reply-To" Value="#trim(sendfrom)#">
        #trim(sendtext)#<br>
        <cfdump var="#cfcatch#"><br>
        <cfdump var="#cgi#"><br>
      
        <cfif isdefined("cfhttp.filecontent")>
          <cfdump var="cfhttp.filecontent">
        </cfif>
    </cfmail>
</cfcatch>
</cftry>

What that does is it log all pages called within your application and see which one is dying or which one isn't being called. The <cfmail> tag will email you what page is the culprit. And you can take it from there.



____________________________________
Just Imagine.
 
I am getting occassional 100% cpu usage, which I suspect is just bad code. Is there a way to track it down? Maybe list currently loaded/executing templates?

I though about bad code for this issue a while back when I had this problem. >>> GUJUm0deL good idea on the save page time to table code...

Make sure your not storing sessions in registry. This will start as 100% cpu then end up causing crashes.

Of course this is stated in MX documentation but it wasn't me who setup CF and SQL durring our initial server setup... After making this modifcation I never had the 100% CPU issue happen again...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top