/** * Display form for agent configuration * * @param $items_id integer ID * @param $options array * *@return bool true if form is ok * **/ function showForm($items_id, $options = array(), $copy = array()) { global $DB, $CFG_GLPI; if ($items_id != '') { $this->getFromDB($items_id); } else { $this->getEmpty(); } $this->showTabs($options); $this->showFormHeader($options); echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Name') . " :</td>"; echo "<td>"; echo "<input type='text' name='name' value='" . $this->fields["name"] . "' size='30'/>"; echo "</td>"; echo "<td>" . __('Type', 'monitoring') . " :</td>"; echo "<td>"; $elements = $this->getGaugeTypes(); Dropdown::showFromArray('type', $elements, array('value' => $this->fields["type"])); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Time (not used for `last value` type)', 'monitoring') . " :</td>"; echo "<td>"; $elements = PluginMonitoringCustomitem_Common::getTimes(); Dropdown::showFromArray('time', $elements, array('value' => $this->fields["time"])); echo "</td>"; echo "<td>" . __('Calendar', 'monitoring') . " :</td>"; echo "<td>"; Dropdown::show('Calendar', array('name' => 'time_specific', 'value' => $this->fields['time_specific'])); echo "</td>"; echo "</tr>"; $this->showFormButtons($options); if ($items_id == 0) { return; } echo "<form name='form' method='post' action='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/customitem_gauge.form.php'>"; echo "<input type='hidden' name='id' value='" . $items_id . "' />"; echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_1'>"; echo "<th colspan='4'>"; echo __('Add gauge', 'monitoring'); echo "</th>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<th>"; echo PluginMonitoringComponentscatalog::getTypeName(); echo "</th>"; echo "<th>"; echo PluginMonitoringComponent::getTypeName(); echo "</th>"; echo "<th colspan='2'>"; echo "</th>"; echo "</tr>"; echo "<tr class='tab_bg_3'>"; echo "<td>"; $toupdate = array('value_fieldname' => 'id', 'to_update' => "add_selectcomponent", 'url' => $CFG_GLPI["root_doc"] . "/plugins/monitoring/ajax/gaugeComponents.php"); Dropdown::show('PluginMonitoringComponentscatalog', array('toupdate' => $toupdate)); echo "</td>"; echo "<td id='add_selectcomponent'>"; echo "</td>"; echo "<td id='add_data'>"; echo "</td>"; echo "<td>"; echo "<input type='submit' name='add_item' value='" . __('Add') . "' class='submit' />"; echo "</td>"; echo "</tr>"; echo "</table>"; Html::closeForm(); $array = importArrayFromDB($this->fields['aggregate_items']); $pmPerfdataDetail = new PluginMonitoringPerfdataDetail(); echo "<table class='tab_cadre_fixe'>"; foreach ($array as $itemtype => $data1) { foreach ($data1 as $items_id1 => $data2) { $item1 = new $itemtype(); $item1->getFromDB(str_replace('id', '', $items_id1)); echo "<tr class='tab_bg_3'>"; echo "<td>"; echo "[" . $item1->getTypeName() . "] "; echo $item1->getLink(); echo "</td>"; foreach ($data2 as $itemtype2 => $data3) { $nb4 = 0; foreach ($data3 as $items_id2 => $data4) { if ($nb4 > 0) { echo "</tr>"; echo "<tr class='tab_bg_3'>"; echo "<td>"; echo "[" . $item1->getTypeName() . "] "; echo $item1->getLink(); echo "</td>"; } $item2 = new $itemtype2(); $item2->getFromDB(str_replace('id', '', $items_id2)); echo "<td>"; echo "[" . $item2->getTypeName() . "] "; echo $item2->getLink(); echo "</td>"; echo "<td>"; $j = 0; foreach ($data4 as $num => $data5) { if ($j > 0) { echo "<hr/>"; } $this->showDefineDataOfGauge($items_id2, array('a' => $itemtype, 'b' => str_replace('id', '', $items_id1), 'c' => $itemtype2, 'd' => str_replace('id', '', $items_id2), 'num' => $num, 'id' => $items_id), TRUE); $j++; $nb4++; } } } echo "</td>"; echo "</tr>"; } } echo "</table>"; echo "<table class='tab_cadre'>"; echo "<tr class='tab_bg_1'>"; echo "<th>"; echo __("Preview", 'monitoring'); echo "</th>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td align='center'>"; $this->showWidget($items_id); $this->showWidgetFrame($items_id); echo "</td>"; echo "</tr>"; echo "</table>"; return true; }
/** * Display services associated with host * * @param $itemtype value type of item * @param $items_id integer id of the object * **/ function listByHost($itemtype, $items_id) { global $CFG_GLPI,$DB; $params = Search::manageParams("PluginMonitoringService", array(), false); $num = 20; // Computer if ($itemtype == 'Printer') { $num = 21; } else if ($itemtype == 'NetworkEquipment') { $num = 22; } $params['criteria'][0] = array( 'field' => $num, 'searchtype' => 'is', 'value' => $items_id ); $col_to_display = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11); $data = Search::prepareDatasForSearch('PluginMonitoringService', $params, $col_to_display); $data['tocompute'] = $data['toview']; Search::constructSQL($data); Search::constructDatas($data); $pmComponentscatalog = new PluginMonitoringComponentscatalog(); $services_id = array(); foreach ($data['data']['rows'] as $row) { $services_id[] = $row['id']; } $oldvalue = current(getAllDatasFromTable( 'glpi_plugin_monitoring_serviceevents', "`plugin_monitoring_services_id` IN ('".implode("', '", $services_id)."')", false, 'date ASC LIMIT 1')); $date = new DateTime($oldvalue['date']); $start = time(); if ($date->getTimestamp() < $start) { $start = $date->getTimestamp(); } $nbdays = round((date('U') - $start) / 86400); echo "<script type=\"text/javascript\"> $(function() { $( \"#custom_date\" ).datepicker({ minDate: -".$nbdays.", maxDate: \"+0D\", dateFormat:'mm/dd/yy' }); $( \"#custom_time\" ).timepicker(); }); </script>"; echo '<center><input type="text" id="custom_date" value="'.date('m/d/Y').'"> ' . ' <input type="text" id="custom_time" value="'.date('H:i').'"></center>'; echo '<div id="custom_date" style="display:none"></div>'; echo '<div id="custom_time" style="display:none"></div>'; echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_1'>"; echo "<th colspan='5'>"; echo __('Resources', 'monitoring'); $item = new $itemtype(); $item->getFromDB($items_id); echo " - ".$item->getTypeName(); echo " - ".$item->getName(); echo "</th>"; echo "</tr>"; echo "<table class='tab_cadre_fixe'>"; foreach ($data['data']['rows'] as $row) { $pmComponentscatalog->getFromDB($row[8][0]['id']); echo "<tr class='tab_bg_1'>"; echo "<th colspan='14'>".$pmComponentscatalog->getTypeName()." : ".$pmComponentscatalog->getLink()."</th>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; // echo "<th>"; // echo __('Show counters', 'monitoring'); // echo "</th>"; echo "<th>"; echo __('Show graphics', 'monitoring'); echo "</th>"; echo "<th>"; echo __('Component', 'monitoring'); echo "</th>"; echo "<th>"; echo __('Resource state', 'monitoring'); echo "</th>"; echo "<th>"; echo __('Last check', 'monitoring'); echo "</th>"; echo "<th>"; echo __('Result details', 'monitoring'); echo "</th>"; echo "<th>"; echo __('Check period', 'monitoring'); echo "</th>"; echo "<th>".__('Current month', 'monitoring')." ".Html::showToolTip(__('Availability', 'monitoring'), array('display'=>false))."</th>"; echo "<th>".__('Last month', 'monitoring')." ".Html::showToolTip(__('Availability', 'monitoring'), array('display'=>false))."</th>"; echo "<th>".__('Current year', 'monitoring')." ".Html::showToolTip(__('Availability', 'monitoring'), array('display'=>false))."</th>"; echo "<th>".__('Detail', 'monitoring')."</th>"; echo '<th>'.__('Acknowledge', 'monitoring').'</th>'; echo "<th>".__('Arguments', 'monitoring')."</th>"; echo "</tr>"; // $querys = "SELECT `glpi_plugin_monitoring_services`.* FROM `glpi_plugin_monitoring_services` // LEFT JOIN `glpi_plugin_monitoring_components` // on `plugin_monitoring_components_id` = `glpi_plugin_monitoring_components`.`id` // WHERE `plugin_monitoring_componentscatalogs_hosts_id`='".$row['id']."' // ORDER BY `name`"; // $results = $DB->query($querys); // while ($datas=$DB->fetch_array($results)) { // $this->getFromDB($datas['id']); echo "<tr class='tab_bg_1'>"; PluginMonitoringDisplay::displayLine($row, 0); echo "</tr>"; // } echo "<tr style='border:1px solid #ccc;background-color:#ffffff'>"; echo "<td colspan='14' height='5'></td>"; echo "</tr>"; } echo "</table>"; Html::closeForm(); }
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'))); }
/** * Display services associated with host * * @param $itemtype value type of item * @param $items_id integer id of the object * **/ function listByHost($itemtype, $items_id) { global $LANG, $CFG_GLPI, $DB; $pmComponentscatalog = new PluginMonitoringComponentscatalog(); $query = "SELECT * FROM `glpi_plugin_monitoring_componentscatalogs_hosts`\n WHERE `items_id`='" . $items_id . "'\n AND `itemtype`='" . $itemtype . "'"; $result = $DB->query($query); // echo "<form name='form' method='post' // action='".$CFG_GLPI['root_doc']."/plugins/monitoring/front/service.form.php'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_1'>"; echo "<th colspan='5'>"; echo $LANG['plugin_monitoring']['service'][0]; // echo " <a href='".$CFG_GLPI['root_doc']."/plugins/monitoring/front/service.form.php?services_id=".$a_hosts['id']."'> // <img src='".$CFG_GLPI['root_doc']."/pics/menu_add.png' /></a>"; // // echo " <a href='".$CFG_GLPI['root_doc']."/plugins/monitoring/front/servicedef.form.php?add_template=1'> // <img src='".$CFG_GLPI['root_doc']."/pics/menu_addtemplate.png' /></a>"; echo "</th>"; echo "</tr>"; echo "<table>"; while ($data = $DB->fetch_array($result)) { $pmComponentscatalog->getFromDB($data['plugin_monitoring_componentscalalog_id']); echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_1'>"; echo "<th colspan='12'>" . $pmComponentscatalog->getTypeName() . " : " . $pmComponentscatalog->getLink() . "</th>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<th>"; echo $LANG['joblist'][0]; echo "</th>"; echo "<th>"; echo $LANG['entity'][0]; echo "</th>"; echo "<th>"; echo $LANG['stats'][7]; echo "</th>"; echo "<th>"; echo $LANG['plugin_monitoring']['component'][0]; echo "</th>"; echo "<th>"; echo $LANG['state'][0]; echo "</th>"; echo "<th>"; echo $LANG['plugin_monitoring']['service'][18]; echo "</th>"; echo "<th>"; echo $LANG['rulesengine'][82]; echo "</th>"; echo "<th>"; echo $LANG['plugin_monitoring']['host'][9]; echo "</th>"; echo "<th>" . $LANG['plugin_monitoring']['availability'][1] . " " . showToolTip($LANG['plugin_monitoring']['availability'][0], array('display' => false)) . "</th>"; echo "<th>" . $LANG['plugin_monitoring']['availability'][2] . " " . showToolTip($LANG['plugin_monitoring']['availability'][0], array('display' => false)) . "</th>"; echo "<th>" . $LANG['plugin_monitoring']['availability'][3] . " " . showToolTip($LANG['plugin_monitoring']['availability'][0], array('display' => false)) . "</th>"; echo "<th>"; echo $LANG['plugin_monitoring']['service'][4]; echo "</th>"; echo "</tr>"; $querys = "SELECT `glpi_plugin_monitoring_services`.* FROM `glpi_plugin_monitoring_services`\n LEFT JOIN `glpi_plugin_monitoring_components`\n on `plugin_monitoring_components_id` = `glpi_plugin_monitoring_components`.`id`\n WHERE `plugin_monitoring_componentscatalogs_hosts_id`='" . $data['id'] . "'\n ORDER BY `name`"; $results = $DB->query($querys); while ($datas = $DB->fetch_array($results)) { $this->getFromDB($datas['id']); echo "<tr class='tab_bg_1'>"; PluginMonitoringDisplay::displayLine($datas, 0); echo "</tr>"; } echo "</table>"; } // echo "<tr class='tab_bg_1'>"; // echo "<td colspan='8' align='center'>"; // echo "<input type='submit' class='submit' name='update' value='".$LANG['buttons'][7]."'>"; // echo "</td>"; // echo "</tr>"; echo "</table>"; echo "</form>"; }
/** * Display services associated with host * * @param $itemtype value type of item * @param $items_id integer id of the object * **/ function listByHost($itemtype, $items_id) { global $CFG_GLPI, $DB; $pmComponentscatalog = new PluginMonitoringComponentscatalog(); $query = "SELECT * FROM `glpi_plugin_monitoring_componentscatalogs_hosts`\n WHERE `items_id`='" . $items_id . "'\n AND `itemtype`='" . $itemtype . "'"; $result = $DB->query($query); // echo "<form name='form' method='post' // action='".$CFG_GLPI['root_doc']."/plugins/monitoring/front/service.form.php'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_1'>"; echo "<th colspan='5'>"; echo __('Resources', 'monitoring'); $item = new $itemtype(); $item->getFromDB($items_id); echo " - " . $item->getTypeName(); echo " - " . $item->getName(); // echo " <a href='".$CFG_GLPI['root_doc']."/plugins/monitoring/front/service.form.php?services_id=".$a_hosts['id']."'> // <img src='".$CFG_GLPI['root_doc']."/pics/menu_add.png' /></a>"; // // echo " <a href='".$CFG_GLPI['root_doc']."/plugins/monitoring/front/servicedef.form.php?add_template=1'> // <img src='".$CFG_GLPI['root_doc']."/pics/menu_addtemplate.png' /></a>"; echo "</th>"; echo "</tr>"; echo "<table class='tab_cadre_fixe'>"; while ($data = $DB->fetch_array($result)) { $pmComponentscatalog->getFromDB($data['plugin_monitoring_componentscalalog_id']); echo "<tr class='tab_bg_1'>"; echo "<th colspan='14'>" . $pmComponentscatalog->getTypeName() . " : " . $pmComponentscatalog->getLink() . "</th>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<th>"; echo __('Status'); echo "</th>"; echo "<th>"; echo __('Entity'); echo "</th>"; echo "<th>"; echo __('Components', 'monitoring'); echo "</th>"; echo "<th>"; echo __('Components', 'monitoring'); echo "</th>"; echo "<th>"; echo __('Status'); echo "</th>"; echo "<th>"; echo __('Last check', 'monitoring'); echo "</th>"; echo "<th>"; echo __('Result details'); echo "</th>"; echo "<th>"; echo __('Check period', 'monitoring'); echo "</th>"; echo "<th>" . __('Current month', 'monitoring') . " " . Html::showToolTip(__('Availability', 'monitoring'), array('display' => false)) . "</th>"; echo "<th>" . __('Last month', 'monitoring') . " " . Html::showToolTip(__('Availability', 'monitoring'), array('display' => false)) . "</th>"; echo "<th>" . __('Current year', 'monitoring') . " " . Html::showToolTip(__('Availability', 'monitoring'), array('display' => false)) . "</th>"; echo "<th>" . __('Detail', 'monitoring') . "</th>"; echo '<th>' . __('Acknowledge', 'monitoring') . '</th>'; echo "<th>"; echo __('Arguments', 'monitoring'); echo "</th>"; echo "</tr>"; $querys = "SELECT `glpi_plugin_monitoring_services`.* FROM `glpi_plugin_monitoring_services`\n LEFT JOIN `glpi_plugin_monitoring_components`\n on `plugin_monitoring_components_id` = `glpi_plugin_monitoring_components`.`id`\n WHERE `plugin_monitoring_componentscatalogs_hosts_id`='" . $data['id'] . "'\n ORDER BY `name`"; $results = $DB->query($querys); while ($datas = $DB->fetch_array($results)) { $this->getFromDB($datas['id']); echo "<tr class='tab_bg_1'>"; PluginMonitoringDisplay::displayLine($datas, 0); echo "</tr>"; } echo "<tr style='border:1px solid #ccc;background-color:#ffffff'>"; echo "<td colspan='14' height='5'></td>"; echo "</tr>"; } echo "</table>"; Html::closeForm(); }