/** * Actions done before the DELETE of the item in the database / * Maybe used to add another check for deletion * * @return bool : true if item need to be deleted else false **/ function pre_deleteItem() { PluginMonitoringToolbox::logIfExtradebug('pm-ack', "acknowledge, pre_deleteItem : " . $this->fields['id'] . "\n"); $user = new User(); $user->getFromDB($this->fields['users_id']); $item = new $this->fields['itemtype'](); $item->getFromDB($this->fields['items_id']); $host_id = -1; $service_id = -1; if ($this->fields['itemtype'] == 'PluginMonitoringHost') { $host_id = $this->fields['items_id']; } else { $service_id = $this->fields['items_id']; } if ($host_id != -1) { // Acknowledge is to be deleted ... // ... send information to shinken via webservice $pmShinkenwebservice = new PluginMonitoringShinkenwebservice(); if ($pmShinkenwebservice->sendAcknowledge($host_id, -1, $user->getName(1), '', '', '', '', 'delete')) { // Set host as acknowledged // $pmHost = new PluginMonitoringHost(); // $pmHost->getFromDB($this->fields['plugin_monitoring_hosts_id']); // $item->setAcknowledged($this->fields['comment']); $a_services = $item->getServicesID(); if (is_array($a_services)) { foreach ($a_services as $service_id) { // Send acknowledge command for a service to shinken via webservice $pmShinkenwebservice = new PluginMonitoringShinkenwebservice(); if ($pmShinkenwebservice->sendAcknowledge(-1, $service_id, $user->getName(1), '', '', '', '', 'delete')) { // Set service as acknowledged // $pmService = new PluginMonitoringService(); // $pmService->getFromDB($service_id); // $pmService->setAcknowledged($this->fields['comment']); } } } Session::addMessageAfterRedirect(__('Acknowledge deletion notified to the monitoring application:', 'monitoring')); $this->fields['notified'] = 1; } else { Session::addMessageAfterRedirect(__('Acknowledge deletion has not been accepted by the monitoring application:', 'monitoring'), false, ERROR); // return false; } } else { // Send acknowledge command for a service to shinken via webservice $pmShinkenwebservice = new PluginMonitoringShinkenwebservice(); if ($pmShinkenwebservice->sendAcknowledge(-1, $service_id, $user->getName(1), '', '', '', '', 'delete')) { // Set service as acknowledged // $pmService = new PluginMonitoringService(); // $pmService->getFromDB($service_id); // $pmService->setAcknowledged($this->fields['comment']); Session::addMessageAfterRedirect(__('Acknowledge deletion notified to the monitoring application:', 'monitoring')); $this->fields['notified'] = 1; } else { Session::addMessageAfterRedirect(__('Acknowledge deletion has not been accepted by the monitoring application:', 'monitoring'), false, ERROR); // return false; } } return true; }
/** * Get modifications of resources (if have modifications); */ function configurationchangesMessage() { global $DB; $input = ''; $pmLog = new PluginMonitoringLog(); // Get id of last Shinken restart $id_restart = 0; $a_restarts = $pmLog->find("(`action`='restart' OR `action`='restart_planned')", "`id` DESC", 1); if (count($a_restarts) > 0) { $a_restart = current($a_restarts); $id_restart = $a_restart['id']; } // get number of modifications $nb_delete = 0; $nb_add = 0; $nb_update = 0; $nb_delete = countElementsInTable(getTableForItemType('PluginMonitoringLog'), "`id` > '" . $id_restart . "'\n AND `action`='delete'"); $nb_add = countElementsInTable(getTableForItemType('PluginMonitoringLog'), "`id` > '" . $id_restart . "'\n AND `action`='add'"); $nb_update = countElementsInTable(getTableForItemType('PluginMonitoringLog'), "`id` > '" . $id_restart . "'\n AND `action`='update'"); if ($nb_delete > 0 or $nb_add > 0 or $nb_update > 0) { $input .= __('The configuration has changed', 'monitoring') . "<br/>"; if ($nb_add > 0) { $input .= "<a onClick='Ext.get(\"added_elements\").toggle();'>" . $nb_add . "</a> " . __('resources added', 'monitoring'); echo "<div style='position:absolute;z-index:10;left: 50%;\n margin-left: -350px;margin-top:40px;display:none'\n class='msgboxmonit msgboxmonit-grey' id='added_elements'>"; $query = "SELECT * FROM `" . getTableForItemType('PluginMonitoringLog') . "`\n WHERE `id` > '" . $id_restart . "' AND `action`='add'\n ORDER BY `id` DESC"; $result = $DB->query($query); while ($data = $DB->fetch_array($result)) { echo "[" . Html::convDateTime($data['date_mod']) . "] Add " . $data['value'] . "<br/>"; } echo "</div>"; } if ($nb_delete > 0) { if ($nb_add > 0) { $input .= " / "; } $input .= "<a onClick='Ext.get(\"deleted_elements\").toggle();'>" . $nb_delete . "</a> " . __('resources deleted', 'monitoring'); echo "<div style='position:absolute;z-index:10;left: 50%;\n margin-left: -350px;margin-top:40px;display:none'\n class='msgboxmonit msgboxmonit-grey' id='deleted_elements'>"; $query = "SELECT * FROM `" . getTableForItemType('PluginMonitoringLog') . "`\n WHERE `id` > '" . $id_restart . "' AND `action`='delete'\n ORDER BY `id` DESC"; $result = $DB->query($query); while ($data = $DB->fetch_array($result)) { echo "[" . Html::convDateTime($data['date_mod']) . "] Delete " . $data['value'] . "<br/>"; } echo "</div>"; } if ($nb_update > 0) { if ($nb_add > 0 or $nb_delete > 0) { $input .= " / "; } $input .= "<a onClick='Ext.get(\"updated_elements\").toggle();'>" . $nb_update . "</a> " . __('resources updated', 'monitoring'); echo "<div style='position:absolute;z-index:10;left: 50%;\n margin-left: -350px;margin-top:40px;display:none'\n class='msgboxmonit msgboxmonit-grey' id='updated_elements'>"; $query = "SELECT * FROM `" . getTableForItemType('PluginMonitoringLog') . "`\n WHERE `id` > '" . $id_restart . "' AND `action`='update'\n ORDER BY `id` DESC"; $result = $DB->query($query); while ($data = $DB->fetch_array($result)) { echo "[" . Html::convDateTime($data['date_mod']) . "] Update " . $data['value'] . "<br/>"; } echo "</div>"; } $input .= "<br/>"; // Try to restart Shinken via webservice $pmShinkenwebservice = new PluginMonitoringShinkenwebservice(); $pmShinkenwebservice->sendRestartArbiter(); $input .= __('Shinken is restarted automatically', 'monitoring'); //$input .= __('Restart Shinken to reload this new configuration', 'monitoring'); } return $input; }
Plugin Monitoring for GLPI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Monitoring. If not, see <http://www.gnu.org/licenses/>. ------------------------------------------------------------------------ @package Plugin Monitoring for GLPI @author David Durieux @co-author @comment @copyright Copyright (c) 2011-2014 Plugin Monitoring for GLPI team @license AGPL License 3.0 or (at your option) any later version http://www.gnu.org/licenses/agpl-3.0-standalone.html @link https://forge.indepnet.net/projects/monitoring/ @since 2013 ------------------------------------------------------------------------ */ include "../../../inc/includes.php"; Session::checkRight("plugin_monitoring_restartshinken", READ); $pmShinkenwebservice = new PluginMonitoringShinkenwebservice(); if (isset($_GET["tag"])) { $pmShinkenwebservice->sendRestartArbiter(1, $_GET["tag"], isset($_GET["action"]) ? $_GET["action"] : 'reload'); } else { $pmShinkenwebservice->sendRestartArbiter(1); } Html::back();
it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Plugin Monitoring for GLPI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Monitoring. If not, see <http://www.gnu.org/licenses/>. ------------------------------------------------------------------------ @package Plugin Monitoring for GLPI @author David Durieux @co-author @comment @copyright Copyright (c) 2011-2013 Plugin Monitoring for GLPI team @license AGPL License 3.0 or (at your option) any later version http://www.gnu.org/licenses/agpl-3.0-standalone.html @link https://forge.indepnet.net/projects/monitoring/ @since 2013 ------------------------------------------------------------------------ */ include "../../../inc/includes.php"; PluginMonitoringProfile::checkRight("command", "w"); $pmShinkenwebservice = new PluginMonitoringShinkenwebservice(); $pmShinkenwebservice->sendRestartArbiter(1); Html::back();
/** * Actions done before the DELETE of the item in the database / * Maybe used to add another check for deletion * * @return bool : true if item need to be deleted else false **/ function pre_deleteItem() { // Toolbox::logInFile("pm-downtime", "Downtime, pre_deleteItem\n"); $user = new User(); $user->getFromDB($this->fields['users_id']); // Downtime is to be created ... // ... send information to shinken via webservice $pmShinkenwebservice = new PluginMonitoringShinkenwebservice(); if ($pmShinkenwebservice->sendDowntime($this->fields['plugin_monitoring_hosts_id'], -1, $user->getName(1), $this->fields['comment'], $this->fields['flexible'], $this->fields['start_time'], $this->fields['end_time'], $this->fields['duration_seconds'], 'delete')) { Session::addMessageAfterRedirect(__('Downtime deletion notified to the monitoring application:', 'monitoring')); $this->fields['notified'] = 1; } else { Session::addMessageAfterRedirect(__('Downtime deletion has not been accepted by the monitoring application:', 'monitoring'), false, ERROR); // return false; } return true; }
------------------------------------------------------------------------ @package Plugin Monitoring for GLPI @author David Durieux @co-author @comment @copyright Copyright (c) 2011-2013 Plugin Monitoring for GLPI team @license AGPL License 3.0 or (at your option) any later version http://www.gnu.org/licenses/agpl-3.0-standalone.html @link https://forge.indepnet.net/projects/monitoring/ @since 2013 ------------------------------------------------------------------------ */ include "../../../inc/includes.php"; PluginMonitoringProfile::checkRight("check", "w"); Html::header(__('Monitoring', 'monitoring'), $_SERVER["PHP_SELF"], "plugins", "monitoring", "acknowledge"); $pmService = new PluginMonitoringService(); if (isset($_POST['add'])) { $pmService->update($_POST); // Send acknowledge command to shinken via webservice $pmShinkenwebservice = new PluginMonitoringShinkenwebservice(); $pmShinkenwebservice->sendAcknowledge($_POST['id']); // "[date('U')] ACKNOWLEDGE_SVC_PROBLEM;Computer-11-debian;rrrrr-1;1;1;1;glpi;comment ddurieux\n" Html::redirect($_POST['referer']); } if (isset($_GET['id'])) { $pmService->addAcknowledge($_GET['id']); } Html::footer();