static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtemplate=0) { switch ($item->getType()) { case 'Central' : $pmDisplay = new PluginMonitoringDisplay(); // $pmDisplay->showHostsCounters("Hosts", 1, 1); $pmDisplay->showHostsBoard(); return true; } if ($item->getID() > 0) { if ($tabnum == 0) { PluginMonitoringToolbox::loadLib(); $pmService = new PluginMonitoringService(); $pmService->manageServices(get_class($item), $item->fields['id']); $pmHostconfig = new PluginMonitoringHostconfig(); $pmHostconfig->showForm($item->getID(), get_class($item)); } else if ($tabnum == 1) { $pmService = new PluginMonitoringService(); $pmService->showGraphsByHost(get_class($item), $item->fields['id']); } } return true; }
function configureNodesLinks($weathermaps_id) { global $DB,$CFG_GLPI; $networkPort = new NetworkPort(); $this->getFromDB($weathermaps_id); $style = ''; if ($this->fields['width'] > 950) { $style = ";position:relative;left:-".(($this->fields['width'] - 950) / 2)."px"; } echo "<table class='tab_cadre' style='width:". $this->fields['width']."px;height:".$this->fields['height']."px". $style."'>"; echo "<tr class='tab_bg_1'>"; echo "<th colspan='2'>"; echo __('Nodes and links', 'monitoring'); echo "</th>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td valign='top'>"; echo "<div>"; PluginMonitoringToolbox::loadLib(); $this->drawMap($weathermaps_id, 100, 1); echo "</div>"; echo "</td>"; echo "<td valign='top'>"; echo "<div style='position: fixed;top: 30px;right: 0;z-index:999;' >"; echo "<table class='tab_cadre' width='100%'>"; echo "<tr>"; echo "<td>"; echo "<a onClick='Ext.get(\"weathermapform\").toggle();'> <img src='".$CFG_GLPI["root_doc"]."/pics/deplier_down.png' /> ".__('Display weathermap form', 'monitoring')." <img src='".$CFG_GLPI["root_doc"]."/pics/deplier_down.png' /></a>"; echo "</td>"; echo "</tr>"; echo"</table>"; echo "</div>"; echo "<div style='position: fixed;top: 50px;right: 0;z-index:1000;' id='weathermapform' >"; echo '<form name="pointform" method="post" action="'.$CFG_GLPI['root_doc'].'/plugins/monitoring/front/weathermapnode.form.php">'; echo "<table>"; echo "<tr>"; echo "<td>"; echo "<table class='tab_cadre' width='100%'>"; echo "<tr>"; echo "<th colspan='2'>"; echo "x : "; echo '<input type="text" name="x" size="4" value="50" />'; echo " "; echo "y : "; echo '<input type="text" name="y" size="4" value="50"/>'; echo "</th>"; echo "</tr>"; // * Add node echo "<tr>"; echo "<th colspan='2'>"; echo "<input type='hidden' name='plugin_monitoring_weathermaps_id' value='".$weathermaps_id."' />"; echo __('Add a node', 'monitoring'); echo "</th>"; echo "</tr>"; echo "<tr>"; echo "<td>"; echo __('Node', 'monitoring')." :"; echo "</td>"; echo "<td>"; Dropdown::showAllItems("items_id"); echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td>"; echo __('Name')." :"; echo "</td>"; echo "<td>"; echo "<input type='text' name='name' value='' />"; echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td>"; echo __('Position of label', 'monitoring')." :"; echo "</td>"; echo "<td>"; $positions = array( 'middle' => __('Center', 'monitoring'), 'start' => __('Right', 'monitoring'), 'end' => __('Left', 'monitoring') ); Dropdown::showFromArray('position', $positions); echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td align='center' colspan='2'>"; echo "<input type='submit' name='add' value=\"".__('Add')."\" class='submit'>"; echo "</td>"; echo "</tr>"; // * Change node position echo "<tr>"; echo "<th colspan='2'>"; echo __('Edit a node', 'monitoring'); echo "</th>"; echo "</tr>"; echo "<tr>"; echo "<td colspan='2' align='center'>"; $query = "SELECT * FROM `".getTableForItemType("PluginMonitoringWeathermapnode")."` WHERE `plugin_monitoring_weathermaps_id`='".$weathermaps_id."' ORDER BY `name`"; $result = $DB->query($query); $elements = array(); $elements[0] = Dropdown::EMPTY_VALUE; $result = $DB->query($query); while ($data=$DB->fetch_array($result)) { $itemtype = $data['itemtype']; if ($itemtype == '0') { $pmWeathermapnode->delete($data); } else { $item = new $itemtype(); $item->getFromDB($data['items_id']); $name = $data['name']; if ($name == '') { $name = $item->getName(); } $elements[$data['id']] = $name; } } $rand = Dropdown::showFromArray('id_update', $elements); $params = array('items_id' => '__VALUE__', 'rand' => $rand); Ajax::updateItemOnSelectEvent("dropdown_id_update$rand", "show_updatenode$rand", $CFG_GLPI["root_doc"]."/plugins/monitoring/ajax/dropdownWnode.php", $params, TRUE); echo "<span id='show_updatenode$rand'></span>\n"; echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td align='center' colspan='2'>"; echo "<input type='submit' name='update' value=\"".__('Save')."\" class='submit'>"; echo "</td>"; echo "</tr>"; // * Delete node echo "<tr>"; echo "<th colspan='2'>"; echo __('Delete a node', 'monitoring'); echo "</th>"; echo "</tr>"; echo "<tr>"; echo "<td>"; echo "</td>"; echo "<td>"; $query = "SELECT * FROM `".getTableForItemType("PluginMonitoringWeathermapnode")."` WHERE `plugin_monitoring_weathermaps_id`='".$weathermaps_id."' ORDER BY `name`"; $result = $DB->query($query); $elements = array(); $elements[0] = Dropdown::EMPTY_VALUE; $result = $DB->query($query); while ($data=$DB->fetch_array($result)) { $itemtype = $data['itemtype']; $item = new $itemtype(); $item->getFromDB($data['items_id']); $name = $data['name']; if ($name == '') { $name = $item->getName(); } $elements[$data['id']] = $name; } Dropdown::showFromArray('id', $elements); echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td align='center' colspan='2'>"; echo "<input type='submit' name='purge' value=\"".__('Delete permanently')."\" class='submit'>"; echo "</td>"; echo "</tr>"; echo "</table>"; Html::closeForm(); echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td>"; echo '<form name="formlink" method="post" action="'.$CFG_GLPI['root_doc'].'/plugins/monitoring/front/weathermaplink.form.php">'; echo "<table class='tab_cadre' width='100%'>"; // *Add Link echo "<tr>"; echo "<th colspan='2'>"; echo __('Add a link', 'monitoring'); echo "</th>"; echo "</tr>"; echo "<tr>"; echo "<td>"; echo __('Source', 'monitoring')."* :"; echo "</td>"; echo "<td>"; $query = "SELECT `glpi_plugin_monitoring_weathermapnodes`.`id` as `id`, `glpi_plugin_monitoring_weathermapnodes`.`name` as `name`, `glpi_plugin_monitoring_componentscatalogs_hosts`.`itemtype`, `glpi_plugin_monitoring_componentscatalogs_hosts`.`items_id`, `glpi_plugin_monitoring_services`.`id` as `services_id`, `glpi_plugin_monitoring_components`.`name` as `components_name`, `plugin_monitoring_commands_id`, `glpi_plugin_monitoring_components`.`arguments`, `glpi_plugin_monitoring_services`.`networkports_id` FROM `glpi_plugin_monitoring_weathermapnodes` LEFT JOIN `glpi_plugin_monitoring_componentscatalogs_hosts` ON (`glpi_plugin_monitoring_weathermapnodes`.`items_id`=`glpi_plugin_monitoring_componentscatalogs_hosts`.`items_id` AND `glpi_plugin_monitoring_weathermapnodes`.`itemtype`=`glpi_plugin_monitoring_componentscatalogs_hosts`.`itemtype`) LEFT JOIN `glpi_plugin_monitoring_services` ON `plugin_monitoring_componentscatalogs_hosts_id`= `glpi_plugin_monitoring_componentscatalogs_hosts`.`id` LEFT JOIN `glpi_plugin_monitoring_components` ON `plugin_monitoring_components_id` = `glpi_plugin_monitoring_components`.`id` WHERE `is_weathermap` = '1' AND `plugin_monitoring_weathermaps_id`='".$weathermaps_id."' ORDER BY `itemtype`,`items_id`,`glpi_plugin_monitoring_components`.`name`"; $elements = array(); $elements[0] = Dropdown::EMPTY_VALUE; $elements2 = array(); $result = $DB->query($query); while ($data=$DB->fetch_array($result)) { $itemtype = $data['itemtype']; $item = new $itemtype(); $item->getFromDB($data['items_id']); $name = $data['name']; if ($name == '') { $name = $item->getName(); } // Try to get device/node connected on this port $device_connected = ''; if ($data['arguments'] != '') { $arguments = importArrayFromDB($data['arguments']); foreach ($arguments as $argument) { if (!is_numeric($argument)) { if (strstr($argument, "[[NETWORKPORTDESCR]]")){ if (class_exists("PluginFusinvsnmpNetworkPort")) { $pfNetworkPort = new PluginFusinvsnmpNetworkPort(); $pfNetworkPort->loadNetworkport($data['networkports_id']); $argument = $pfNetworkPort->getValue("ifdescr"); } } elseif (strstr($argument, "[[NETWORKPORTNUM]]")){ $networkPort = new NetworkPort(); $networkPort->getFromDB($data['networkports_id']); $argument = $pfNetworkPort->fields['logical_number']; } elseif (strstr($argument, "[[NETWORKPORTNAME]]")){ $networkPort = new NetworkPort(); $networkPort->getFromDB($data['networkports_id']); $argument = $pfNetworkPort->fields['name']; } // Search networkport have this name or description $a_ports = $networkPort->find("`itemtype`='".$itemtype."' AND `items_id`='".$data['items_id']."' AND `name`='".$argument."'"); foreach ($a_ports as $pdata) { if ($device_connected == '') { $oppositeports_id = $networkPort->getContact($pdata['id']); if ($oppositeports_id) { $networkPort->getFromDB($oppositeports_id); $a_nodes = $pmWeathermapnode->find(" `plugin_monitoring_weathermaps_id`='".$weathermaps_id."' AND `itemtype`='".$networkPort->fields['itemtype']."' AND `items_id`='".$networkPort->fields['items_id']."'", "", 1); if (count($a_nodes) > 0) { $a_node = current($a_nodes); $device_connected = $pmWeathermapnode->getNodeName($a_node['id']); } } } } if ($device_connected == '' AND class_exists("PluginFusinvsnmpNetworkPort")) { $queryn = "SELECT `glpi_networkports`.`id` FROM `glpi_plugin_fusinvsnmp_networkports` LEFT JOIN `glpi_networkports` ON `glpi_networkports`.`id`=`networkports_id` WHERE `itemtype`='".$itemtype."' AND `items_id`='".$data['items_id']."' AND `ifdescr`='".$argument."'"; $resultn = $DB->query($queryn); while ($pdata=$DB->fetch_array($resultn)) { if ($device_connected == '') { $oppositeports_id = $networkPort->getContact($pdata['id']); if ($oppositeports_id) { $networkPort->getFromDB($oppositeports_id); $a_nodes = $pmWeathermapnode->find(" `plugin_monitoring_weathermaps_id`='".$weathermaps_id."' AND `itemtype`='".$networkPort->fields['itemtype']."' AND `items_id`='".$networkPort->fields['items_id']."'", "", 1); if (count($a_nodes) > 0) { $a_node = current($a_nodes); $queryl = "SELECT `plugin_monitoring_weathermapnodes_id_1` FROM `glpi_plugin_monitoring_weathermaplinks` LEFT JOIN `glpi_plugin_monitoring_weathermapnodes` ON `glpi_plugin_monitoring_weathermapnodes`.`id` = `plugin_monitoring_weathermapnodes_id_1` WHERE ((`plugin_monitoring_weathermapnodes_id_1`='".$data['id']."' AND `plugin_monitoring_weathermapnodes_id_2`='".$a_node['id']."') OR (`plugin_monitoring_weathermapnodes_id_1`='".$a_node['id']."' AND `plugin_monitoring_weathermapnodes_id_2`='".$data['id']."')) AND `plugin_monitoring_weathermaps_id` = '".$weathermaps_id."'"; $resultl = $DB->query($queryl); if ($DB->numrows($resultl) == '0') { $device_connected = $pmWeathermapnode->getNodeName($a_node['id']); } } } } } } } } } if ($device_connected == '') { $networkPort->getFromDB($data['networkports_id']); $elements2[$data['id']."-".$data['services_id']] = $name." [".$networkPort->getfield('name')."] (".$data['components_name'].")"; } else { $networkPort->getFromDB($data['networkports_id']); $elements[$data['id']."-".$data['services_id']] = $name." [".$networkPort->getfield('name')."] (".$data['components_name'].") > ".$device_connected; } } if (count($elements) > 1 AND count($elements2) > 0) { $elements = array_merge($elements,array('0'=>Dropdown::EMPTY_VALUE)); $elements = array_merge($elements, $elements2); } else { $elements = array_merge($elements, $elements2); } Dropdown::showFromArray('linksource', $elements); echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td>"; echo __('Destination', 'monitoring')." :"; echo "</td>"; echo "<td>"; echo "<div id='nodedestination'>"; $query = "SELECT * FROM `".getTableForItemType("PluginMonitoringWeathermapnode")."` WHERE `plugin_monitoring_weathermaps_id`='".$weathermaps_id."' ORDER BY `name`"; $result = $DB->query($query); $elements = array(); $elements[0] = Dropdown::EMPTY_VALUE; $result = $DB->query($query); while ($data=$DB->fetch_array($result)) { $itemtype = $data['itemtype']; $item = new $itemtype(); $item->getFromDB($data['items_id']); $name = $data['name']; if ($name == '') { $name = $item->getName(); } $elements[$data['id']] = $name; } Dropdown::showFromArray('plugin_monitoring_weathermapnodes_id_2', $elements); echo "</div>"; echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td>"; echo __('Max bandwidth input', 'monitoring')." :"; echo "</td>"; echo "<td>"; echo "<input type='text' name='bandwidth_in' value=''/>"; echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td>"; echo __('Max bandwidth output', 'monitoring')." :"; echo "</td>"; echo "<td>"; echo "<input type='text' name='bandwidth_out' value=''/>"; echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td align='center' colspan='2'>"; echo "<input type='submit' name='add' value=\"".__('Add')."\" class='submit'>"; echo "</td>"; echo "</tr>"; // * Edit link echo "<tr>"; echo "<th colspan='2'>"; echo __('Edit a link', 'monitoring'); echo "</th>"; echo "</tr>"; echo "<tr>"; echo "<td colspan='2' align='center'>"; $pmWeathermapnode = new PluginMonitoringWeathermapnode(); $query = "SELECT `glpi_plugin_monitoring_weathermaplinks`.`id` as `id`, `itemtype`, `items_id`, `name`, `plugin_monitoring_weathermapnodes_id_2` FROM `glpi_plugin_monitoring_weathermaplinks` LEFT JOIN `glpi_plugin_monitoring_weathermapnodes` ON `glpi_plugin_monitoring_weathermapnodes`.`id` = `plugin_monitoring_weathermapnodes_id_1` WHERE `plugin_monitoring_weathermaps_id` = '".$weathermaps_id."'"; $elements = array(); $elements[0] = Dropdown::EMPTY_VALUE; $result = $DB->query($query); while ($data=$DB->fetch_array($result)) { $itemtype = $data['itemtype']; $item = new $itemtype(); $item->getFromDB($data['items_id']); $name1 = $data['name']; if ($name1 == '') { $name1 = $item->getName(); } $pmWeathermapnode->getFromDB($data['plugin_monitoring_weathermapnodes_id_2']); $itemtype = $pmWeathermapnode->fields['itemtype']; $item = new $itemtype(); $item->getFromDB($pmWeathermapnode->fields['items_id']); $name2 = $pmWeathermapnode->fields['name']; if ($name2 == '') { $name2 = $item->getName(); } $elements[$data['id']] = $name1." - ".$name2; } $rand = Dropdown::showFromArray('id_update', $elements); $params = array('items_id' => '__VALUE__', 'rand' => $rand); Ajax::updateItemOnSelectEvent("dropdown_id_update$rand", "show_updatelink$rand", $CFG_GLPI["root_doc"]."/plugins/monitoring/ajax/dropdownWlink.php", $params, TRUE); echo "<span id='show_updatelink$rand'></span>\n"; echo "</td>"; echo "</tr>"; // * Delete link echo "<tr>"; echo "<th colspan='2'>"; echo __('Delete a link', 'monitoring'); echo "</th>"; echo "</tr>"; echo "<tr>"; echo "<td>"; echo __('Link', 'monitoring')." :"; echo "</td>"; echo "<td>"; Dropdown::showFromArray('id', $elements); echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td align='center' colspan='2'>"; echo "<input type='submit' name='purge' value=\"".__('Delete permanently')."\" class='submit'>"; echo "</td>"; echo "</tr>"; echo "</table>"; Html::closeForm(); echo "</td>"; echo "</tr>"; echo "</table>"; echo "</div>"; echo "</td>"; echo "</tr>"; echo "</table>"; }
/** * Display list of services */ function showResourcesBoard($width = '', $perfdatas = false, $params = array()) { global $DB, $CFG_GLPI; $col_to_display = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11); $data = Search::prepareDatasForSearch($params['itemtype'], $params, $col_to_display); $data['tocompute'] = $data['toview']; Search::constructSQL($data); //echo "<pre>"; print_r($data['sql']['search']); Search::constructDatas($data); /* if (! isset($_SESSION['plugin_monitoring_reduced_interface'])) { $_SESSION['plugin_monitoring_reduced_interface'] = false; } if (! isset($_GET['order'])) { $_GET['order'] = "ASC"; } if (! isset($_GET['sort'])) { $_GET['sort'] = ""; } $order = "ASC"; if (isset($_GET['order'])) { $order = $_GET['order']; } $where = ''; if (isset($_GET['field'])) { foreach ($_GET['field'] as $key=>$value) { $wheretmp = ''; if (isset($_GET['link'][$key])) { $wheretmp.= " ".$_GET['link'][$key]." "; } $wheretmp .= Search::addWhere( "", 0, "PluginMonitoringService", $_GET['field'][$key], $_GET['searchtype'][$key], $_GET['contains'][$key]); if (!strstr($wheretmp, "``.``")) { if ($where != '' AND !isset($_GET['link'][$key])) { $where .= " AND "; } $where .= $wheretmp; } } } if ($where != '') { $where = "(".$where; $where .= ") AND "; } $where .= ' `glpi_plugin_monitoring_services`.`entities_id` IN ('.$_SESSION['glpiactiveentities_string'].')'; if ($where != '') { $where = " WHERE ".$where; $where = str_replace("`".getTableForItemType("PluginMonitoringDisplay")."`.", "", $where); } $leftjoin = " INNER JOIN `glpi_plugin_monitoring_services` ON (`glpi_plugin_monitoring_services`.`plugin_monitoring_componentscatalogs_hosts_id` = `glpi_plugin_monitoring_componentscatalogs_hosts`.`id`) INNER JOIN `glpi_plugin_monitoring_hosts` ON `glpi_plugin_monitoring_componentscatalogs_hosts`.`items_id` = `glpi_plugin_monitoring_hosts`.`items_id` AND `glpi_plugin_monitoring_componentscatalogs_hosts`.`itemtype` = `glpi_plugin_monitoring_hosts`.`itemtype` INNER JOIN `glpi_plugin_monitoring_componentscatalogs` ON `plugin_monitoring_componentscalalog_id` = `glpi_plugin_monitoring_componentscatalogs`.`id` INNER JOIN `glpi_plugin_monitoring_components` ON (`glpi_plugin_monitoring_services`.`plugin_monitoring_components_id` = `glpi_plugin_monitoring_components`.`id`) INNER JOIN `glpi_entities` ON (`glpi_plugin_monitoring_services`.`entities_id` = `glpi_entities`.`id`) "; $leftjoin .= " LEFT JOIN `glpi_computers` ON `glpi_plugin_monitoring_componentscatalogs_hosts`.`items_id` = `glpi_computers`.`id` AND `glpi_plugin_monitoring_componentscatalogs_hosts`.`itemtype`='Computer'"; $leftjoin .= " LEFT JOIN `glpi_printers` ON `glpi_plugin_monitoring_componentscatalogs_hosts`.`items_id` = `glpi_printers`.`id` AND `glpi_plugin_monitoring_componentscatalogs_hosts`.`itemtype`='Printer'"; $leftjoin .= " LEFT JOIN `glpi_networkequipments` ON `glpi_plugin_monitoring_componentscatalogs_hosts`.`items_id` = `glpi_networkequipments`.`id` AND `glpi_plugin_monitoring_componentscatalogs_hosts`.`itemtype`='NetworkEquipment'"; // * ORDER $ORDERQUERY = "ORDER BY `glpi_plugin_monitoring_services`.`name` ASC"; $toview = array(1, 2, 3, 4, 5); $toviewComplete = array( 'ITEM_0' => 'host_name', 'ITEM_1' => 'component_name', 'ITEM_2' => 'state', 'ITEM_3' => 'last_check', 'ITEM_4' => 'event' ); foreach ($toview as $key => $val) { if ($_GET['sort']==$val) { $ORDERQUERY = Search::addOrderBy("PluginMonitoringService", $_GET['sort'], $_GET['order'], $key); foreach ($toviewComplete as $keyi=>$vali) { $ORDERQUERY= str_replace($keyi, $vali, $ORDERQUERY); } } } $query = "SELECT `glpi_plugin_monitoring_services`.*, CONCAT_WS('', `glpi_computers`.`name`, `glpi_printers`.`name`, `glpi_networkequipments`.`name`) AS host_name, `glpi_plugin_monitoring_componentscatalogs_hosts`.`itemtype`, `glpi_plugin_monitoring_componentscatalogs_hosts`.`items_id`, `glpi_plugin_monitoring_hosts`.`id` AS host_id, `glpi_plugin_monitoring_hosts`.`state` AS host_state, `glpi_plugin_monitoring_hosts`.`is_acknowledged` AS host_acknowledged, `glpi_plugin_monitoring_components`.`id` AS component_id, `glpi_plugin_monitoring_components`.`name` AS component_name FROM `glpi_plugin_monitoring_componentscatalogs_hosts` ".$leftjoin." ".$where." ".$ORDERQUERY; $result = $DB->query($query); $start = 0; if (isset($_GET["start"])) { $start = $_GET["start"]; } $numrows = $DB->numrows($result); $parameters = ''; $globallinkto = Toolbox::append_params( array('criteria' => Toolbox::stripslashes_deep($_GET['search']['criteria']), 'metacriteria' => Toolbox::stripslashes_deep($_GET['search']['metacriteria'])), '&'); $parameters = "sort=".$_GET['sort']."&order=".$_GET['order'].$globallinkto; Html::printPager($start, $numrows, $CFG_GLPI['root_doc']."/plugins/monitoring/front/service.php", $parameters); $limit = $numrows; if ($_SESSION["glpilist_limit"] < $numrows) { $limit = $_SESSION["glpilist_limit"]; } $query .= " LIMIT ".intval($start)."," . intval($_SESSION['glpilist_limit']); // Fred : on repose la requête sur la base une 2ème fois ... ? $result = $DB->query($query); */ $rand = mt_rand(); if (!isset($data['data']) || !isset($data['data']['totalcount'])) { return false; } // Contruct Pager parameters $globallinkto = Toolbox::append_params(array('criteria' => Toolbox::stripslashes_deep($data['search']['criteria']), 'metacriteria' => Toolbox::stripslashes_deep($data['search']['metacriteria'])), '&'); $parameters = "sort=" . $data['search']['sort'] . "&order=" . $data['search']['order'] . '&' . $globallinkto; if (isset($_GET['_in_modal'])) { $parameters .= "&_in_modal=1"; } // If the begin of the view is before the number of items if ($data['data']['count'] > 0) { // Display pager only for HTML if ($data['display_type'] == Search::HTML_OUTPUT) { $search_config_top = ""; $search_config_bottom = ""; Html::printPager($data['search']['start'], $data['data']['totalcount'], $data['search']['target'], $parameters, $data['itemtype'], 0, $search_config_top); } // Define begin and end var for loop // Search case $begin_display = $data['data']['begin']; $end_display = $data['data']['end']; } else { $search_config_top = ""; $search_config_bottom = ""; $begin_display = 0; $end_display = 0; } // Pour la génération des graphes ... echo '<div style="display:none"><input type="text" id="custom_date" value="' . date('m/d/Y') . '"> ' . ' <input type="text" id="custom_time" value="' . date('H:i') . '"></div>'; echo "<br/>"; if ($perfdatas) { echo "<table class='tab_cadrehov' style='width:100%;'>\n <tr class='tab_bg_1'><th colspan='2' class='left'>" . __('Global counters', 'monitoring') . "</th></tr>\n <tr class='tab_bg_3' id='global_counters'></tr>\n </table>"; echo "<br/>"; } if ($width == '') { echo "<table class='tab_cadrehov' style='width:100%;'>"; } else { echo "<table class='tab_cadrehov' style='width:" . $width . "px;'>"; } $num = 0; echo "<tr class='tab_bg_1'>"; if (!isset($_SESSION['plugin_monitoring_reduced_interface'])) { $_SESSION['plugin_monitoring_reduced_interface'] = 0; } if (!$_SESSION['plugin_monitoring_reduced_interface']) { // echo Search::showHeaderItem(0, __('Show counters', 'monitoring'), $num); echo Search::showHeaderItem(0, __('Show graphics', 'monitoring'), $num); } $this->showHeaderItem(__('Host name', 'monitoring'), 1, $num, $begin_display, $globallinkto, 'service.php', 'PluginMonitoringService'); $this->showHeaderItem(__('Component', 'monitoring'), 2, $num, $begin_display, $globallinkto, 'service.php', 'PluginMonitoringService'); if (!$perfdatas) { $this->showHeaderItem(__('Resource state', 'monitoring'), 3, $num, $begin_display, $globallinkto, 'service.php', 'PluginMonitoringService'); $this->showHeaderItem(__('Last check', 'monitoring'), 4, $num, $begin_display, $globallinkto, 'service.php', 'PluginMonitoringService'); echo Search::showHeaderItem(0, __('Result details', 'monitoring'), $num); echo Search::showHeaderItem(0, __('Check period', 'monitoring'), $num); if (Session::haveRight("plugin_monitoring_acknowledge", READ)) { echo Search::showHeaderItem(0, __('Acknowledge', 'monitoring'), $num); } } echo "</tr>"; PluginMonitoringDisplay::$ar_counterTypes = array(); PluginMonitoringToolbox::loadLib(); // while ($data=$DB->fetch_array($result)) { //echo "<pre>"; print_r($data['data']); foreach ($data['data']['rows'] as $row) { // Reduced array or not ? if ($_SESSION['plugin_monitoring_reduced_interface'] and $row[2]['displayname'] == 'OK') { continue; } echo "<tr class='tab_bg_3'>"; $this->displayLine($row, 1, $perfdatas); echo "</tr>"; } echo "</table>"; echo "<br/>"; Html::printPager($data['search']['start'], $data['data']['totalcount'], $data['search']['target'], $parameters, '', 0, $search_config_bottom); if ($perfdatas) { // foreach(PluginMonitoringDisplay::$ar_counterTypes as $counter_id => $counter_name) { // Toolbox::logInFile("pm", "Counter type +++ : $counter_id => $counter_name\n"); // } echo "<script>\n Ext.onReady(function(){\n // console.log('Ready ...');\n window.setTimeout(function(){"; foreach (PluginMonitoringDisplay::$ar_counterTypes as $counter_id => $counter_name) { echo "\n var global = Ext.get('#global_counter_" . $counter_id . "');\n if (! global) {\n var html = \"<th id='global_counter_" . $counter_id . "' counterType ='" . $counter_id . "' class='global_counter'>\";\n html += \"<span class='global_counter_name'>" . $counter_name . "</span>\";\n html += \"<span> : </span>\";\n html += \"<span class='global_counter_value'>0</span>\";\n html += \"</th>\";\n Ext.select('#global_counters').createChild(html);\n console.log('Created an element for global \\'" . $counter_id . " / " . $counter_name . "\\' counter.');\n }\n"; } echo "\n }, 100);\n window.setInterval(function(){\n Ext.select('.global_counter').each(function(el) {\n var counterType = el.getAttribute('counterType');\n // console.log('Global counter for '+counterType+' exists.');\n\n el.select('.global_counter_value').each(function(elGlobalValue) {\n elGlobalValue.update('0');\n // console.log('Global counter value is : '+parseFloat(elGlobalValue.dom.innerHTML));\n\n var select = 'td[counter=\\'' + counterType + '\\'][counterType=\\'difference\\']';\n Ext.select(select).each(function(el) {\n // console.log('Local counter is ' + el.getAttribute('counter') + ', value is : '+parseFloat(el.dom.innerHTML));\n var newCounter = parseFloat(elGlobalValue.dom.innerHTML) + parseFloat(el.dom.innerHTML);\n elGlobalValue.update(newCounter.toString());\n });\n });\n });\n }, 1000);\n });\n </script>"; } }
function slideSlider($id) { global $CFG_GLPI, $DB; echo "<script type='text/javascript'> function fittext(itemid) { document.getElementById(itemid).style.fontSize = '50px'; var fontsize = 50; while(document.getElementById(itemid).offsetWidth > 120) { fontsize--; if (fontsize > 20) { fontsize--; } document.getElementById(itemid).style.fontSize = fontsize + 'px'; } while(document.getElementById(itemid).offsetHeight > 67) { fontsize--; document.getElementById(itemid).style.fontSize = fontsize + 'px'; } if (fontsize > 30) { document.getElementById(itemid).style.fontSize = '30px'; } if (fontsize < 7) { document.getElementById(itemid).style.fontSize = '7px'; } } </script>"; PluginMonitoringToolbox::loadLib(); $this->getFromDB($id); echo '<div id="custom_date" style="display:none"></div>'; echo '<div id="custom_time" style="display:none"></div>'; echo '<script src="'.$CFG_GLPI["root_doc"].'/plugins/monitoring/lib/slider.js-14/js/jssor.slider.mini.js"></script> <script> jQuery(document).ready(function ($) { //Define an array of slideshow transition code var _SlideshowTransitions = [ {$Duration:0001,$Opacity:2} ]; var options = { $AutoPlay: true, $AutoPlayInterval: '.$this->fields['duration'].'000, $SlideshowOptions: { $Class: $JssorSlideshowRunner$, $Transitions: _SlideshowTransitions, $TransitionsOrder: 1, $ShowLink: true } }; var jssor_slider1 = new $JssorSlider$(\'slider1_container\', options); }); </script>'; echo "<table class='tab_cadre'>"; echo "<tr>"; echo "<td>"; $query = "SELECT * FROM `glpi_plugin_monitoring_sliders_items` WHERE `plugin_monitoring_sliders_id`='".$id."'"; $result = $DB->query($query); $maxWidth = 0; $maxHeight = 0; $is_minemap = 0; while ($data=$DB->fetch_array($result)) { if ($data['itemtype'] == 'PluginMonitoringServicescatalog' || $data['itemtype'] == 'PluginMonitoringComponentscatalog' || $data['itemtype'] == 'PluginMonitoringCustomitem_Gauge' || $data['itemtype'] == 'PluginMonitoringCustomitem_Counter') { if ($maxWidth < 180) { $maxWidth = 180; } if ($maxHeight < 180) { $maxHeight = 180; } if ($data['is_minemap'] == 1) { $is_minemap = 1; } } else if ($data['itemtype'] == 'PluginMonitoringService') { if ($maxWidth < 475) { $maxWidth = 475; } if ($maxHeight < 330) { $maxHeight = 330; } } else if ($data['itemtype'] == "PluginMapsMap") { if ($maxWidth < 950) { $maxWidth = 950; } if ($maxHeight < 800) { $maxHeight = 800; } } else { $itemtype = $data['itemtype']; $item = new $itemtype(); $item->getFromDB($data['items_id']); if ($maxWidth < $item->fields['width']) { $maxWidth = $item->fields['width']; } if (isset($item->fields['height'])) { if ($maxHeight < $item->fields['width']) { $maxHeight = $item->fields['height']; } } } } if ($is_minemap) { $maxHeight = '1500'; } $pm = new PluginMonitoringComponentscatalog(); echo '<div id="slider1_container" style="position: relative; top: 0px; left: 0px; width: '.$maxWidth.'px; height: '.$maxHeight.'px;"> <!-- Slides Container --> <div u="slides" style="cursor: move; position: absolute; overflow: hidden; left: 0px; top: 0px; width: '.$maxWidth.'px; height: '.$maxHeight.'px;">'; $result = $DB->query($query); while ($data=$DB->fetch_array($result)) { $itemtype = $data['itemtype']; $item = new $itemtype(); if ($itemtype == "PluginMonitoringService") { echo '<div>'; echo $item->showWidget($data['items_id'], $data['extra_infos']); echo '</div>'; } else if ($itemtype == "PluginMonitoringWeathermap") { echo '<div>'; echo '<div id="weathermap-'.$data['items_id'].'"></div>'; echo '</div>'; } else if ($itemtype == 'PluginMonitoringDisplayview') { echo '<div>'; $pmDisplayview_item = new PluginMonitoringDisplayview_item(); echo $pmDisplayview_item->view($data['items_id']); echo '</div>'; } else if ($itemtype == "PluginMapsMap") { echo '<div>'; echo '<div id="pluginmap"></div>'; echo '</div>'; } else { echo '<div>'; echo $item->showWidget($data['items_id']); echo '</div>'; } } echo ' </div> </div>'; $result = $DB->query($query); while ($data=$DB->fetch_array($result)) { $itemtype = $data['itemtype']; $item = new $itemtype(); // Ajax if ($itemtype == "PluginMonitoringService") { $pmComponent = new PluginMonitoringComponent(); $item = new $itemtype(); $item->getFromDB($data['items_id']); $pmComponent->getFromDB($item->fields['plugin_monitoring_components_id']); $pmServicegraph = new PluginMonitoringServicegraph(); $pmServicegraph->displayGraph($pmComponent->fields['graph_template'], "PluginMonitoringService", $data['items_id'], "0", $data['extra_infos'], "js"); } else if($itemtype == "PluginMonitoringComponentscatalog") { $pmComponentscatalog = new PluginMonitoringComponentscatalog(); $pmComponentscatalog->ajaxLoad($data['items_id'], $data['is_minemap']); } else if($itemtype == "PluginMonitoringServicescatalog") { $pmServicescatalog = new PluginMonitoringServicescatalog(); $pmServicescatalog->ajaxLoad($data['items_id']); } else if($itemtype == "PluginMonitoringDisplayview") { } else if($itemtype == "PluginMonitoringCustomitem_Gauge") { $pmCustomitem_Gauge = new PluginMonitoringCustomitem_Gauge(); $pmCustomitem_Gauge->ajaxLoad($data['items_id']); } else if($itemtype == "PluginMonitoringCustomitem_Counter") { $pmCustomitem_Counter = new PluginMonitoringCustomitem_Counter(); $pmCustomitem_Counter->ajaxLoad($data['items_id']); } if ($itemtype == "PluginMonitoringWeathermap") { $sess_id = session_id(); PluginMonitoringSecurity::updateSession(); echo "<script type='text/javascript'> var mgr = new Ext.UpdateManager('weathermap-".$data['items_id']."'); mgr.startAutoRefresh(50, \"".$CFG_GLPI["root_doc"]. "/plugins/monitoring/ajax/widgetWeathermap.php\"," . " \"id=".$data['items_id']."&extra_infos=". $data['extra_infos']."&sess_id=".$sess_id. "&glpiID=".$_SESSION['glpiID']. "&plugin_monitoring_securekey=".$_SESSION['plugin_monitoring_securekey']. "\", \"\", true); </script>"; } if ($itemtype == "PluginMapsMap") { $sess_id = session_id(); PluginMonitoringSecurity::updateSession(); echo "<script type='text/javascript'> var mgr = new Ext.UpdateManager('pluginmap'); mgr.startAutoRefresh(50, \"".$CFG_GLPI["root_doc"]. "/plugins/monitoring/ajax/widgetPluginmap.php\"," . " \"extra_infos=". $data['extra_infos']."&sess_id=".$sess_id. "&glpiID=".$_SESSION['glpiID']. "&plugin_monitoring_securekey=".$_SESSION['plugin_monitoring_securekey']. "\", \"\", true); </script>"; } } echo "</td>"; echo "</tr>"; echo "</table>"; }
function showWidget($id) { PluginMonitoringToolbox::loadLib(); return "<div id=\"updatecustomitem_gauge" . $id . "\"></div>"; }
$item = new $itemtype(); $item->getFromDB($items_id); $pmComponent->getFromDB($item->fields['plugin_monitoring_components_id']); $_SESSION['glpi_plugin_monitoring']['perfnameinvert'][$pmComponent->fields['id']] = array(); $_POST['perfnameinvert'] = explode("####", $_POST['perfnameinvert']); foreach ($_POST["perfnameinvert"] as $perfname) { $_SESSION['glpi_plugin_monitoring']['perfnameinvert'][$pmComponent->fields['id']][$perfname] = "checked"; } } if (isset($_POST["perfnamecolor"])) { $itemtype = $_GET['itemtype']; $items_id = $_GET['items_id']; $item = new $itemtype(); $item->getFromDB($items_id); $pmComponent->getFromDB($item->fields['plugin_monitoring_components_id']); $_SESSION['glpi_plugin_monitoring']['perfnamecolor'][$pmComponent->fields['id']] = array(); foreach ($_POST["perfnamecolor"] as $perfname => $color) { if ($color != '') { $_SESSION['glpi_plugin_monitoring']['perfnamecolor'][$pmComponent->fields['id']][$perfname] = $color; } } } Html::back(); } $pMonitoringDisplay = new PluginMonitoringDisplay(); if (isset($_GET['itemtype']) and isset($_GET['items_id'])) { PluginMonitoringToolbox::loadLib(); $pmServicegraph = new PluginMonitoringServicegraph(); $pMonitoringDisplay->displayGraphs($_GET['itemtype'], $_GET['items_id']); } Html::footer();
/** * Display graphs of services associated with host * * @param $itemtype value type of item * @param $items_id integer id of the object * **/ function showGraphsByHost($itemtype, $items_id) { global $CFG_GLPI,$DB; PluginMonitoringToolbox::loadLib(); $pmComponentscatalog = new PluginMonitoringComponentscatalog(); $pmComponent = new PluginMonitoringComponent(); $pmServicegraph = new PluginMonitoringServicegraph(); $networkPort = new NetworkPort(); $query = "SELECT * FROM `glpi_plugin_monitoring_componentscatalogs_hosts` WHERE `items_id`='".$items_id."' AND `itemtype`='".$itemtype."'"; $result = $DB->query($query); 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 "<table class='tab_cadre_fixe'>"; while ($data=$DB->fetch_array($result)) { $pmComponentscatalog->getFromDB($data['plugin_monitoring_componentscalalog_id']); $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`='".$data['id']."' ORDER BY `name`"; $results = $DB->query($querys); while ($datas=$DB->fetch_array($results)) { $pmComponent->getFromDB($datas['plugin_monitoring_components_id']); if ($pmComponent->fields['graph_template'] != 0) { echo "<tr>"; echo "<td>"; echo "<table class='tab_cadre'>"; echo "<tr class='tab_bg_3'>"; echo "<th>"; echo "<a href='".$CFG_GLPI['root_doc']."/plugins/monitoring/front/display.form.php?itemtype=PluginMonitoringService&items_id=".$datas['id']."'>"; echo $pmComponent->fields['name']; echo "</a>"; if (!is_null($datas['networkports_id']) && $datas['networkports_id'] > 0) { $networkPort->getFromDB($datas['networkports_id']); echo " [".$networkPort->getLink()."]"; } echo "</th>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td style='position: relative'>"; $pmServicegraph->displayGraph($pmComponent->fields['graph_template'], "PluginMonitoringService", $datas['id'], "0", "2h", "", 920); echo "</td>"; echo "</tr>"; echo "</table>"; echo "</td>"; echo "</tr>"; } } } echo "</tr>"; echo "</table>"; }
function view($id, $config = 0) { global $DB, $CFG_GLPI; $pmDisplayview = new PluginMonitoringDisplayview(); $pmDisplayview_rule = new PluginMonitoringDisplayview_rule(); $pmDisplayview->getFromDB($id); echo "<script type='text/javascript'>\n function fittext(itemid) {\n document.getElementById(itemid).style.fontSize = '50px';\n var fontsize = 50;\n while(document.getElementById(itemid).offsetWidth > 120) {\n fontsize--;\n if (fontsize > 20) {\n fontsize--;\n }\n document.getElementById(itemid).style.fontSize = fontsize + 'px';\n }\n while(document.getElementById(itemid).offsetHeight > 67) {\n fontsize--;\n document.getElementById(itemid).style.fontSize = fontsize + 'px';\n }\n if (fontsize > 30) {\n document.getElementById(itemid).style.fontSize = '30px';\n }\n if (fontsize < 7) {\n document.getElementById(itemid).style.fontSize = '7px';\n }\n }\n </script>"; PluginMonitoringToolbox::loadLib(); $style = ''; if ($config == '1') { $this->addItem($id); $pmDisplayview_rule->showReplayRulesForm($id); echo "<div id='updatecoordonates'></div>"; if ($pmDisplayview->fields['width'] > 950) { $style = ";position:relative;left:-" . ($pmDisplayview->fields['width'] - 950) / 2 . "px"; } } else { if (!is_null($pmDisplayview->fields['counter'])) { $pmDisplay = new PluginMonitoringDisplay(); $pmDisplay->showCounters($pmDisplayview->fields['counter']); } } echo "<table class='tab_cadre_fixe' id='test' style='width:" . $pmDisplayview->fields['width'] . "px" . $style . "'>"; echo "<tr class='tab_bg_1'>"; echo "<th>"; echo $pmDisplayview->fields['name']; echo "</th>"; echo "</tr>"; echo "<tr class='tab_bg_1' id='date_text'>"; echo "<th>"; echo __('Select date', 'monitoring') . " - " . __('Select time', 'monitoring'); echo "</th>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>"; $query = "SELECT * FROM `glpi_plugin_monitoring_displayviews_items`\n WHERE `plugin_monitoring_displayviews_id`='" . $id . "'\n AND `itemtype`='PluginMonitoringService'"; $result = $DB->query($query); $a_items = array(); $end = time(); $start = time(); $pmComponent = new PluginMonitoringComponent(); while ($data = $DB->fetch_array($result)) { $itemtype = $data['itemtype']; $item = new $itemtype(); $item->getFromDB($data['items_id']); if (isset($item->fields['plugin_monitoring_components_id'])) { $oldvalue = current(getAllDatasFromTable('glpi_plugin_monitoring_serviceevents', "`plugin_monitoring_services_id`='" . $data['items_id'] . "'", false, 'date ASC LIMIT 1')); $date = new DateTime($oldvalue['date']); if ($date->getTimestamp() < $start) { $start = $date->getTimestamp(); } $pmComponent->getFromDB($item->fields['plugin_monitoring_components_id']); $a_items["item" . $data['id']] = array('rrdtool_template' => $pmComponent->fields['graph_template'], 'itemtype' => $data['itemtype'], 'items_id' => $data['items_id'], 'timezone' => 0, 'time' => $data['extra_infos'], 'pmComponents_id' => $pmComponent->fields['id']); } } $nbdays = round((date('U') - $start) / 86400); echo "<script type=\"text/javascript\">\n \$(function() {\n \$( \"#custom_date\" ).datepicker({ minDate: -" . $nbdays . ", maxDate: \"+0D\", dateFormat:'mm/dd/yy' });\n \$( \"#custom_time\" ).timepicker();\n\n });\n </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 "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1' id='time_text' style='display: none;'>"; echo "<th>"; echo __('Select time', 'monitoring'); echo "</th>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<th>"; echo __('View', 'monitoring'); echo "</th>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>"; echo "<input type='hidden' name='updateviewid' id='updateviewid' value='" . $id . "' />"; if ($config == 0) { echo "<div id='filariane'> </div>"; echo "<input type='hidden' name='updatefil' id='updatefil' value='" . $id . "!' />"; echo "<script type=\"text/javascript\">\n function reloadfil() {\n \$.get('" . $CFG_GLPI["root_doc"] . "/plugins/monitoring/ajax/updateFilariane.php?updatefil=' + \$('#updatefil').val() + '&id=" . $id . "¤tview=' + \$('#updateviewid').val(), function(data) {\n \$('#filariane').html(data);\n });\n }\n reloadfil();\n </script>"; } echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td height='1200' id='panel'>"; echo "<script type=\"text/javascript\">\n \$.get('" . $CFG_GLPI["root_doc"] . "/plugins/monitoring/ajax/showPanel.php?id=" . $id . "&config=" . $config . "', function(data) {\n \$('#panel').html(data);\n });\n </script>"; echo "</td>"; echo "</tr>"; echo "</table>"; echo "<br/>"; }
function view($id, $config=0) { global $DB, $CFG_GLPI; $pmDisplayview = new PluginMonitoringDisplayview(); $pmDisplayview_rule = new PluginMonitoringDisplayview_rule(); $pmDisplayview->getFromDB($id); echo "<script type='text/javascript'> function fittext(itemid) { document.getElementById(itemid).style.fontSize = '50px'; var fontsize = 50; while(document.getElementById(itemid).offsetWidth > 120) { fontsize--; if (fontsize > 20) { fontsize--; } document.getElementById(itemid).style.fontSize = fontsize + 'px'; } while(document.getElementById(itemid).offsetHeight > 67) { fontsize--; document.getElementById(itemid).style.fontSize = fontsize + 'px'; } if (fontsize > 30) { document.getElementById(itemid).style.fontSize = '30px'; } if (fontsize < 7) { document.getElementById(itemid).style.fontSize = '7px'; } } </script>"; PluginMonitoringToolbox::loadLib(); $style = ''; if ($config == '1') { $this->addItem($id); $pmDisplayview_rule->showReplayRulesForm($id); echo "<div id='updatecoordonates'></div>"; if ($pmDisplayview->fields['width'] > 950) { $style = ";position:relative;left:-".(($pmDisplayview->fields['width'] - 950) / 2)."px"; } } else { if (!is_null($pmDisplayview->fields['counter'])) { $pmDisplay = new PluginMonitoringDisplay(); $pmDisplay->showCounters($pmDisplayview->fields['counter']); } } echo "<table class='tab_cadre_fixe' id='test' style='width:".$pmDisplayview->fields['width']."px".$style."'>"; echo "<tr class='tab_bg_1'>"; echo "<th>"; echo $pmDisplayview->fields['name']; echo "</th>"; echo "</tr>"; echo "<tr class='tab_bg_1' id='date_text'>"; echo "<th>"; echo __('Select date', 'monitoring')." - ".__('Select time', 'monitoring'); echo "</th>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>"; $query = "SELECT * FROM `glpi_plugin_monitoring_displayviews_items` WHERE `plugin_monitoring_displayviews_id`='".$id."' AND `itemtype`='PluginMonitoringService'"; $result = $DB->query($query); $a_items = array(); $end = time(); $start = time(); $pmComponent = new PluginMonitoringComponent(); while ($data=$DB->fetch_array($result)) { $itemtype = $data['itemtype']; $item = new $itemtype(); $item->getFromDB($data['items_id']); if (isset($item->fields['plugin_monitoring_components_id'])) { $oldvalue = current(getAllDatasFromTable( 'glpi_plugin_monitoring_serviceevents', "`plugin_monitoring_services_id`='".$data['items_id']."'", false, 'date ASC LIMIT 1')); $date = new DateTime($oldvalue['date']); if ($date->getTimestamp() < $start) { $start = $date->getTimestamp(); } $pmComponent->getFromDB($item->fields['plugin_monitoring_components_id']); $a_items["item".$data['id']] = array( 'rrdtool_template' => $pmComponent->fields['graph_template'], 'itemtype' => $data['itemtype'], 'items_id' => $data['items_id'], 'timezone' => 0, 'time' => $data['extra_infos'], 'pmComponents_id' => $pmComponent->fields['id'] ); } } $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 "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1' id='time_text' style='display: none;'>"; echo "<th>"; echo __('Select time', 'monitoring'); echo "</th>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<th>"; echo __('View', 'monitoring'); echo "</th>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>"; echo "<input type='hidden' name='updateviewid' id='updateviewid' value='".$id."' />"; if ($config == 0) { echo "<div id='filariane'> </div>"; echo "<input type='hidden' name='updatefil' id='updatefil' value='".$id."!' />"; /* echo "<script type=\"text/javascript\"> function reloadfil() { Ext.get('filariane').load({ url: '".$CFG_GLPI["root_doc"]."/plugins/monitoring/ajax/updateFilariane.php', scripts: true, params:'updatefil=' + Ext.get('updatefil').getValue() + '&id=".$id. "¤tview=' + Ext.get('updateviewid').getValue() }); } reloadfil(); </script>"; */ } echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td height='1200' id='panel'>"; $queryitems = "SELECT * FROM `glpi_plugin_monitoring_displayviews_items` WHERE `plugin_monitoring_displayviews_id`='".$id."'"; $resultitems = $DB->query($queryitems); $a_items = array(); while ($dataitems=$DB->fetch_array($resultitems)) { // if ($this->displayItem($dataitems, $config)) { $a_items[] = $dataitems; // } // } } echo " <script type=\"text/javascript\"> $(function() { "; foreach ($a_items as $item) { if ($config == '1') { $event = ", stop: function() { pos = $('#draggable".$item['id']."').position(); $.get('".$CFG_GLPI["root_doc"]."/plugins/monitoring/ajax/displayview_itemcoordinates.php" ."?id=".$item['id'] ."&x=' + pos.left + '&y=' + pos.top); }"; } else { $event = ''; } $size = $this->getSizeOfWidget($item['itemtype']); echo "$( \"#draggable".$item['id']."\" ).draggable({ cursor: 'move', cursorAt: { " . "top: ".($size['height']/2).", left: ".($size['width']/2).", " . " }, grid: [ 10, 10 ]".$event." } );"; } echo " }); </script>"; echo "<div id='viewform' style='width: ".$pmDisplayview->fields['width']."px;height:1200px;position: relative;'>"; foreach ($a_items as $item) { $size = $this->getSizeOfWidget($item['itemtype']); echo '<div id="draggable'.$item['id'].'" '; if ($item['itemtype'] != 'PluginMonitoringServicescatalog' && $item['itemtype'] != 'PluginMonitoringComponentscatalog') { echo 'class="ui-widget-content" '; } echo 'style="width: '.$size['width'].'px; height: '.$size['height'].'px; ' . 'position: absolute; left: '.$item['x'].'px; top: '.$item['y'].'px;">'; if ($item['itemtype'] == 'PluginMonitoringService') { $pmComponent = new PluginMonitoringComponent(); $pmService = new PluginMonitoringService(); $pmService->getFromDB($item['items_id']); $pmComponent->getFromDB($pmService->fields['plugin_monitoring_components_id']); $pmServicegraph = new PluginMonitoringServicegraph(); $pmServicegraph->displayGraph($pmComponent->fields['graph_template'], "PluginMonitoringService", $item['items_id'], "0", $item['extra_infos'], "", ($size['width'] - 15)); } else if ($item['itemtype'] == 'PluginMonitoringWeathermap') { } else { echo "<div id=\"update".$item['itemtype'].$item['items_id']."\"></div>"; echo "<script type=\"text/javascript\">"; echo " (function worker() { $.get('".$CFG_GLPI["root_doc"]."/plugins/monitoring/ajax/updateWidgetComponentscatalog.php" ."?id=".$item['items_id']."&is_minemap=".$item['is_minemap']. "', function(data) { $('#update".$item['itemtype'].$item['items_id']."').html(data); setTimeout(worker, 30000); }); })();"; echo "</script>"; } echo '</div>'; } // echo "<script type='text/javascript'> // // //Simple 'border layout' panel to house both grids // var displayPanel = new Ext.Panel({ // id : 'viewpanel', // width : ".$pmDisplayview->fields['width'].", // height : 1200, // layout: 'absolute', // renderTo : 'panel', // items : [] // }); // // </script>"; echo "</div>"; // echo "<script type=\"text/javascript\"> // function reloadview() { // Ext.get('viewform').load({ // url: '".$CFG_GLPI["root_doc"]."/plugins/monitoring/ajax/loadView.php', // scripts: true, // params:'id=' + Ext.get('updateviewid').getValue() + '&config=".$config."' // }); // } // reloadview(); // </script>"; echo "</td>"; echo "</tr>"; echo "</table>"; echo "<br/>"; }