views:

83

answers:

3

I am rolling my own simple web-based perfmon, I am not happy with some of the data I can get like cpu usage, which i use via a sql query. I am able to get memory usage just fine...I will attach a screenshot, so you can see what I currently have for my main/home/dashboard page.

I am currently using webcharts3d, which i am loving being able to use ajax, update the chart, and i have a dynamically updating dashboard. Yes of course I have to get only a few performance counter's so in my desire to have a web-based performance dashboard i do not kill the server.

DECLARE @CPU_BUSY int, @IDLE int
SELECT @CPU_BUSY = @@CPU_BUSY, @IDLE = @@IDLE WAITFOR DELAY '000:00:01'
SELECT  (@@CPU_BUSY - @CPU_BUSY)/((@@IDLE - @IDLE + @@CPU_BUSY - @CPU_BUSY) *1.00) *100 AS 'CPU'

And all i get in results is 0.0000, so either the query is wrong, or i have very little cpu activity going on. Where as when I use my windows task manager.

Here is the code for gathering memory I am using, I do not claim credit for any of this code, I found it somewhere.

<cfscript>
      jRuntime = CreateObject("java","java.lang.Runtime").getRuntime();
      memory = StructNew();
      memory.freeAllocated = jRuntime.freeMemory() / 1024^2;
      memory.allocated = jRuntime.totalMemory() / 1024^2;
      memory.used = memory.allocated - memory.freeAllocated;
      memory.percentUsedAllo = (memory.used / memory.allocated) * 100;
</cfscript>

SysAdmin

So I am looking for more wmi or java or scripts to get cpu usage, and perhaps any other important server stat.

Thank You.

A: 

CfTracker probably has the code you need, and since it uses the Apache License you can simply grab any relevant stuff from it, once you attribute appropriately.

It would be even better if you could go a step further and talk to Dave Boyet about combining your two tools - or at least collaborating on the common bits.


To more directly answer your question, here's a blog article explaining how to use WMI from ColdFusion.

Peter Boughton
cftracker uses java, to get more java centric information, which my end users would not really understand which is why i am aiming for simple hardware based measurements, that at a glance can tell if there are problems.Thank You though.
crosenblum
If your users are sys admins they should really understand Java stuff as well as regular stuff, but anyway you possibly just missed my edit? I've just added a link to a WMI solution also, which should give you the "simple" stuff also?
Peter Boughton
I was looking there the last 2 days. I tried and tried but was not able to get that script to work. My users are not sysadmin, my end users are a programmer, and my boss, who is a former network admin.
crosenblum
CfTracker is only going to tell you what's going on with the Java instance. I've yet to even consider expanding it to cover the server itself yet. If you're going for the system as a whole, WMI is probably your best bet. Be careful though, I've had issues with periodically querying WMI, causing the WMI service to freeze up and require a restart.
Mister Dai
+1  A: 

How about using Coldfusion built-in function called, GetMetricData. It can help you to monitor your server performance like Coldfusion Admin. I've done it with bar of cfchart. If you wanna integrate with Web3Dcharts, you can.

http://ppshein.wordpress.com/2010/08/04/getmetricdata-for-server-monitor/

<cfset pmData = GetMetricData(“PERF_MONITOR”) >
<cfchart chartheight=”500″ chartwidth=”700″ format=”PNG” showlegend=”yes”>
    <cfchartseries type=”bar” seriescolor=”##639526″ paintstyle=”light” colorlist=”##ff8080,##ffff80,##80ff80,##0080ff,##ff80c0,##ff80ff,##ff8040,##008000,##0080c0,##808000″>
        <cfchartdata item=”Page Hits” value=”#pmData.PageHits#”>
        <cfchartdata item=”Request Queued” value=”#pmData.ReqQueued#”>
        <cfchartdata item=”Database Hits” value=”#pmData.DBHits#”>
        <cfchartdata item=”Request Running” value=”#pmData.ReqRunning#”>
        <cfchartdata item=”Request TimedOut” value=”#pmData.ReqTimedOut#”>
        <cfchartdata item=”Bytes In” value=”#pmData.BytesIn#”>
        <cfchartdata item=”Bytes Out” value=”#pmData.BytesOut#”>
        <cfchartdata item=”Avg Queue Time” value=”#pmData.AvgQueueTime#”>
        <cfchartdata item=”Avg Request Time” value=”#pmData.AvgReqTime#”>
        <cfchartdata item=”Avg Database Time” value=”#pmData.AvgDBTime#”>
    </cfchartseries>
</cfchart>
ppshein
I already have that information, i need cpu usage, and to get that i must get it thru wmi or java.
crosenblum
Be careful using GetMetricData(), it doesn't work on CF enterprise when installing in multi-server mode.
Mister Dai
+1  A: 

Another solution:

Then using the Reliability and Performance Monitor (i.e. perfmon), create a counter for CPU (Total) - it should be in the long list of Windows counters.

You can save this data to file or to a database. If you save it to a database you can then use CF to query that data and get pretty accurate performance info. You can of course display this on a graph over time which is a massive benefit in my opinion.

When you have that done you can then enable performance monitoring in CF admin, and you will then have CF performance metrics available to pick up in perfmon.

We have successfully implemented this solution across a CF cluster of 10+ machines and it gives a an excellent idea of server performance at a given point in time and historically.

Ciaran Archer
note that perfmon doesn't work for enterprise installations afaik
Antony
We use it for Enterprise CF right now.
Ciaran Archer