I am trying to make a plugin to a website that would show the server's CPU load, disk space, free memory etc.
I did a research and in most of the cases they suggested using wmic for that as it allows remote connection what I'll need.
I'm using the following code to get the CPU load in percentage:
<cfexecute name="C:/Windows/system32/wbem/wmic.exe"
arguments="cpu get LoadPercentage /format:csv"
timeout=100 />
When I load the site it times out. I've checked the server and the process is still running. Is there a way to make it work?
Update: I've tried running WMIC as a different user, to make sure the problem is not coming from ColdFusion having insufficient rights. The code I'm using is the following:
<cfset Args='/user:*username* "C:\Windows\system32\wbem\wmic.exe cpu get LoadPercentage" | F:\Sanur\sanur.exe *password*'>
<cfdump var="#Args#">
<br />
<cfexecute
name="C:\Windows\system32\runas.exe"
arguments=#Args#
variable="result"
timeout=100
></cfexecute>
<cfdump var="#result#">
In this case it returns an [empty string] and does not start wmic.exe (checking task manager). If I try it without sanur I get the response below. I suspect the problem is using 2 commands in cfexecute arguments.
Enter the password for username: