You are here

protected function SensorGitDirtyTree::runSensorCommand in Monitoring 7

Run the command and set the status message and the status to the result.

Parameters

\Drupal\monitoring\Result\SensorResultInterface $result: Sensor result object.

string $cmd: Command we want to run.

Return value

array Output of executing the Shell command.

1 call to SensorGitDirtyTree::runSensorCommand()
SensorGitDirtyTree::runSensor in lib/Drupal/monitoring/Sensor/Sensors/SensorGitDirtyTree.php
Runs the sensor, updating $sensor_result.

File

lib/Drupal/monitoring/Sensor/Sensors/SensorGitDirtyTree.php, line 265
Contains \Drupal\monitoring\Sensor\Sensors\SensorGitDirtyTree.

Class

SensorGitDirtyTree
Monitors the git repository for dirty files.

Namespace

Drupal\monitoring\Sensor\Sensors

Code

protected function runSensorCommand(SensorResultInterface &$result, $cmd) {
  $exit_code = 0;
  $command = $this
    ->buildCommand($cmd);
  exec($command, $output, $exit_code);
  if ($exit_code > 0) {
    $result
      ->addStatusMessage('Non-zero exit code @exit_code for command @command', array(
      '@exit_code' => $exit_code,
      '@command' => $command,
    ));
    $result
      ->setStatus(SensorResultInterface::STATUS_CRITICAL);
  }
  return $output;
}