function sendDowntime($host_id = -1, $service_id = -1, $author = '', $comment = '', $flexible = '0', $start_time = '0', $end_time = '0', $duration = '3600', $operation = '') { global $DB; if ($host_id == -1 && $service_id == -1) { return false; } $pmTag = new PluginMonitoringTag(); $pmService = new PluginMonitoringService(); $pmService->getFromDB($service_id); $service_description = $pmService->getName(array('shinken' => '1')); $pmHost = new PluginMonitoringHost(); $pmHost->getFromDB($host_id == -1 ? $pmService->getHostID() : $host_id); $hostname = $pmHost->getName(true); // Downtime an host ... $acknowledgeServiceOnly = true; $a_fields = array(); if ($host_id == -1) { $tag = PluginMonitoringEntity::getTagByEntities($pmService->getEntityID()); } else { // ... one service of the host. $tag = PluginMonitoringEntity::getTagByEntities($pmHost->getEntityID()); } $ip = $pmTag->getIP($tag); $auth = $pmTag->getAuth($tag); $port = $pmTag->getPort($tag); $url = 'http://' . $ip . ':' . $port . '/'; $action = 'downtime'; $a_fields = array('action' => empty($operation) ? 'add' : $operation, 'host_name' => $hostname, 'service_description' => $service_description, 'author' => $author, 'comment' => mb_convert_encoding($comment, "iso-8859-1"), 'flexible' => $flexible, 'start_time' => PluginMonitoringServiceevent::convert_datetime_timestamp($start_time), 'end_time' => PluginMonitoringServiceevent::convert_datetime_timestamp($end_time), 'trigger_id' => '0', 'duration' => $duration); // Send downtime command ... return $this->sendCommand($url, $action, $a_fields, '', $auth); }