The only problem with ${ProcessInstanceCount} is you do not have the ability to set your thresholds separate from each other (e.g. greater than x = critical and less than y=critical, or less than y = warning and greater than x = critical). We frequently use this for Java process counts, where if there are more than X it is critical, but if the count falls under Y it is also critical.
This script allows the component status to be changed on exit for these variables as well.