function pluginMonitoringInstall($version) { global $DB, $LANG, $CFG_GLPI; // ** Insert in DB $DB_file = GLPI_ROOT . "/plugins/monitoring/install/mysql/plugin_monitoring-" . $version . "-empty.sql"; $DBf_handle = fopen($DB_file, "rt"); $sql_query = fread($DBf_handle, filesize($DB_file)); fclose($DBf_handle); foreach (explode(";\n", "{$sql_query}") as $sql_line) { if (get_magic_quotes_runtime()) { $sql_line = stripslashes_deep($sql_line); } if (!empty($sql_line)) { $DB->query($sql_line); } } include GLPI_ROOT . "/plugins/monitoring/inc/profile.class.php"; $pmProfile = new PluginMonitoringProfile(); $pmProfile->initProfile(); include GLPI_ROOT . "/plugins/monitoring/inc/command.class.php"; $pmCommand = new PluginMonitoringCommand(); $pmCommand->initCommands(); include GLPI_ROOT . "/plugins/monitoring/inc/notificationcommand.class.php"; $pmNotificationcommand = new PluginMonitoringNotificationcommand(); $pmNotificationcommand->initCommands(); include GLPI_ROOT . "/plugins/monitoring/inc/check.class.php"; $pmCheck = new PluginMonitoringCheck(); $pmCheck->initChecks(); include GLPI_ROOT . "/plugins/monitoring/inc/hostconfig.class.php"; $pmHostconfig = new PluginMonitoringHostconfig(); $pmHostconfig->initConfig(); include GLPI_ROOT . "/plugins/monitoring/inc/config.class.php"; $pmConfig = new PluginMonitoringConfig(); $pmConfig->initConfig(); $query = "UPDATE `glpi_plugin_monitoring_configs`\n SET `version`='" . PLUGIN_MONITORING_VERSION . "'\n WHERE `id`='1'"; $DB->query($query); if (!is_dir(GLPI_PLUGIN_DOC_DIR . '/monitoring')) { mkdir(GLPI_PLUGIN_DOC_DIR . "/monitoring"); } if (!is_dir(GLPI_PLUGIN_DOC_DIR . '/monitoring/templates')) { mkdir(GLPI_PLUGIN_DOC_DIR . "/monitoring/templates"); } if (!is_dir(GLPI_PLUGIN_DOC_DIR . '/monitoring/weathermapbg')) { mkdir(GLPI_PLUGIN_DOC_DIR . "/monitoring/weathermapbg"); } CronTask::Register('PluginMonitoringServiceevent', 'updaterrd', '300', array('mode' => 2, 'allowmode' => 3, 'logs_lifetime' => 30)); CronTask::Register('PluginMonitoringLog', 'cleanlogs', '96400', array('mode' => 2, 'allowmode' => 3, 'logs_lifetime' => 30)); CronTask::Register('PluginMonitoringUnavaibility', 'unavaibility', '300', array('mode' => 2, 'allowmode' => 3, 'logs_lifetime' => 30)); }
function generateTemplatesCfg($file=0, $tag='') { global $DB; PluginMonitoringToolbox::logIfExtradebug( 'pm-shinken', "Starting generateTemplatesCfg ($tag) ...\n" ); $pMonitoringCheck = new PluginMonitoringCheck(); $calendar = new Calendar(); $a_servicetemplates = array(); $i=0; $a_templatesdef = array(); $query = "SELECT * FROM `glpi_plugin_monitoring_components` GROUP BY `plugin_monitoring_checks_id`, `active_checks_enabled`, `passive_checks_enabled`, `calendars_id` ORDER BY `id`"; $result = $DB->query($query); while ($data=$DB->fetch_array($result)) { PluginMonitoringToolbox::logIfExtradebug( 'pm-shinken', " - add template ".'template'.$data['id'].'-service'."\n" ); $a_servicetemplates[$i]['name'] = 'template'.$data['id'].'-service'; $pMonitoringCheck->getFromDB($data['plugin_monitoring_checks_id']); $a_servicetemplates[$i]['alias'] = $data['description'].' / '.$data['name']; $a_servicetemplates[$i]['check_interval'] = $pMonitoringCheck->fields['check_interval']; $a_servicetemplates[$i]['retry_interval'] = $pMonitoringCheck->fields['retry_interval']; $a_servicetemplates[$i]['max_check_attempts'] = $pMonitoringCheck->fields['max_check_attempts']; if ($calendar->getFromDB($data['calendars_id'])) { $a_servicetemplates[$i]['check_period'] = $calendar->fields['name']; } $a_servicetemplates[$i]['notification_interval'] = '30'; $a_servicetemplates[$i]['notification_period'] = "24x7"; $a_servicetemplates[$i]['notification_options'] = 'w,u,c,r,f,s'; $a_servicetemplates[$i]['process_perf_data'] = '1'; $a_servicetemplates[$i]['active_checks_enabled'] = $data['active_checks_enabled']; $a_servicetemplates[$i]['passive_checks_enabled'] = $data['passive_checks_enabled']; $a_servicetemplates[$i]['parallelize_check'] = '1'; $a_servicetemplates[$i]['obsess_over_service'] = '1'; $a_servicetemplates[$i]['check_freshness'] = '1'; $a_servicetemplates[$i]['freshness_threshold'] = '3600'; $a_servicetemplates[$i]['notifications_enabled'] = '1'; $a_servicetemplates[$i]['event_handler_enabled'] = '0'; //$a_servicetemplates[$i]['event_handler'] = 'super_event_kill_everyone!DIE'; $a_servicetemplates[$i]['flap_detection_enabled'] = '1'; $a_servicetemplates[$i]['failure_prediction_enabled'] = '1'; $a_servicetemplates[$i]['retain_status_information'] = '1'; $a_servicetemplates[$i]['retain_nonstatus_information'] = '1'; $a_servicetemplates[$i]['is_volatile'] = '0'; /* Fred: Previous line should be commented and this comment should be removed ... but there is a bug in Shinken notifications with volatile services ! if ($data['passive_checks_enabled'] == '1' && $data['active_checks_enabled'] == '0') { $a_servicetemplates[$i]['is_volatile'] = '1'; } else { $a_servicetemplates[$i]['is_volatile'] = '0'; } */ // $a_servicetemplates[$i]['_httpstink'] = 'NO'; $a_servicetemplates[$i]['register'] = '0'; // Manage user interface ... $a_servicetemplates[$i]['icon_set'] = 'service'; $queryc = "SELECT * FROM `glpi_plugin_monitoring_components` WHERE `plugin_monitoring_checks_id`='".$data['plugin_monitoring_checks_id']."' AND `active_checks_enabled`='".$data['active_checks_enabled']."' AND `passive_checks_enabled`='".$data['passive_checks_enabled']."' AND `calendars_id`='".$data['calendars_id']."'"; $resultc = $DB->query($queryc); while ($datac=$DB->fetch_array($resultc)) { $a_templatesdef[$datac['id']] = $a_servicetemplates[$i]['name']; } $i++; } $_SESSION['plugin_monitoring']['servicetemplates'] = $a_templatesdef; PluginMonitoringToolbox::logIfExtradebug( 'pm-shinken', "End generateTemplatesCfg\n" ); if ($file == "1") { $config = "# Generated by plugin monitoring for GLPI\n# on ".date("Y-m-d H:i:s")."\n\n"; foreach ($a_servicetemplates as $data) { $config .= $this->writeFile("service", $data); } return array('servicetemplates.cfg', $config); } else { return $a_servicetemplates; } }
@author David Durieux @co-author @comment @copyright Copyright (c) 2011-2012 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 2011 ------------------------------------------------------------------------ */ define('GLPI_ROOT', '../../..'); include GLPI_ROOT . "/inc/includes.php"; PluginMonitoringProfile::checkRight("check", "w"); commonHeader($LANG['plugin_monitoring']['title'][0], $_SERVER["PHP_SELF"], "plugins", "monitoring", "checks"); $pMonitoringCheck = new PluginMonitoringCheck(); if (isset($_POST["add"])) { $pMonitoringCheck->add($_POST); glpi_header($_SERVER['HTTP_REFERER']); } else { if (isset($_POST["update"])) { $pMonitoringCheck->update($_POST); glpi_header($_SERVER['HTTP_REFERER']); } else { if (isset($_POST["delete"])) { $pMonitoringCheck->delete($_POST); $pMonitoringCheck->redirectToList(); } } } if (isset($_GET["id"])) {
function showForm($items_id, $options=array(), $services_id='') { $pMonitoringCommand = new PluginMonitoringCommand(); $pMonitoringServicedef = new PluginMonitoringServicedef(); if (isset($_GET['withtemplate']) AND ($_GET['withtemplate'] == '1')) { $options['withtemplate'] = 1; } else { $options['withtemplate'] = 0; } if ($services_id!='') { $this->getEmpty(); } else { $this->getFromDB($items_id); } $this->showTabs($options); $this->showFormHeader($options); if (!isset($this->fields['plugin_monitoring_servicedefs_id']) OR empty($this->fields['plugin_monitoring_servicedefs_id'])) { $pMonitoringServicedef->getEmpty(); } else { $pMonitoringServicedef->getFromDB($this->fields['plugin_monitoring_servicedefs_id']); } $template = false; echo "<tr>"; echo "<td>"; if ($services_id!='') { echo "<input type='hidden' name='plugin_monitoring_services_id' value='".$services_id."' />"; } echo __('Name')." :"; echo "</td>"; echo "<td>"; $objectName = autoName($this->fields["name"], "name", ($template === "newcomp"), $this->getType()); Html::autocompletionTextField($this, 'name', array('value' => $objectName)); echo "</td>"; echo "<td>"; echo __('Template')." :"; echo "</td>"; echo "<td>"; if ($items_id != '0') { echo "<input type='hidden' name='update' value='update'>\n"; } echo "<input type='hidden' name='plugin_monitoring_servicedefs_id_s' value='".$this->fields['plugin_monitoring_servicedefs_id']."'>\n"; if ($pMonitoringServicedef->fields['is_template'] == '0') { $this->fields['plugin_monitoring_servicedefs_id'] = 0; } Dropdown::show("PluginMonitoringServicetemplate", array( 'name' => 'plugin_monitoring_servicetemplates_id', 'value' => $this->fields['plugin_monitoring_servicetemplates_id'], 'auto_submit' => true )); echo "</td>"; echo "<td>"; if ($this->fields["items_id"] == '') { } else { echo "<input type='hidden' name='items_id' value='".$this->fields["items_id"]."'>\n"; echo "<input type='hidden' name='itemtype' value='".$this->fields["itemtype"]."'>\n"; } echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<th colspan='4'> </th>"; echo "</tr>"; echo "<tr>"; // * itemtype link if ($this->fields['itemtype'] != '') { $itemtype = $this->fields['itemtype']; $item = new $itemtype(); $item->getFromDB($this->fields['items_id']); echo "<td>"; echo __('Item Type')." <i>".$item->getTypeName()."</i>"; echo " :</td>"; echo "<td>"; echo $item->getLink(1); echo "</td>"; } else { echo "<td colspan='2' align='center'>"; echo __('No type associated', 'monitoring'); echo "</td>"; } // * command echo "<td>"; echo __('Command', 'monitoring')." :"; echo "</td>"; echo "<td align='center'>"; if ($this->fields['plugin_monitoring_servicetemplates_id'] > 0) { $pMonitoringServicetemplate = new PluginMonitoringServicetemplate(); $pMonitoringServicetemplate->getFromDB($this->fields['plugin_monitoring_servicetemplates_id']); $pMonitoringCommand->getFromDB($pMonitoringServicetemplate->fields['plugin_monitoring_commands_id']); echo $pMonitoringCommand->getLink(1); } else { $pMonitoringCommand->getFromDB($pMonitoringServicedef->fields['plugin_monitoring_commands_id']); Dropdown::show("PluginMonitoringCommand", array( 'name' =>'plugin_monitoring_commands_id', 'value'=>$pMonitoringServicedef->fields['plugin_monitoring_commands_id'] )); } echo "</td>"; echo "</tr>"; echo "<tr>"; // * checks echo "<td>".__('Check definition', 'monitoring')." :</td>"; echo "<td align='center'>"; if ($this->fields['plugin_monitoring_servicetemplates_id'] > 0) { $pMonitoringCheck = new PluginMonitoringCheck(); $pMonitoringCheck->getFromDB($pMonitoringServicetemplate->fields['plugin_monitoring_checks_id']); echo $pMonitoringCheck->getLink(1); } else { Dropdown::show("PluginMonitoringCheck", array('name'=>'plugin_monitoring_checks_id', 'value'=>$pMonitoringServicedef->fields['plugin_monitoring_checks_id'])); } echo "</td>"; // * active check echo "<td>"; echo __('Active check', 'monitoring')." :"; echo "</td>"; echo "<td align='center'>"; if ($this->fields['plugin_monitoring_servicetemplates_id'] > 0) { echo Dropdown::getYesNo($pMonitoringServicetemplate->fields['active_checks_enabled']); } else { Dropdown::showYesNo("active_checks_enabled", $pMonitoringServicedef->fields['active_checks_enabled']); } echo "</td>"; echo "</tr>"; echo "<tr>"; // * passive check echo "<td>"; echo __('Passive check', 'monitoring')." :"; echo "</td>"; echo "<td align='center'>"; if ($this->fields['plugin_monitoring_servicetemplates_id'] > 0) { echo Dropdown::getYesNo($pMonitoringServicetemplate->fields['passive_checks_enabled']); } else { Dropdown::showYesNo("passive_checks_enabled", $pMonitoringServicedef->fields['passive_checks_enabled']); } echo "</td>"; // * calendar echo "<td>".__('Check period', 'monitoring')." :</td>"; echo "<td align='center'>"; if ($this->fields['plugin_monitoring_servicetemplates_id'] > 0) { $calendar = new Calendar(); $calendar->getFromDB($pMonitoringServicetemplate->fields['calendars_id']); echo $calendar->getLink(1); } else { dropdown::show("Calendar", array('name'=>'calendars_id', 'value'=>$pMonitoringServicedef->fields['calendars_id'])); } echo "</td>"; echo "</tr>"; if (!($this->fields['plugin_monitoring_servicetemplates_id'] > 0 AND $pMonitoringServicetemplate->fields['remotesystem'] == '')) { echo "<tr>"; echo "<th colspan='4'>".__('Remote check', 'monitoring')."</th>"; echo "</tr>"; echo "<tr>"; // * remotesystem echo "<td>"; echo __('Utility used for remote check', 'monitoring')." :"; echo "</td>"; echo "<td>"; $input = array(); $input[''] = '------'; $input['byssh'] = 'byssh'; $input['nrpe'] = 'nrpe'; $input['nsca'] = 'nsca'; if ($this->fields['plugin_monitoring_servicetemplates_id'] > 0) { echo $input[$pMonitoringServicetemplate->fields['remotesystem']]; } else { Dropdown::showFromArray("remotesystem", $input, array('value'=>$pMonitoringServicedef->fields['remotesystem'])); } echo "</td>"; // * is_argument echo "<td>"; echo __('Use arguments (NRPE only)', 'monitoring')." :"; echo "</td>"; echo "<td>"; if ($this->fields['plugin_monitoring_servicetemplates_id'] > 0) { echo Dropdown::getYesNo($pMonitoringServicetemplate->fields['is_arguments']); } else { Dropdown::showYesNo("is_arguments", $pMonitoringServicedef->fields['is_arguments']); } echo "</td>"; echo "</tr>"; echo "<tr>"; // alias command echo "<td>"; echo __('Alias command if required (NRPE only)', 'monitoring')." :"; echo "</td>"; echo "<td>"; if ($this->fields['plugin_monitoring_servicetemplates_id'] > 0) { echo "<input type='text' name='alias_commandservice' value='".$this->fields['alias_command']."' />"; } else { echo "<input type='text' name='alias_command' value='".$pMonitoringServicedef->fields['alias_command']."' />"; } echo "</td>"; echo "<td>"; echo __('Template (for graphs generation)', 'monitoring')." :GHJKL"; echo "</td>"; echo "<td>"; if ($this->fields['plugin_monitoring_servicetemplates_id'] > 0) { $pMonitoringCommand->getEmpty(); $pMonitoringCommand->getFromDB($pMonitoringServicetemplate->fields['aliasperfdata_commands_id']); echo $pMonitoringCommand->getLink(1); } else { $pMonitoringCommand->getFromDB($pMonitoringServicedef->fields['aliasperfdata_commands_id']); Dropdown::show("PluginMonitoringCommand", array( 'name' =>'aliasperfdata_commands_id', 'value'=>$pMonitoringServicedef->fields['aliasperfdata_commands_id'] )); } echo "</td>"; echo "</tr>"; } // * Manage arguments $array = array(); $a_displayarg = array(); if (isset($pMonitoringCommand->fields['command_line'])) { preg_match_all("/\\$(ARG\d+)\\$/", $pMonitoringCommand->fields['command_line'], $array); $a_arguments = importArrayFromDB($this->fields['arguments']); foreach ($array[0] as $arg) { if (strstr($arg, "ARG")) { $arg = str_replace('$', '', $arg); if (!isset($a_arguments[$arg])) { $a_arguments[$arg] = ''; } $a_displayarg[$arg] = $a_arguments[$arg]; } } } if (count($a_displayarg) > 0) { $a_argtext = importArrayFromDB($pMonitoringCommand->fields['arguments']); echo "<tr>"; echo "<th colspan='4'>".__('Argument ([text:text] is used to get values dynamically)', 'monitoring')." </th>"; echo "</tr>"; foreach ($a_displayarg as $key=>$value) { echo "<tr>"; echo "<th>".$key."</th>"; echo "<td colspan='2'>"; if (isset($a_argtext[$key])) { echo nl2br($a_argtext[$key])." :"; } else { echo __('Argument', 'monitoring')." :"; } if ($value == '') { $matches = array(); preg_match('/(\[\w+\:\w+\])/', nl2br($a_argtext[$key]), $matches); if (isset($matches[0])) { $value = $matches[0]; } } echo "</td>"; echo "<td>"; echo "<input type='text' name='arg[".$key."]' value='".$value."'/><br/>"; echo "</td>"; echo "</tr>"; } } $this->showFormButtons($options); return true; }
/** * * @param $items_id integer ID * @param $options array * *@return bool true if form is ok * **/ function showForm($items_id, $itemtype, $options = array()) { global $DB, $CFG_GLPI; $pmCommand = new PluginMonitoringCommand(); $pmCheck = new PluginMonitoringCheck(); $calendar = new Calendar(); $pmRealm = new PluginMonitoringRealm(); $entities_id = 0; if ($itemtype == "Entity") { $entities_id = $items_id; } else { $item = new $itemtype(); $item->getFromDB($items_id); $entities_id = $item->fields['entities_id']; } $query = "SELECT * FROM `" . $this->getTable() . "`\n WHERE `items_id`='" . $items_id . "'\n AND `itemtype`='" . $itemtype . "'\n LIMIT 1"; $result = $DB->query($query); if ($DB->numrows($result) == '0') { $this->getEmpty(); if ($entities_id != '0' or $itemtype != 'Entity') { $this->fields['plugin_monitoring_commands_id'] = -1; $this->fields['plugin_monitoring_checks_id'] = -1; $this->fields['calendars_id'] = -1; $this->fields['plugin_monitoring_realms_id'] = -1; } } else { $data = $DB->fetch_assoc($result); $this->getFromDB($data['id']); } echo "<form name='form' method='post' \n action='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/hostconfig.form.php'>"; echo "<table class='tab_cadre_fixe'"; echo "<tr class='tab_bg_1'>"; echo "<th colspan='4'>"; echo __('Hosts configuration', 'monitoring'); echo "</th>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>"; echo __('Command', 'monitoring') . " :"; echo "</td>"; echo "<td>"; $input = array(); if ($entities_id != '0' or $itemtype != 'Entity') { $input["-1"] = __('Inheritance of the parent entity'); } $query = "SELECT * FROM `" . getTableForItemType("PluginMonitoringCommand") . "`\n ORDER BY `name`"; $result = $DB->query($query); while ($data = $DB->fetch_array($result)) { $input[$data['id']] = $data['name']; } Dropdown::showFromArray('plugin_monitoring_commands_id', $input, array('value' => $this->fields['plugin_monitoring_commands_id'])); echo "</td>"; echo "<td>" . __('Check definition', 'monitoring') . " :</td>"; echo "<td>"; $input = array(); if ($entities_id != '0' or $itemtype != 'Entity') { $input["-1"] = __('Inheritance of the parent entity'); } $query = "SELECT * FROM `" . getTableForItemType("PluginMonitoringCheck") . "`\n ORDER BY `name`"; $result = $DB->query($query); while ($data = $DB->fetch_array($result)) { $input[$data['id']] = $data['name']; } Dropdown::showFromArray('plugin_monitoring_checks_id', $input, array('value' => $this->fields['plugin_monitoring_checks_id'])); echo "</td>"; echo "</tr>"; // Inheritance if ($this->fields['plugin_monitoring_commands_id'] == '-1' or $this->fields['plugin_monitoring_checks_id'] == '-1') { echo "<tr class='tab_bg_1'>"; if ($this->fields['plugin_monitoring_commands_id'] == '-1') { echo "<td colspan='2' class='green center'>"; echo __('Inheritance of the parent entity') . " : "; $pmCommand->getFromDB($this->getValueAncestor("plugin_monitoring_commands_id", $entities_id)); echo $pmCommand->fields['name']; echo "</td>"; } else { echo "<td colspan='2'>"; echo "</td>"; } if ($this->fields['plugin_monitoring_checks_id'] == '-1') { echo "<td colspan='2' class='green center'>"; echo __('Inheritance of the parent entity') . " : "; $pmCheck->getFromDB($this->getValueAncestor("plugin_monitoring_checks_id", $entities_id)); echo $pmCheck->fields['name']; echo "</td>"; } else { echo "<td colspan='2'>"; echo "</td>"; } echo "</tr>"; } echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Reaml', 'monitoring') . " :</td>"; echo "<td>"; $input = array(); if ($entities_id != '0' or $itemtype != 'Entity') { $input["-1"] = __('Inheritance of the parent entity'); } $query = "SELECT * FROM `" . getTableForItemType("PluginMonitoringRealm") . "`\n ORDER BY `name`"; $result = $DB->query($query); while ($data = $DB->fetch_array($result)) { $input[$data['id']] = $data['name']; } Dropdown::showFromArray('plugin_monitoring_realms_id', $input, array('value' => $this->fields['plugin_monitoring_realms_id'])); echo "</td>"; echo "<td>" . __('Check period', 'monitoring') . " :</td>"; echo "<td>"; if (Session::isMultiEntitiesMode()) { $input = array(); if ($entities_id != '0' or $itemtype != 'Entity') { $input["-1"] = __('Inheritance of the parent entity'); } $entities_ancestors = getAncestorsOf("glpi_entities", $entities_id); if (!isset($entities_ancestors[$entities_id])) { $entities_ancestors[$entities_id] = $entities_id; } $query = "SELECT * FROM `" . getTableForItemType("Calendar") . "`\n WHERE `entities_id` IN ('" . implode(",", $entities_ancestors) . "') AND `is_recursive`='1'\n ORDER BY `name`"; $result = $DB->query($query); while ($data = $DB->fetch_array($result)) { $input[$data['id']] = $data['name']; } Dropdown::showFromArray('calendars_id', $input, array('value' => $this->fields['calendars_id'])); } else { Dropdown::show("Calendar", array('value' => $this->fields['calendars_id'])); } echo "</td>"; echo "</tr>"; // Inheritance if ($this->fields['calendars_id'] == '-1' or $this->fields['plugin_monitoring_realms_id'] == '-1') { echo "<tr class='tab_bg_1'>"; if ($this->fields['plugin_monitoring_realms_id'] == '-1') { echo "<td colspan='2' class='green center'>"; echo __('Inheritance of the parent entity') . " : "; $pmRealm->getFromDB($this->getValueAncestor("plugin_monitoring_realms_id", $entities_id)); echo $pmRealm->fields['name']; echo "</td>"; } else { echo "<td colspan='2'>"; echo "</td>"; } if ($this->fields['calendars_id'] == '-1') { echo "<td colspan='2' class='green center'>"; echo __('Inheritance of the parent entity') . " : "; $calendar->getFromDB($this->getValueAncestor("calendars_id", $entities_id)); echo $calendar->fields['name']; echo "</td>"; } else { echo "<td colspan='2'>"; echo "</td>"; } echo "</tr>"; } if ($itemtype == 'Entity' and $items_id == '0') { echo "<tr class='tab_bg_1'>"; echo "<td>"; echo __('Shinken Server', 'monitoring') . " :"; echo "</td>"; echo "<td>"; Dropdown::show("Computer", array('name' => 'computers_id', 'value' => $this->fields['computers_id'])); echo "</td>"; echo "<td colspan='2'></td>"; echo "</tr>"; } echo "<tr class='tab_bg_1'>"; echo "<td colspan='4' align='center'>"; if (isset($this->fields['id']) and $this->fields['id'] != '') { echo "<input type='hidden' name='id' value='" . $this->fields['id'] . "'/>"; } echo "<input type='hidden' name='itemtype' value='" . $itemtype . "'/>"; echo "<input type='hidden' name='items_id' value='" . $items_id . "'/>"; echo "<input type='submit' name='update' value=\"" . __('Save') . "\" class='submit'>"; echo "</td>"; echo "</tr>"; echo "</table>"; Html::closeForm(); return true; }
/** * Display form for service configuration * * @param $items_id integer ID * @param $options array * *@return bool true if form is ok * **/ function showForm($items_id, $options = array()) { $pMonitoringCommand = new PluginMonitoringCommand(); if ($items_id == '0') { $this->getEmpty(); } else { $this->getFromDB($items_id); } $this->showFormHeader($options); echo "<tr>"; echo "<td>"; echo __('Template name') . " :"; echo "</td>"; echo "<td>"; echo "<input type='hidden' name='is_template' value='1' />"; $objectName = autoName($this->fields["name"], "name", 1, $this->getType()); Html::autocompletionTextField($this, 'name', array('value' => $objectName)); echo "</td>"; // * commande echo "<td>"; echo __('Command', 'monitoring') . " :"; echo "</td>"; echo "<td align='center'>"; if ($this->fields['is_template'] == '1') { $pMonitoringCommand->getFromDB($this->fields['plugin_monitoring_commands_id']); echo $pMonitoringCommand->getLink(1); } else { $pMonitoringCommand->getFromDB($this->fields['plugin_monitoring_commands_id']); Dropdown::show("PluginMonitoringCommand", array('name' => 'plugin_monitoring_commands_id', 'value' => $this->fields['plugin_monitoring_commands_id'])); } echo "</td>"; echo "</tr>"; echo "<tr>"; // * checks echo "<td>" . __('Check definition', 'monitoring') . " :</td>"; echo "<td align='center'>"; if ($this->fields['is_template'] == '1') { $pMonitoringCheck = new PluginMonitoringCheck(); $pMonitoringCheck->getFromDB($this->fields['plugin_monitoring_checks_id']); echo $pMonitoringCheck->getLink(1); } else { Dropdown::show("PluginMonitoringCheck", array('name' => 'plugin_monitoring_checks_id', 'value' => $this->fields['plugin_monitoring_checks_id'])); } echo "</td>"; // * active check echo "<td>"; echo __('Active checks enable', 'monitoring') . " :"; echo "</td>"; echo "<td align='center'>"; if ($this->fields['is_template'] == '1') { echo Dropdown::getYesNo($this->fields['active_checks_enabled']); } else { Dropdown::showYesNo("active_checks_enabled", $this->fields['active_checks_enabled']); } echo "</td>"; echo "</tr>"; echo "<tr>"; // * passive check echo "<td>"; echo __('Passive checks enable', 'monitoring') . " :"; echo "</td>"; echo "<td align='center'>"; if ($this->fields['is_template'] == '1') { echo Dropdown::getYesNo($this->fields['passive_checks_enabled']); } else { Dropdown::showYesNo("passive_checks_enabled", $this->fields['passive_checks_enabled']); } echo "</td>"; // * calendar echo "<td>" . __('Check period', 'monitoring') . " :</td>"; echo "<td align='center'>"; if ($this->fields['is_template'] == '1') { $calendar = new Calendar(); $calendar->getFromDB($this->fields['calendars_id']); echo $calendar->getLink(1); } else { dropdown::show("Calendar", array('name' => 'calendars_id', 'value' => $this->fields['calendars_id'])); } echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<th colspan='4'>" . __('Remote check', 'monitoring') . "</th>"; echo "</tr>"; echo "<tr>"; // * remotesystem echo "<td>"; echo __('Utility used for remote check', 'monitoring') . " :"; echo "</td>"; echo "<td>"; $input = array(); $input[''] = '------'; $input['byssh'] = __('By ssh', 'monitoring'); $input['nrpe'] = 'nrpe'; $input['nsca'] = 'nsca'; if ($this->fields['is_template'] == '1') { echo $input[$this->fields['remotesystem']]; } else { Dropdown::showFromArray("remotesystem", $input, array('value' => $this->fields['remotesystem'])); } echo "</td>"; // * is_argument echo "<td>"; echo __('Use arguments (Only for NRPE)', 'monitoring') . " :"; echo "</td>"; echo "<td>"; if ($this->fields['is_template'] == '1') { echo Dropdown::getYesNo($this->fields['is_arguments']); } else { Dropdown::showYesNo("is_arguments", $this->fields['is_arguments']); } echo "</td>"; echo "</tr>"; echo "<tr>"; // alias command echo "<td>"; echo __('Alias command if required (Only for NRPE)', 'monitoring') . " :"; echo "</td>"; echo "<td>"; if ($this->fields['is_template'] == '1') { echo "<input type='text' name='alias_commandservice' value='" . $this->fields['alias_command'] . "' />"; } else { echo "<input type='text' name='alias_command' value='" . $this->fields['alias_command'] . "' />"; } echo "</td>"; echo "<td>"; echo __('Command link (used for graphs generation)', 'monitoring') . " :"; echo "</td>"; echo "<td>"; if ($this->fields['is_template'] == '1') { $pMonitoringCommand->getFromDB($this->fields['aliasperfdata_commands_id']); echo $pMonitoringCommand->getLink(1); } else { $pMonitoringCommand->getFromDB($this->fields['aliasperfdata_commands_id']); Dropdown::show("PluginMonitoringCommand", array('name' => 'aliasperfdata_commands_id', 'value' => $this->fields['aliasperfdata_commands_id'])); } echo "</td>"; echo "</tr>"; // * Manage arguments $array = array(); $a_displayarg = array(); if (isset($pMonitoringCommand->fields['command_line'])) { preg_match_all("/\\\$(ARG\\d+)\\\$/", $pMonitoringCommand->fields['command_line'], $array); $a_arguments = importArrayFromDB($this->fields['arguments']); foreach ($array[0] as $arg) { if (strstr($arg, "ARG")) { $arg = str_replace('$', '', $arg); if (!isset($a_arguments[$arg])) { $a_arguments[$arg] = ''; } $a_displayarg[$arg] = $a_arguments[$arg]; } } } if (count($a_displayarg) > 0) { $a_argtext = importArrayFromDB($pMonitoringCommand->fields['arguments']); echo "<tr>"; echo "<th colspan='4'>" . __('Arguments', 'monitoring') . " </th>"; echo "</tr>"; foreach ($a_displayarg as $key => $value) { echo "<tr>"; echo "<th>" . $key . "</th>"; echo "<td colspan='2'>"; if (isset($a_argtext[$key])) { echo nl2br($a_argtext[$key]) . " :"; } else { echo __('Argument', 'monitoring') . " :"; } echo "</td>"; echo "<td>"; echo "<input type='text' name='arg[" . $key . "]' value='" . $value . "'/><br/>"; echo "</td>"; echo "</tr>"; } } $this->showFormButtons($options); return true; }
static function getAdditionalMenuOptions() { global $CFG_GLPI; $main_menu = '<img src="' . $CFG_GLPI["root_doc"] . '/plugins/monitoring/pics/main_menu.png" alt="' . __('Main menu', 'monitoring') . '" title="' . __('Main menu', 'monitoring') . '"\\>'; return array('componentscatalog' => array('title' => PluginMonitoringComponentscatalog::getTypeName(), 'page' => PluginMonitoringComponentscatalog::getSearchURL(false), 'links' => array($main_menu => '/plugins/monitoring/front/menu.php', 'search' => '/plugins/monitoring/front/componentscatalog.php', 'add' => '/plugins/monitoring/front/componentscatalog.form.php')), 'command' => array('title' => PluginMonitoringCommand::getTypeName(), 'page' => PluginMonitoringCommand::getSearchURL(false), 'links' => array($main_menu => '/plugins/monitoring/front/menu.php', 'search' => '/plugins/monitoring/front/command.php', 'add' => '/plugins/monitoring/front/command.form.php')), 'check' => array('title' => PluginMonitoringCheck::getTypeName(), 'page' => PluginMonitoringCheck::getSearchURL(false), 'links' => array($main_menu => '/plugins/monitoring/front/menu.php', 'search' => '/plugins/monitoring/front/check.php', 'add' => '/plugins/monitoring/front/check.form.php')), 'eventhandler' => array('title' => PluginMonitoringEventhandler::getTypeName(), 'page' => PluginMonitoringEventhandler::getSearchURL(false), 'links' => array($main_menu => '/plugins/monitoring/front/menu.php', 'search' => '/plugins/monitoring/front/eventhandler.php', 'add' => '/plugins/monitoring/front/eventhandler.form.php')), 'perfdata' => array('title' => PluginMonitoringPerfdata::getTypeName(), 'page' => PluginMonitoringPerfdata::getSearchURL(false), 'links' => array($main_menu => '/plugins/monitoring/front/menu.php', 'search' => '/plugins/monitoring/front/perfdata.php', 'add' => '/plugins/monitoring/front/perfdata.form.php')), 'component' => array('title' => PluginMonitoringComponent::getTypeName(), 'page' => PluginMonitoringComponent::getSearchURL(false), 'links' => array($main_menu => '/plugins/monitoring/front/menu.php', 'search' => '/plugins/monitoring/front/component.php', 'add' => '/plugins/monitoring/front/component.form.php')), 'contacttemplate' => array('title' => PluginMonitoringContacttemplate::getTypeName(), 'page' => PluginMonitoringContacttemplate::getSearchURL(false), 'links' => array($main_menu => '/plugins/monitoring/front/menu.php', 'search' => '/plugins/monitoring/front/contacttemplate.php', 'add' => '/plugins/monitoring/front/contacttemplate.form.php')), 'notificationcommand' => array('title' => PluginMonitoringNotificationcommand::getTypeName(), 'page' => PluginMonitoringNotificationcommand::getSearchURL(false), 'links' => array($main_menu => '/plugins/monitoring/front/menu.php', 'search' => '/plugins/monitoring/front/notificationcommand.php', 'add' => '/plugins/monitoring/front/notificationcommand.form.php')), 'realm' => array('title' => PluginMonitoringRealm::getTypeName(), 'page' => PluginMonitoringRealm::getSearchURL(false), 'links' => array($main_menu => '/plugins/monitoring/front/menu.php', 'search' => '/plugins/monitoring/front/realm.php', 'add' => '/plugins/monitoring/front/realm.form.php')), 'tag' => array('title' => PluginMonitoringTag::getTypeName(), 'page' => PluginMonitoringTag::getSearchURL(false), 'links' => array($main_menu => '/plugins/monitoring/front/menu.php', 'search' => '/plugins/monitoring/front/tag.php')), 'servicescatalog' => array('title' => PluginMonitoringServicescatalog::getTypeName(), 'page' => PluginMonitoringServicescatalog::getSearchURL(false), 'links' => array($main_menu => '/plugins/monitoring/front/menu.php', 'search' => '/plugins/monitoring/front/servicescatalog.php', 'add' => '/plugins/monitoring/front/servicescatalog.form.php')), 'weathermap' => array('title' => PluginMonitoringWeathermap::getTypeName(), 'page' => PluginMonitoringWeathermap::getSearchURL(false), 'links' => array($main_menu => '/plugins/monitoring/front/menu.php', 'search' => '/plugins/monitoring/front/weathermap.php', 'add' => '/plugins/monitoring/front/weathermap.form.php')), 'displayview' => array('title' => PluginMonitoringDisplayview::getTypeName(), 'page' => PluginMonitoringDisplayview::getSearchURL(false), 'links' => array('search' => '/plugins/monitoring/front/displayview.php', 'add' => '/plugins/monitoring/front/displayview.form.php')), 'slider' => array('title' => PluginMonitoringSlider::getTypeName(), 'page' => PluginMonitoringSlider::getSearchURL(false), 'links' => array($main_menu => '/plugins/monitoring/front/menu.php', 'search' => '/plugins/monitoring/front/slider.php', 'add' => '/plugins/monitoring/front/slider.form.php')), 'downtime' => array('title' => PluginMonitoringDowntime::getTypeName(), 'page' => PluginMonitoringDowntime::getSearchURL(false), 'links' => array('search' => '/plugins/monitoring/front/downtime.php')), 'acknowledge' => array('title' => PluginMonitoringAcknowledge::getTypeName(), 'page' => PluginMonitoringAcknowledge::getSearchURL(false), 'links' => array('search' => '/plugins/monitoring/front/acknowledge.php')), 'menu' => array('title' => PluginMonitoringMenu::getTypeName(), 'links' => array($main_menu => '/plugins/monitoring/front/menu.php', 'config' => '/plugins/monitoring/front/config.form.php')), 'dashboard' => array('title' => PluginMonitoringDisplay::getTypeName(), 'links' => array($main_menu => '/plugins/monitoring/front/menu.php', 'config' => '/plugins/monitoring/front/config.form.php')), 'config' => array('title' => PluginMonitoringConfig::getTypeName(), 'links' => array($main_menu => '/plugins/monitoring/front/menu.php'))); }
function showComponents($componentscatalogs_id) { global $DB, $LANG, $CFG_GLPI; $this->addComponent($componentscatalogs_id); $rand = mt_rand(); $pmComponent = new PluginMonitoringComponent(); $pmCommand = new PluginMonitoringCommand(); $pmCheck = new PluginMonitoringCheck(); $calendar = new Calendar(); echo "<form method='post' name='componentscatalog_component_form{$rand}' id='componentscatalog_component_form{$rand}' action=\"" . $CFG_GLPI["root_doc"] . "/plugins/monitoring/front/componentscatalog_component.form.php\">"; echo "<table class='tab_cadre_fixe'>"; echo "<tr>"; echo "<th>"; echo $LANG['plugin_monitoring']['component'][2]; echo "</th>"; echo "</tr>"; echo "</table>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr>"; echo "<th width='10'> </th>"; echo "<th>" . $LANG['common'][16] . "</th>"; echo "<th>" . $LANG['plugin_monitoring']['command'][2] . "</th>"; echo "<th>" . $LANG['plugin_monitoring']['check'][0] . "</th>"; echo "<th>" . $LANG['plugin_monitoring']['host'][9] . "</th>"; echo "<th>" . $LANG['plugin_monitoring']['service'][8] . "</th>"; echo "</tr>"; $used = array(); $query = "SELECT * FROM `" . $this->getTable() . "`\n WHERE `plugin_monitoring_componentscalalog_id`='" . $componentscatalogs_id . "'"; $result = $DB->query($query); while ($data = $DB->fetch_array($result)) { $used[] = $data['plugin_monitoring_components_id']; $pmComponent->getFromDB($data['plugin_monitoring_components_id']); echo "<tr>"; echo "<td>"; echo "<input type='checkbox' name='item[" . $data["id"] . "]' value='1'>"; echo "</td>"; echo "<td class='center'>"; echo $pmComponent->getLink(1); echo "</td>"; echo "<td class='center'>"; $pmCommand->getFromDB($pmComponent->fields['plugin_monitoring_commands_id']); echo $pmCommand->getLink(); echo "</td>"; echo "<td class='center'>"; $pmCheck->getFromDB($pmComponent->fields['plugin_monitoring_checks_id']); echo $pmCheck->getLink(); echo "</td>"; echo "<td class='center'>"; $calendar->getFromDB($pmComponent->fields['calendars_id']); echo $calendar->getLink(); echo "</td>"; echo "<td class='center'>"; if ($pmComponent->fields['remotesystem'] == '') { echo "-"; } else { echo $pmComponent->fields['remotesystem']; } echo "</td>"; echo "</tr>"; } openArrowMassive("componentscatalog_host_form{$rand}", true); closeArrowMassive('deleteitem', $LANG['buttons'][6]); echo "</table>"; }
function showComponents($componentscatalogs_id) { global $DB, $CFG_GLPI; $this->addComponent($componentscatalogs_id); $rand = mt_rand(); $pmComponent = new PluginMonitoringComponent(); $pmCommand = new PluginMonitoringCommand(); $pmCheck = new PluginMonitoringCheck(); $calendar = new Calendar(); echo "<form method='post' name='componentscatalog_component_form{$rand}' id='componentscatalog_component_form{$rand}' action=\"" . $CFG_GLPI["root_doc"] . "/plugins/monitoring/front/componentscatalog_component.form.php\">"; echo "<table class='tab_cadre_fixe'>"; echo "<tr>"; echo "<th>"; echo __('Associated components', 'monitoring'); echo "</th>"; echo "</tr>"; echo "</table>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr>"; echo "<th width='10'> </th>"; echo "<th>" . __('Name') . "</th>"; echo "<th>" . __('Command name', 'monitoring') . "</th>"; echo "<th>" . __('Check definition', 'monitoring') . "</th>"; echo "<th>" . __('Check period', 'monitoring') . "</th>"; echo "<th>" . __('Remote check', 'monitoring') . "</th>"; echo "</tr>"; $used = array(); $query = "SELECT * FROM `" . $this->getTable() . "`\n WHERE `plugin_monitoring_componentscalalog_id`='" . $componentscatalogs_id . "'"; $result = $DB->query($query); while ($data = $DB->fetch_array($result)) { $used[] = $data['plugin_monitoring_components_id']; $pmComponent->getFromDB($data['plugin_monitoring_components_id']); echo "<tr>"; echo "<td>"; echo "<input type='checkbox' name='item[" . $data["id"] . "]' value='1'>"; echo "</td>"; echo "<td class='center'>"; echo $pmComponent->getLink(1); echo "</td>"; echo "<td class='center'>"; $pmCommand->getFromDB($pmComponent->fields['plugin_monitoring_commands_id']); echo $pmCommand->getLink(); echo "</td>"; echo "<td class='center'>"; $pmCheck->getFromDB($pmComponent->fields['plugin_monitoring_checks_id']); echo $pmCheck->getLink(); echo "</td>"; echo "<td class='center'>"; $calendar->getFromDB($pmComponent->fields['calendars_id']); echo $calendar->getLink(); echo "</td>"; echo "<td class='center'>"; if ($pmComponent->fields['remotesystem'] == '') { echo "-"; } else { echo $pmComponent->fields['remotesystem']; } echo "</td>"; echo "</tr>"; } Html::openArrowMassives("componentscatalog_host_form{$rand}", true); Html::closeArrowMassives(array('deleteitem' => _sx('button', 'Delete permanently'))); Html::closeForm(); echo "</table>"; }
function pluginMonitoringInstall($version) { global $DB, $CFG_GLPI; // ** Insert in DB $DB_file = GLPI_ROOT . "/plugins/monitoring/install/mysql/plugin_monitoring-" . $version . "-empty.sql"; $DBf_handle = fopen($DB_file, "rt"); $sql_query = fread($DBf_handle, filesize($DB_file)); fclose($DBf_handle); foreach (explode(";\n", "{$sql_query}") as $sql_line) { if (get_magic_quotes_runtime()) { $sql_line = Toolbox::stripslashes_deep($sql_line); } if (!empty($sql_line)) { $DB->query($sql_line); } } include GLPI_ROOT . "/plugins/monitoring/inc/profile.class.php"; $pmProfile = new PluginMonitoringProfile(); $pmProfile->initProfile(); include GLPI_ROOT . "/plugins/monitoring/inc/command.class.php"; $pmCommand = new PluginMonitoringCommand(); $pmCommand->initCommands(); include GLPI_ROOT . "/plugins/monitoring/inc/notificationcommand.class.php"; $pmNotificationcommand = new PluginMonitoringNotificationcommand(); $pmNotificationcommand->initCommands(); include GLPI_ROOT . "/plugins/monitoring/inc/check.class.php"; $pmCheck = new PluginMonitoringCheck(); $pmCheck->initChecks(); include GLPI_ROOT . "/plugins/monitoring/inc/hostconfig.class.php"; $pmHostconfig = new PluginMonitoringHostconfig(); $pmHostconfig->initConfig(); include GLPI_ROOT . "/plugins/monitoring/inc/config.class.php"; $pmConfig = new PluginMonitoringConfig(); $pmConfig->initConfig(); $query = "UPDATE `glpi_plugin_monitoring_configs`\n SET `version`='" . PLUGIN_MONITORING_VERSION . "'\n WHERE `id`='1'"; $DB->query($query); $query = "SELECT * FROM `glpi_calendars`\n WHERE `name`='24x7'\n LIMIT 1"; $result = $DB->query($query); if ($DB->numrows($result) == 0) { $calendar = new Calendar(); $input = array(); $input['name'] = '24x7'; $input['is_recursive'] = 1; $calendars_id = $calendar->add($input); $calendarSegment = new CalendarSegment(); $input = array(); $input['calendars_id'] = $calendars_id; $input['is_recursive'] = 1; $input['begin'] = '00:00:00'; $input['end'] = '24:00:00'; $input['day'] = '0'; $calendarSegment->add($input); $input['day'] = '1'; $calendarSegment->add($input); $input['day'] = '2'; $calendarSegment->add($input); $input['day'] = '3'; $calendarSegment->add($input); $input['day'] = '4'; $calendarSegment->add($input); $input['day'] = '5'; $calendarSegment->add($input); $input['day'] = '6'; $calendarSegment->add($input); } if (!is_dir(GLPI_PLUGIN_DOC_DIR . '/monitoring')) { mkdir(GLPI_PLUGIN_DOC_DIR . "/monitoring"); } if (!is_dir(GLPI_PLUGIN_DOC_DIR . '/monitoring/templates')) { mkdir(GLPI_PLUGIN_DOC_DIR . "/monitoring/templates"); } if (!is_dir(GLPI_PLUGIN_DOC_DIR . '/monitoring/weathermapbg')) { mkdir(GLPI_PLUGIN_DOC_DIR . "/monitoring/weathermapbg"); } CronTask::Register('PluginMonitoringServiceevent', 'updaterrd', '300', array('mode' => 2, 'allowmode' => 3, 'logs_lifetime' => 30)); CronTask::Register('PluginMonitoringLog', 'cleanlogs', '96400', array('mode' => 2, 'allowmode' => 3, 'logs_lifetime' => 30)); CronTask::Register('PluginMonitoringUnavaibility', 'unavaibility', '300', array('mode' => 2, 'allowmode' => 3, 'logs_lifetime' => 30)); CronTask::Register('PluginMonitoringDisplayview_rule', 'replayallviewrules', '1200', array('mode' => 2, 'allowmode' => 3, 'logs_lifetime' => 30)); }
static function getTimeBetween2Checks($components_id) { $pmComponent = new PluginMonitoringComponent(); $pmCheck = new PluginMonitoringCheck(); $pmComponent->getFromDB($components_id); $pmCheck->getFromDB($pmComponent->fields['plugin_monitoring_checks_id']); $timeMinutes = $pmCheck->fields['check_interval']; $timeSeconds = $timeMinutes * 60; return $timeSeconds; }
function generateTemplatesCfg($file = 0, $tag = '') { global $DB; $pMonitoringCheck = new PluginMonitoringCheck(); $calendar = new Calendar(); $a_servicetemplates = array(); $i = 0; $a_templatesdef = array(); $query = "SELECT * FROM `glpi_plugin_monitoring_components`\n GROUP BY `plugin_monitoring_checks_id`, `active_checks_enabled`, \n `passive_checks_enabled`, `calendars_id`\n ORDER BY `id`"; $result = $DB->query($query); while ($data = $DB->fetch_array($result)) { $a_servicetemplates[$i]['name'] = 'template' . $data['id'] . '-service'; $pMonitoringCheck->getFromDB($data['plugin_monitoring_checks_id']); $a_servicetemplates[$i]['check_interval'] = $pMonitoringCheck->fields['check_interval']; $a_servicetemplates[$i]['retry_interval'] = $pMonitoringCheck->fields['retry_interval']; $a_servicetemplates[$i]['max_check_attempts'] = $pMonitoringCheck->fields['max_check_attempts']; if ($calendar->getFromDB($data['calendars_id'])) { $a_servicetemplates[$i]['check_period'] = $calendar->fields['name']; } $a_servicetemplates[$i]['notification_interval'] = '30'; if ($calendar->getFromDB($data['calendars_id'])) { $a_servicetemplates[$i]['notification_period'] = $calendar->fields['name']; } else { $a_servicetemplates[$i]['notification_period'] = "24x7"; } $a_servicetemplates[$i]['notification_options'] = 'w,c,r'; $a_servicetemplates[$i]['active_checks_enabled'] = '1'; $a_servicetemplates[$i]['process_perf_data'] = '1'; $a_servicetemplates[$i]['active_checks_enabled'] = '1'; $a_servicetemplates[$i]['passive_checks_enabled'] = '1'; $a_servicetemplates[$i]['parallelize_check'] = '1'; $a_servicetemplates[$i]['obsess_over_service'] = '1'; $a_servicetemplates[$i]['check_freshness'] = '1'; $a_servicetemplates[$i]['freshness_threshold'] = '1'; $a_servicetemplates[$i]['notifications_enabled'] = '1'; $a_servicetemplates[$i]['event_handler_enabled'] = '0'; //$a_servicetemplates[$i]['event_handler'] = 'super_event_kill_everyone!DIE'; $a_servicetemplates[$i]['flap_detection_enabled'] = '1'; $a_servicetemplates[$i]['failure_prediction_enabled'] = '1'; $a_servicetemplates[$i]['retain_status_information'] = '1'; $a_servicetemplates[$i]['retain_nonstatus_information'] = '1'; $a_servicetemplates[$i]['is_volatile'] = '0'; $a_servicetemplates[$i]['_httpstink'] = 'NO'; $a_servicetemplates[$i]['register'] = '0'; $queryc = "SELECT * FROM `glpi_plugin_monitoring_components`\n WHERE `plugin_monitoring_checks_id`='" . $data['plugin_monitoring_checks_id'] . "' \n AND `active_checks_enabled`='" . $data['active_checks_enabled'] . "' \n AND `passive_checks_enabled`='" . $data['passive_checks_enabled'] . "'\n AND `calendars_id`='" . $data['calendars_id'] . "'"; $resultc = $DB->query($queryc); while ($datac = $DB->fetch_array($resultc)) { $a_templatesdef[$datac['id']] = $a_servicetemplates[$i]['name']; } $i++; } $_SESSION['plugin_monitoring']['servicetemplates'] = $a_templatesdef; if ($file == "1") { $config = "# Generated by plugin monitoring for GLPI\n# on " . date("Y-m-d H:i:s") . "\n\n"; foreach ($a_servicetemplates as $data) { $config .= $this->constructFile("service", $data); } return array('servicetemplates.cfg', $config); } else { return $a_servicetemplates; } }
@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 2011 ------------------------------------------------------------------------ */ include "../../../inc/includes.php"; Session::checkRight("config", READ); Html::header(__('Monitoring', 'monitoring'), $_SERVER["PHP_SELF"], "plugins", "PluginMonitoringDashboard", "check"); $pMonitoringCheck = new PluginMonitoringCheck(); if (isset($_POST["add"])) { $pMonitoringCheck->add($_POST); Html::back(); } else { if (isset($_POST["update"])) { $pMonitoringCheck->update($_POST); Html::back(); } else { if (isset($_POST["purge"])) { $pMonitoringCheck->delete($_POST); $pMonitoringCheck->redirectToList(); } } } if (!isset($_GET["id"])) {