public function check_status(thresholds $thresholds, $params = array())
 {
     global $DB;
     $count = $DB->count_records('task_adhoc');
     $result = new status_result();
     $result->status = $thresholds->check($count);
     $result->text = "{$count} ad-hoc tasks in queue";
     return $result;
 }
 public function check_status(thresholds $thresholds, $params = array())
 {
     global $DB;
     $count = $DB->count_records('events_queue_handlers');
     $result = new status_result();
     $result->status = $thresholds->check($count);
     $result->text = "{$count} events in queue";
     return $result;
 }
 public function check_status(thresholds $thresholds, $params = array())
 {
     if (!isset($params['task'])) {
         throw new invalid_service_exception("Task parameter required");
     }
     if (!($task = \core\task\manager::get_scheduled_task($params['task']))) {
         throw new invalid_service_exception("Task not found");
     }
     $result = new status_result();
     $lastrun = $task->get_last_run_time();
     if (!$lastrun) {
         $result->text = 'Task has never run';
         $result->status = service::NAGIOS_STATUS_UNKNOWN;
     } else {
         $timeelapsed = time() - $lastrun;
         $result->status = $thresholds->check($timeelapsed);
         $result->text = "Last ran at " . date(DATE_RSS, $lastrun) . ", {$timeelapsed} seconds ago";
     }
     return $result;
 }