Skip to content

Latest commit

 

History

History
47 lines (38 loc) · 4.63 KB

README.md

File metadata and controls

47 lines (38 loc) · 4.63 KB

Process CPU Usage Monitor

A program to monitor CPU, memory, or handle resource usage of processes. The program exits when some resource usage metrics exceed a specified threshold. For Windows.

Use cases

If there is some process that occasionally misbehaves and starts hogging computer resources then you can use CPU Usage Monitor tool to launch corrective actions upon detection of the occurrence of the problem.

You can create a batch file which contains a loop and inside that loop two commands: the first command starts the CPU Usage Monitor tool. If the first command quits then that means that the trigger situation has been detected and therefore it is appropriate time for the second command to be executed. The second command would contain some corrective action. For example, the second command could:
    a) Kill and restart the misbehaving process.
    b) Send an email to the administrator.

Example batch file content:

@echo off
:s
CPUUsageMonitor.exe -cpuUsageThreshold=90 -handlesThreshold=75000 -memoryCommitThresholdMB=1024 -programRegEx="YourProblematicExecutableName"
pskill.exe "YourProblematicExecutableName"
ping -n 2 127.0.0.1
REM sleep 1
goto s

The above example monitors two resource usage metrics of a process called "YourProblematicExecutableName". Once ANY of the CPU usage percent metric, handle usage count metric, or the committed memory usage metric exceed the corresponding threshold, the process will be killed by the next command in the batch file. By default the trigger activates (that is, CPU Usage Monitor quits) when some of the thresholds is exceeded for 3 consequtive checks with 5 second intervals, and then the resource usage violation continues for another 30 seconds after that. If the monitored process resumes normal resource usage during that additional time interval then the trigger is reset and CPU Usage Monitor continues running without quitting.

State

Ready to use. Maintained and in active use.

Program arguments and their default values


-help (Shows help text)
-failIfNotResponding=True (Consider a process as failed when it is not responding.)
-cpuUsageThreshold= (Cpu usage threshold percent (inclusive) at which a program is considered as failed.)
-memoryCommitThresholdMB= (Memory commit threshold in MB (inclusive) at which a program is considered as failed.)
-workingSetThresholdMB= (Working set threshold in MB (inclusive) at which a program is considered as failed.)
-gdiHandlesThreshold= (GDI handles threshold (inclusive) at which a program is considered as failed.)
-userHandlesThreshold= (User handles threshold (inclusive) at which a program is considered as failed.)
-handlesThreshold= (Handles threshold (inclusive) at which a program is considered as failed.)
-pagedPoolThresholdKB= (Paged pool threshold in KB (inclusive) at which a program is considered as failed.)
-nonPagedPoolThresholdKB= (NonPaged pool threshold in KB (inclusive) at which a program is considered as failed.)
-applyCpuUsageThresholdPerCpu=True (Whether the Cpu Usage Threshold percent applies to capability of one cpu or capability of all cpu-s.)
-outageTimeBeforeGiveUpSeconds=30 (How long outage should last before trigger is activated and CPUUsageMonitor quits. NB! This timeout starts only after the failure count specified with -outageConditionNumChecks has been exceeded.)
-outageConditionNumChecks=3 (How many checks should fail before outage can be declared)
-passedCheckIntervalMs=10000 (How many ms to pause after a successful check)
-failedCheckIntervalMs=5000 (How many ms to pause after a failed check)
-programRegEx="regular expression" (Regular expression with process name. NB! Do not include file extension .exe! If regular expression matches multiple processes then if at least one process matching the given expression exceeds the cpu usage limit then the monitored program is considered as failed. Multiple regular expressions can be specified. In this case the program exits only after ALL monitored regular expressions have triggered.)
-failIfNoMatchingProcesses=False (Consider having no matching processes as a failure too. Trigger is still activated only after outage condition repeat counts and timeouts have passed.)
-executeCommandOnFail="" (Instead of quitting the monitor program, execute a command specified in this argument, and continue running the monitor program. To add execution arguments to this call, this argument must be the last one of the CPU Usage monitor arguments.)

Analytics