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); }
/** * Form to modify acknowledge of an host */ function showUpdateAcknowledgeForm($id=-1) { global $CFG_GLPI; Session::checkRight("plugin_monitoring_acknowledge", UPDATE); if ($id == -1) { $pm_Host = $this; } else { $pm_Host = new PluginMonitoringHost(); $pm_Host->getFromDB($id); } $hostname = $pm_Host->getName(); echo "<form name='form' method='post' action='".$CFG_GLPI['root_doc']."/plugins/monitoring/front/acknowledge.form.php'>"; echo "<input type='hidden' name='host_id' value='$id' />"; echo "<input type='hidden' name='hostname' value='$hostname' />"; echo "<input type='hidden' name='hostAcknowledge' value='$hostname' />"; echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_1'>"; echo "<th colspan='2'>"; echo __('Modify acknowledge for the host', 'monitoring').' : '.$pm_Host->getLink(); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>"; echo __('Acknowledge comment', 'monitoring'); echo "</td>"; echo "<td>"; echo "<textarea cols='80' rows='4' name='acknowledge_comment' >".$pm_Host->fields['acknowledge_comment']."</textarea>"; echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td colspan='2' align='center'>"; echo "<input type='hidden' name='id' value='".$pm_Host->fields['id']."' />"; echo "<input type='hidden' name='is_acknowledged' value='1' />"; echo "<input type='hidden' name='acknowledge_users_id' value='".$_SESSION['glpiID']."' />"; echo "<input type='hidden' name='referer' value='".$_SERVER['HTTP_REFERER']."' />"; echo "<tr class='tab_bg_1'>"; echo "<td>"; echo __('Acknowledge user', 'monitoring'); echo "</td>"; echo "<td>"; $user = new User(); $user->getFromDB($pm_Host->fields['acknowledge_users_id']); echo $user->getName(1); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td colspan='3' align='center'>"; echo "<input type='submit' name='update' value=\"".__('Update acknowledge comment', 'monitoring')."\" class='submit'>"; echo "</td>"; echo "</tr>"; echo "</table>"; Html::closeForm(); }