Entering a value into the Windows load

I wrote an image processing script in php that runs as a scheduled cron task (on OSX). To avoid system overload, the script checks the system load (using "uptime") and only runs when the load is below a predefined threshold.

I have now ported this to Windows (2003 Server) and am looking for a similar command line function to report the system load as an integer or float.

+1


source to share


5 answers


You can try this on Windows Command Prompt. This works in XP, gets a lot of other information.



wmic CPU

+1


source


Don't use a load ...

In this case, the system load is not a good indicator. On Unix, it essentially tells you how many processes are ready and waiting to run at the moment. But since there are many reasons a process can wait, your script can actually run without costing another process any performance, even if the "load" on the system is high.

... use nice



You must use nice(1)

the Unix equivalent on Windows ("Process Priority"?), So the OS can decide when to run the script!

If you set the priority of your script to the absolute lowest possible priority, it will only be executed by the scheduler if nothing else is done at the moment.

You will probably need to implement some mechanism to allow more than one instance of your script to run at the same time if it takes longer than the interval between calls.

+3


source


You can use a command line utility called pv to display the process name and% cpu usage over a period of time (default is 500ms) using this command line:

pve.exe -o"%n\t%c"

      

There is a toggle help -?

that describes the options available.

For OSX / linux it will take a little more work than running time as you will need to sum the numbers from the first column (or omit the process name and just sum the form value of each line of output) to get the total (in%) CPU usage.

On the other hand, with a little work, you might end up with a specific amount of CPU that your executing process is using, rather than the total CPU consumption.

0


source


WMI tests almost everything on Windows, including system boot.

I found a thread about this .

0


source


Just use the standard win32 apis (GTC)

0


source







All Articles