Performance Monitoring
CPU-USAGE ( -- %)
(CPU-USAGE) ( ms -- %)
Monitors the CPU usage for one second. The resulted value (in percents) is placed on a stack.
Example:
#( test_cpuusage
\ printing CPU usage to console once a minute
Action:
CPU-USAGE . ." %" CR
)#
Use (CPU-USAGE) word if you want to set the time (in ms) during which CPU usage should be monitored.
Example:
#( test_cpuusage1 \ printing CPU usage to console once a minute Action: \ monitoring CPU usage for 10 seconds 10000 (CPU-USAGE) . ." %" CR )#
You can change the value of the VALUE-variable CpuMeasurementTime as well (default value - 1000 ms).
Example:
#( test_cpuusage2 \ printing CPU usage to console once a minute Action: CpuMeasurementTime \ placing the old value to the stack 5000 TO CpuMeasurementTime \ setting new value (5000 ms) \ monitoring CPU usage for 5 seconds CPU-USAGE . ." %" CR TO CpuMeasurementTime \ reverting to old value )#
These words only work in WinNT/2000/XP.
Returns TRUE (-1) if computer's idle time is greater then or equal to a specified amount of seconds. A computer is considered idle when its user gives no signs of activity, i.e. does not move or click the mouse and doesn't press keys on the keyboard. User's activity can be emulated: see sections "Keyboard Input Emulation" and "Mouse Activity Emulation".
#( test_idle
\ computer is idle for 10 minutes
Rule: IDLE: 600
Action:
MSG: "Back to the work!"
)#
To access the idle time counter, use word GetIdleTime, which puts on stack the computer's idle time in milliseconds.
It should be noted that the counter incrementation will start only after word IDLE: is been used in some task or after idle time counting has been initiated specifically:
<% InitIdleHook %> #( test_idle1 RunOnce NoDel Action: 60 0 DO LOG: "log\idle.log" "Idle time: %GetIdleTime%" PAUSE: 1000 LOOP )#
Operating system may interfere with operation or the word IDLE: If a console window is open (e.g. Command Prompt, FAR etc.), Windows "ignores" user's actions and idle time counter goes on despite of user's activities.
When a console window is open, Window 9* ignores only keyboard input, but it correctly processes actions performed with the mouse. Win2000 ignores both.
PROC-CPU-USAGE ( a u -- %)
(PROC-CPU-USAGE) ( a u ms -- %)
Monitors the CPU usage produced by specified process for one second. The resulted value (in percents) is placed on a stack. Use the name of an executable file to specify the name of the process. If the specified process does not exists the words PROC-CPU-USAGE/(PROC-CPU-USAGE) return 0.
Example:
#( test_proccpuusage \ printing CPU usage produced by 'notepad.exe' \ to console once a minute Action: S" notepad.exe" PROC-CPU-USAGE . ." %" CR )#
Use (PROC-CPU-USAGE) word if you want to set the time (in ms) during which CPU usage should be monitored.
Example:
#( test_proccpuusage1 \ printing CPU usage produced by 'notepad.exe' \ to console once a minute Action: \ monitoring CPU usage for 10 seconds S" notepad.exe" 10000 (PROC-CPU-USAGE) . ." %" CR )#
You can change the value of the VALUE-variable CpuMeasurementTime as well (default value - 1000 ms).
Example:
#( test_proccpuusage2 \ printing CPU usage produced by 'notepad.exe' \ to console once a minute Action: CpuMeasurementTime \ placing the old value to the stack 5000 TO CpuMeasurementTime \ setting new value (5000 ms) \ monitoring CPU usage for 5 seconds S" notepad.exe" PROC-CPU-USAGE . ." %" CR TO CpuMeasurementTime \ reverting to old value )#
These words only work in WinNT/2000/XP.
WatchCPUUsage: <CPUUsage%> <seconds>
This word is triggered when CPU usage exceeds the specified level (in percents) for a specified time (in seconds).
Example:
#( test_watchcpuusage WatchCPUUsage: 95 10 Action: MSG: "CPU usage exceeds 95%% for 10 seconds!" )#
This word only works in WinNT/2000/XP. You should set nncron.ini variable PerfMonitor to ON for this word to works properly.
See also: