function showSimpleReport($componentscatalogs_id) { global $CFG_GLPI; $pmComponentscatalog_Component = new PluginMonitoringComponentscatalog_Component(); $pmComponent = new PluginMonitoringComponent(); $a_options = array(); $this->getFromDB($componentscatalogs_id); echo "<form name='form' method='post' action='".$CFG_GLPI['root_doc']."/plugins/monitoring/front/report_componentscatalog.form.php'>"; echo "<table class='tab_cadre_fixe'>"; echo '<tr class="tab_bg_1">'; echo '<th colspan="5">'; echo __('Report'); echo "<input type='hidden' name='componentscatalogs_id' value='".$componentscatalogs_id."' />"; $a_options['componentscatalogs_id'] = $componentscatalogs_id; echo '</th>'; echo '</tr>'; // ** simple report echo '<tr class="tab_bg_1">'; echo '<tr class="tab_bg_1">'; echo '<td>'; echo '<input type="radio" name="reporttype" value="simplereport" checked />'; echo '</td>'; echo '<td colspan="4">'; echo '<strong>'.__('Simple report', "monitoring").'</strong>'; echo '</td>'; echo '</tr>'; echo '<tr class="tab_bg_1">'; echo '<td>'; echo '</td>'; echo "<td>".__('Start date')." :</td>"; echo "<td>"; Html::showDateFormItem("date_start", date('Y-m-d H:i:s', date('U') - (24 * 3600 * 7))); $a_options['date_start'] = date('Y-m-d H:i:s', date('U') - (24 * 3600 * 7)); // Fred ? $a_options['date_start'] = '2013-01-01 01:01:01'; echo "</td>"; echo "<td>".__('End date')." :</td>"; echo "<td>"; Html::showDateFormItem("date_end", date('Y-m-d')); $a_options['date_end'] = date('Y-m-d'); echo "</td>"; echo "</tr>"; echo "</table>"; echo "<table class='tab_cadre_fixe'>"; $a_composants = $pmComponentscatalog_Component->find("`plugin_monitoring_componentscalalog_id`='".$componentscatalogs_id."'"); foreach ($a_composants as $comp_data) { $pmComponent->getFromDB($comp_data['plugin_monitoring_components_id']); echo "<tr class='tab_bg_1'>"; echo "<td width='10'>"; echo "<input type='checkbox' name='components_id[]' value='".$pmComponent->getID()."' checked />"; $a_options['components_id'][] = $pmComponent->getID(); echo "</td>"; echo "<td>"; echo $pmComponent->getLink(); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td width='10'>"; echo "</td>"; echo "<td>"; PluginMonitoringToolbox::preferences($pmComponent->getID(), 1, 1); echo "</td>"; echo "</tr>"; } echo "<tr class='tab_bg_1'>"; echo "<td colspan='2' align='center'>"; echo "<input type='submit' class='submit' name='generate' value='".__('Generate the report', 'monitoring')."'/>"; echo "</td>"; echo "</tr>"; echo "</table>"; Html::closeForm(); $this->generateReport($a_options, FALSE); }
function displayGraphs($itemtype, $items_id) { global $CFG_GLPI; $pmComponent = new PluginMonitoringComponent(); $pmConfig = new PluginMonitoringConfig(); $pmComponentscatalog_Host = new PluginMonitoringComponentscatalog_Host(); $networkPort = new NetworkPort(); $item = new $itemtype(); $item->getFromDB($items_id); $pmComponent->getFromDB($item->fields['plugin_monitoring_components_id']); if (!isset($_SESSION['glpi_plugin_monitoring']['perfname'][$pmComponent->fields['id']])) { PluginMonitoringToolbox::loadPreferences($pmComponent->fields['id']); } $css_width = '950'; if (isset($_GET['mobile'])) { $css_width = '300'; } echo "<table class='tab_cadre' width='" . $css_width . "'>"; echo "<tr class='tab_bg_1'>"; echo "<th>"; $title = Dropdown::getDropdownName(getTableForItemType('PluginMonitoringComponent'), $item->fields['plugin_monitoring_components_id']); if (!is_null($item->fields['networkports_id']) && $item->fields['networkports_id'] > 0) { $networkPort->getFromDB($item->fields['networkports_id']); $title .= " [" . $networkPort->getLink() . "]"; } $title .= ' ' . __('on', 'monitoring') . ' '; $pmComponentscatalog_Host->getFromDB($item->fields["plugin_monitoring_componentscatalogs_hosts_id"]); if (isset($pmComponentscatalog_Host->fields['itemtype']) and $pmComponentscatalog_Host->fields['itemtype'] != '') { $itemtype2 = $pmComponentscatalog_Host->fields['itemtype']; $item2 = new $itemtype2(); $item2->getFromDB($pmComponentscatalog_Host->fields['items_id']); $title .= str_replace("'", "\"", $item2->getLink() . " (" . $item2->getTypeName() . ")"); } echo $title; echo "</th>"; echo "<th width='200'>"; if (!isset($_GET['mobile'])) { echo "<form method='post'>"; $a_timezones = PluginMonitoringConfig::getTimezones(); if (!isset($_SESSION['plugin_monitoring_timezone'])) { $_SESSION['plugin_monitoring_timezone'] = '0'; } $a_timezones_allowed = array(); $pmConfig->getFromDB(1); $a_temp = importArrayFromDB($pmConfig->fields['timezones']); foreach ($a_temp as $key) { $a_timezones_allowed[$key] = $a_timezones[$key]; } if (count($a_timezones_allowed) == '0') { $a_timezones_allowed['0'] = $a_timezones['0']; } Dropdown::showFromArray('plugin_monitoring_timezone', $a_timezones_allowed, array('value' => $_SESSION['plugin_monitoring_timezone'])); echo " <input type='submit' name='update' value=\"" . __('Save') . "\" class='submit'>"; Html::closeForm(); } echo "</th>"; echo "</tr>"; $timezone = '0'; if (isset($_SESSION['plugin_monitoring_timezone'])) { $timezone = $_SESSION['plugin_monitoring_timezone']; } if (!isset($_GET['mobile'])) { echo "<tr class='tab_bg_1'>"; echo "<th colspan='2'>"; echo "<div id='legendlink'><a onClick='\$(\"#options\").toggle();'>[ Options ]</a></div>"; echo "</th>"; echo "</tr>"; // * Display perfname echo "<tr class='tab_bg_1'>"; echo "<td colspan='2'>"; echo "<div id='options' style='display:none'>"; PluginMonitoringToolbox::preferences($pmComponent->fields['id'], 0); echo "</div>"; echo "</td>"; echo "</tr>"; // * Display date slider echo "<tr class='tab_bg_1'>"; echo "<th colspan='2'>"; echo __('Select date', 'monitoring') . " - " . __('Select time', 'monitoring'); echo "</th>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<th colspan='2'>"; $start = time(); $oldvalue = current(getAllDatasFromTable('glpi_plugin_monitoring_serviceevents', "`plugin_monitoring_services_id`='" . $items_id . "'", false, 'date ASC LIMIT 1')); $date = new DateTime($oldvalue['date']); if ($date->getTimestamp() < $start) { $start = $date->getTimestamp(); } $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 "</th>"; echo "</tr>"; } $a_list = array(); $a_list["2h"] = __("Last 2 hours", "monitoring"); $a_list["12h"] = __("Last 12 hours", "monitoring"); $a_list["1d"] = __("Last 24 hours", "monitoring"); $a_list["1w"] = __("Last 7 days (average)", "monitoring"); // $a_list["1m"] = __("Last month (average)", "monitoring"); // $a_list["0y6m"] = __("Last 6 months (average)", "monitoring"); // $a_list["1y"] = __("Last year (average)", "monitoring"); foreach ($a_list as $time => $name) { echo "<tr class='tab_bg_1'>"; echo "<th colspan='2'>"; echo $name; echo "</th>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td align='center' colspan='2' style='position: relative'>"; $pmServicegraph = new PluginMonitoringServicegraph(); $part = ''; $width = '950'; if (isset($_GET['mobile'])) { $width = '294'; } $pmServicegraph->displayGraph($pmComponent->fields['graph_template'], $itemtype, $items_id, $timezone, $time, $part, $width); echo "</td>"; echo "</tr>"; } echo "</table>"; }
function preferences($components_id) { // echo '<script type="text/javascript"> // jQuery(function() { // jQuery("#jquery-tagbox-select").tagBox({ // enableDropdown: true, // separator: "####", // tagButtonTitle: "'.__('Add to graph', 'monitoring').'", // dropdownSource: function() { // return jQuery("#jquery-tagbox-select-options"); // } // }); // }); // jQuery(function() { // jQuery("#jquery-tagbox-select2").tagBox({ // enableDropdown: true, // separator: "####", // tagButtonTitle: "'.__('Invert', 'monitoring').'", // dropdownSource: function() { // return jQuery("#jquery-tagbox-select2-options"); // } // }); // }); // </script>'; echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_1'>"; echo "<th>"; echo __('Settings'); echo "</th>"; echo "</tr>"; echo "<tr class='tab_bg_3'>"; echo "<td>"; PluginMonitoringToolbox::preferences($components_id); echo "</td>"; echo "</tr>"; echo "</table>"; }