Hey do you know how I can get the SERVER details information where coldfusion8 is running or any server within our network. I looked at the Server.Variables but that stuff is very basic. I need to get things like CPU type, RAM, Virtual Memory etc...Please help.
Now in general your code should be as portable as possible and shouldn’t care about the machine it’s running on. But there are definitely times when you need to know more about the environment your code is running in. Rey is correct that the Server scope provides a bit of this. You can see the operating system name and version along with other tidbits. You can also go down to Java if you want even more data. The java.lang.System object can reveal a lot of data about your system.
<cfset runtime = createObject("java", "java.lang.System")>
<cfset props = runtime.getProperties()>
<cfset env = runtime.getenv()>
Run this on your own machine to see what’s represented. Most of it should mimic what you see if you click the blue system info link in your ColdFusion admin. What’s missing is the amount of RAM. I did some googling but everything I found reflected the amount of total/available RAM for the JVM, not the box itself. Luckily a follower on Twitter, appleseedexm, pointed out another Java interface, OperatingSystemMXBean. He pointed out that this doesn’t work everywhere, but it worked for me. In order to get an instance of this interface you have to make an instance of a management factory:
<cfset mf = createObject("java", "java.lang.management.ManagementFactory")>
<cfset osbean = mf.getOperatingSystemMXBean()>
free physical mem = #osbean.getFreePhysicalMemorySize()#<br/>
total physical mem = #osbean.getTotalPhysicalMemorySize()#<br/>
For my laptop this returned:
free physical mem = 4512501760
total physical mem = 8519028736
Hope this helps!