You are here

function nagios_check_elysia_cron in Nagios Monitoring 8

Same name and namespace in other branches
  1. 7 nagios.module \nagios_check_elysia_cron()

Check when the Drupal cron system was last invoked.

Return value

array

File

./nagios.module, line 634
Main file for Nagios service monitoring.

Code

function nagios_check_elysia_cron() {
  $conn = Database::getConnection();
  $result = $conn
    ->query('SELECT * FROM {elysia_cron} WHERE last_aborted <> 0');
  $err_crons = [];
  foreach ($result as $blocked_cron) {
    $err_crons[] = $blocked_cron;
  }
  $text = '';
  foreach ($err_crons as $cron) {
    $text .= t('Elysia cron ":cron" last aborted on ":abort"' . PHP_EOL, [
      ':cron' => $cron->name,
      ':abort' => $cron->last_abort_function,
    ]);
  }
  if (!empty($err_crons)) {
    $data = [
      'status' => NAGIOS_STATUS_CRITICAL,
      'type' => 'state',
      'text' => $text,
    ];
  }
  else {
    $data = [
      'status' => NAGIOS_STATUS_OK,
      'type' => 'state',
      'text' => '',
    ];
  }
  return [
    'key' => 'ELYSIA_CRON',
    'data' => $data,
  ];
}