array('threshold' => 4, 'time' => 'past5'); * -> threshold for status warning => 4 of 'uptime' command output for past5 minutes, * other options are 'past1' or 'past15' * * 'critical' => array('threshold' => 5, 'time' => 'past5') * -> threshold for status critical => 5 of 'uptime' command output for past5 minutes, * other options are 'past1' or 'past15' * ); */ $CONFIG = array( 'warning' => array('threshold' => 4, 'time' => 'past5'), 'critical' => array('threshold' => 5, 'time' => 'past5') ); // exec command exec('uptime', $output); // get result if (preg_match('/average: ([0-9]+\.[0-9]{2}), ([0-9]+\.[0-9]{2}), ([0-9]+\.[0-9]{2})$/', $output[0], $result)) { $load['past1'] = $result[1]; $load['past5'] = $result[2]; $load['past15'] = $result[3]; } // output result if ( $load[ $CONFIG['critical']['time'] ] > $CONFIG['critical']['threshold'] ) { echo 'FAILURE: 1:'. $load['past1'] .' 5:'. $load['past5'] .' 15:'. $load['past15'] .'|performance:'. $load['past1']; } elseif ( $load[ $CONFIG['warning']['time'] ] > $CONFIG['warning']['threshold'] ) { echo 'WARNING: 1:'. $load['past1'] .' 5:'. $load['past5'] .' 15:'. $load['past15'] .'|performance:'. $load['past1']; } else { echo 'OK: 1:'. $load['past1'] .' 5:'. $load['past5'] .' 15:'. $load['past15'] .'|performance:'. $load['past1']; } ?>