You are here

protected function GitDirtyTreeSensorPlugin::runSensorCommand in Monitoring 8

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 GitDirtyTreeSensorPlugin::runSensorCommand()
GitDirtyTreeSensorPlugin::runSensor in src/Plugin/monitoring/SensorPlugin/GitDirtyTreeSensorPlugin.php
Runs the sensor, updating $sensor_result.

File

src/Plugin/monitoring/SensorPlugin/GitDirtyTreeSensorPlugin.php, line 273
Contains \Drupal\monitoring\Plugin\monitoring\SensorPlugin\GitDirtyTreeSensorPlugin.

Class

GitDirtyTreeSensorPlugin
Monitors the git repository for dirty files.

Namespace

Drupal\monitoring\Plugin\monitoring\SensorPlugin

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;
}