2000000, -> threshold free memory in kilobytes for status warning * 'critical' => 1000000 -> threshold free memory in kilobytes for status critical * ); * */ $CONFIG = array( 'warning' => 2000000, 'critical' => 1000000 ); // execute command exec('free', $output); // get result if (preg_match('/^Mem:\s+([0-9]+)\s+([0-9]+)\s+([0-9]+)\s/U', $output[1], $result)) { $memory['total'] = $result[1]; $memory['used'] = $result[2]; $memory['free'] = $result[3]; } // output result if ( $memory['free'] < $CONFIG['critical'] ) { echo 'FAILURE: '. $memory['free'] .' kilobytes free|performance:'. $memory['free']; } elseif ( $memory['free'] < $CONFIG['warning'] ) { echo 'WARNING: '. $memory['free'] .' kilobytes free|performance:'. $memory['free']; } else { echo 'OK: '. $memory['free'] .' kilobytes free|performance:'. $memory['free']; } ?>