15, -> number of running processes as threshold for status warning * 'critical' => 20, -> number of running processes as threshold for status critical * 'process' => 'apache' -> label of the process to match within the 'ps -efa' command output * ); */ $CONFIG = array( 'warning' => 15, 'critical' => 20, 'process' => 'apache' ); // exec command $command = "ps -efa | grep ". $CONFIG['process'] ." | wc -l"; exec($command, $output); // output result $count = trim($output[0]); if ($CONFIG['critical'] > 0 and $count >= $CONFIG['critical']) { echo 'FAILURE: '. $count .' '. $PROCESS .' processes|performance:'. $count; } elseif ($CONFIG['warning'] > 0 and $count >= $CONFIG['warning']) { echo 'WARNING: '. $count .' '. $CONFIG['process'] .' processes|performance:'. $count; } else { echo 'OK: '. $count .' '. $CONFIG['process'] .' processes|performance:'. $count; } ?>