public static function QueryState(TaskEnvironment $env) { $state = ServiceState::Good; $lastIteration = ServiceState::GetLastIterationTime(); if ($lastIteration < time() - 60 * 60) { $state = ServiceState::Warning; } if ($lastIteration < time() - 12 * 60 * 60) { $state = ServiceState::Error; } return array('name' => 'Service Monitor', 'description' => 'Monitors the services run-time and distributes updates by e-mail in case of any warnings or errors.', 'state' => $state, 'subtasks' => array(array('name' => 'Service Iteration', 'date' => ServiceState::GetLastIterationTime(), 'value' => '\\o/'))); }
public function queryServiceStates() { $state = array('last_iteration' => ServiceState::GetLastIterationTime(), 'services' => array()); $environment = TaskEnvironment::GetInstance(); foreach ($this->m_services as $name) { $state['services'][$name] = array('details' => $name::QueryState($environment), 'tasks' => array()); foreach ($this->m_tasks as $task) { if ($task['service'] != $name) { continue; } $state['services'][$name]['tasks'][] = array('interval' => $task['interval'], 'last_execution' => ServiceState::GetLastExecutionTime($task), 'name' => implode('::', $task['callback']), 'unique_id' => $task['unique_id']); } } return $state; }