The command line statistics program supplied with ColdFusion, cfstat, has never worked for me. I’ve never tried it on Windows, but I have tried it on Linux on versions 6 and 7, and now version 8.

A little digging around told me why it never worked in CFMX 6-7. Apparently the cfstat script was looking for a particular jar file using a relative path – so it only worked if you were calling it from within the ColdFusion installation directory, which I guess I never did. Looking at the cfstat script in version 8, I can see they specify the full path.

But cfstat still wasn’t working for me in CF8, I got this error message:

Could not contact the ColdFusion Application Server running on this machine:
     Perhaps ColdFusion is not running on this machine?
     Perhaps cfstat is not enabled from the ColdFusion administrator?
     Perhaps ColdFusion was not restarted after enabling cfstat?
     Perhaps cfstat service is not listening on default port?
       Use option -port with port number as per the cfstatport
       defined in the neo-metrics xml file.

I realized I hadn’t checked the Enable CFSTAT button in the CF administrator, so I did that and restarted ColdFusion. Still got the same error message.

After googing around a while I found mention of someone who had a similar issue – they couldn’t get the Enable CFSTAT checkbox to stay checked after CF restarts. He fixed it by editing the neo-metric.xml file and changing the <var name='cfstat'><number>1.0</number></var> setting to be <var name='cfstat'><string>true</string></var>. Mine was already set to the string “true”, so that wasn’t it. But I did notice the cfstatport setting looked funny: <var name='cfstatport'><number>1.0</number></var>. There was a neo-metric.bak file on my server, so I compared the two, and found that in the bak file the setting was <var name='cfstatport'><string>7999</string></var>. I changed my neo-metric.xml file to reflect this and restarted CF. It worked!

I can’t be sure but this server may have been upgraded from CF7, instead of a fresh install, and that might have contributed to the problem.

Also, here is a (Linux only) tip: To have cfstat run every X seconds and continually refresh, use this command “watch -nX ./cfstat”, where X is how many seconds between refreshes. I’m new to cfstat – so if there is a better way to do this please let me know.

3 Comments

  1. Charlie Arehart says:

    Hey Ryan, I’ll throw out a couple more points. If you do set that port value to 7999, be careful that you are not running CF7, as that is the default value it uses. (CF6 used 8103, but as of CF7 you can change it using those XML entries you mention.) Also, if one does change it to other than 7999, then you have to use the -port option on the CFSTAT command to specify that value.

  2. Bill Wheatley says:

    you can just do cfstat X (X being a # of seconds to wait before refresh)

  3. Brad Melendy says:

    Unfortunately, this continues to be a problem with version 9.  I've tried everything I've read here plus other stuff and can't get the options for CFSTAT or Performance Monitoring to stay selected.  Very frustrating because I can't use CFSTAT on my Coldfusion 9 servers.  My Coldfusion 8 servers do work correctly with CFSTAT.