/** * Display info of device * * @global type $DB Toolbox::logDebug($this->fields); * @param type $id */ function showWidget2Frame($id, $is_minemap = FALSE) { global $DB, $CFG_GLPI; $pmDisplayview_item = new PluginMonitoringDisplayview_item(); $pmDisplayview_item->getFromDB($id); $itemtype = $pmDisplayview_item->fields['extra_infos']; $item = new $itemtype(); $item->getFromDB($pmDisplayview_item->fields['items_id']); $critical = 0; $warning = 0; $ok = 0; $acknowledge = 0; $query = "SELECT * FROM `glpi_plugin_monitoring_services`" . " LEFT JOIN `glpi_plugin_monitoring_componentscatalogs_hosts`" . " ON `plugin_monitoring_componentscatalogs_hosts_id`=" . " `glpi_plugin_monitoring_componentscatalogs_hosts`.`id`" . " WHERE `items_id`='" . $item->fields['id'] . "'" . " AND `itemtype`='" . $itemtype . "'" . " AND `glpi_plugin_monitoring_services`.`id` IS NOT NULL" . " ORDER BY `glpi_plugin_monitoring_services`.`name`"; $result = $DB->query($query); $services = array(); $resources = array(); $i = 0; while ($data = $DB->fetch_array($result)) { $ret = PluginMonitoringHost::getState($data['state'], $data['state_type'], '', $data['is_acknowledged']); if (strstr($ret, '_soft')) { $ok++; $resources[$data['id']]['state'] = 'OK'; } else { if ($ret == 'red') { $critical++; $resources[$data['id']]['state'] = 'CRITICAL'; } else { if ($ret == 'redblue') { $acknowledge++; $resources[$data['id']]['state'] = 'ACKNOWLEDGE'; } else { if ($ret == 'orange' || $ret == 'yellow') { $warning++; $resources[$data['id']]['state'] = 'WARNING'; } else { $ok++; $resources[$data['id']]['state'] = 'OK'; } } } } $services[$i++] = $data['id']; $resources[$data['id']]['last_check'] = $data['last_check']; $resources[$data['id']]['event'] = $data['event']; $resources[$data['id']]['name'] = $data['name']; $resources[$data['id']]['plugin_monitoring_components_id'] = $data['plugin_monitoring_components_id']; } $class = 'ok'; if ($critical > 0) { $nb_ressources = $critical; $class = 'crit'; } else { if ($warning > 0) { $nb_ressources = $warning; $class = 'warn'; } else { $nb_ressources = $ok; } } echo '<div class="ch-item"> <div class="ch-info-' . $class . '"> <h1><a href="'; if ($item->can($item->getID(), READ)) { echo $item->getFormURL() . '?id=' . $item->getID() . '&forcetab=PluginMonitoringHost$0'; } else { echo $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/displayhost.php?itemtype=" . $itemtype . "&items_id=" . $item->getID(); } echo '">' . '<span id="devicea-' . $id . '">' . $item->getName() . '</span></a></h1> <p><a>' . $nb_ressources . '</a><font style="font-size: 14px;"> / ' . ($ok + $warning + $critical + $acknowledge) . '</font></p> </div> </div>'; echo "<script>\n fittext('devicea-" . $id . "');\n </script>"; echo "<div class='minemapdiv' align='center'>" . "<a onclick='\$(\"#minemapdisplayview2-" . $id . "\").toggle()'>" . "Minemap</a></div>"; if (!$is_minemap) { echo '<div class="minemapdiv" id="minemapdisplayview2-' . $id . '" style="display: none; z-index: 1500">'; } else { echo '<div class="minemapdiv" id="minemapdisplayview2-' . $id . '">'; } echo '<table class="tab_cadrehov" >'; // Get services list ... echo '<div class="minemapdiv">'; echo '<table class="tab_cadrehov">'; // Header with services name and link to services list ... echo '<tr class="tab_bg_2">'; echo '<th colspan="2">'; echo __('Services', 'monitoring'); echo '</th>'; echo '</tr>'; // Content with host/service status and link to services list ... foreach ($services as $services_id) { $field_id = 20; if ($itemtype == 'Printer') { $field_id = 21; } else { if ($itemtype == 'NetworkEquipment') { $field_id = 22; } } $link = $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/service.php?hidesearch=1" . "&criteria[0][field]=" . $field_id . "" . "&criteria[0][searchtype]=equals" . "&criteria[0][value]=" . $item->getID() . "&criteria[1][link]=AND" . "&criteria[1][field]=2" . "&criteria[1][searchtype]=equals" . "&criteria[1][value]=" . $resources[$services_id]['plugin_monitoring_components_id'] . "&itemtype=PluginMonitoringService" . "&start=0'"; echo "<tr class='tab_bg_2'>"; echo "<td class='left'><a href='" . $link . "'>" . $resources[$services_id]['name'] . "</a></td>"; echo '<td>'; echo '<a href="' . $link . '" title="' . $resources[$services_id]['state'] . " - " . $resources[$services_id]['last_check'] . " - " . $resources[$services_id]['event'] . '">' . '<div class="service service' . $resources[$services_id]['state'] . '"></div></a>'; echo '</td>'; echo '</tr>'; } echo '</table>'; echo '</div>'; }
@package Plugin Monitoring for GLPI @author David Durieux @co-author @comment @copyright Copyright (c) 2011-2013 Plugin Monitoring for GLPI team @license AGPL License 3.0 or (at your option) any later version http://www.gnu.org/licenses/agpl-3.0-standalone.html @link https://forge.indepnet.net/projects/monitoring/ @since 2011 ------------------------------------------------------------------------ */ include "../../../inc/includes.php"; header("Content-Type: text/html; charset=UTF-8"); Html::header_nocache(); Session::checkCentralAccess(); //print_r($_POST); if (isset($_POST['id']) and isset($_POST['x']) and isset($_POST['y'])) { $pmDisplayview_item = new PluginMonitoringDisplayview_item(); if ($pmDisplayview_item->getFromDB($_POST['id'])) { if ($_POST['x'] < 1 or $_POST['y'] < 0) { $pmDisplayview_item->delete(array('id' => $_POST['id'])); } else { $input = array(); $input['id'] = $_POST['id']; $input['x'] = $_POST['x']; $input['y'] = $_POST['y']; $pmDisplayview_item->update($input); } } }
/** * Display info of device * * @global type $DB * @param type $id */ function showWidget2Frame($id) { global $DB, $CFG_GLPI; $pmDisplayview_item = new PluginMonitoringDisplayview_item(); $pmDisplayview_item->getFromDB($id); $itemtype = $pmDisplayview_item->fields['extra_infos']; $item = new $itemtype(); $item->getFromDB($pmDisplayview_item->fields['items_id']); $critical = 0; $warning = 0; $ok = 0; $acknowledge = 0; $query = "SELECT * FROM `glpi_plugin_monitoring_services`" . " LEFT JOIN `glpi_plugin_monitoring_componentscatalogs_hosts`" . " ON `plugin_monitoring_componentscatalogs_hosts_id`=" . " `glpi_plugin_monitoring_componentscatalogs_hosts`.`id`" . " WHERE `items_id`='" . $item->fields['id'] . "'" . " AND `itemtype`='" . $itemtype . "'" . " AND `glpi_plugin_monitoring_services`.`id` IS NOT NULL"; $result = $DB->query($query); while ($data = $DB->fetch_array($result)) { $ret = PluginMonitoringDisplay::getState($data['state'], $data['state_type'], '', $data['is_acknowledged']); if (strstr($ret, '_soft')) { $ok++; } else { if ($ret == 'red') { $critical++; } else { if ($ret == 'redblue') { $acknowledge++; } else { if ($ret == 'orange' || $ret == 'yellow') { $warning++; } else { $ok++; } } } } } $class = 'ok'; if ($critical > 0) { $nb_ressources = $critical; $class = 'crit'; } else { if ($warning > 0) { $nb_ressources = $warning; $class = 'warn'; } else { $nb_ressources = $ok; } } echo '<div class="ch-item"> <div class="ch-info-' . $class . '"> <h1><a href="'; if ($item->can($item->getID(), 'r')) { echo $item->getFormURL() . '?id=' . $item->getID() . '&forcetab=PluginMonitoringHost$0'; } else { echo $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/displayhost.php?itemtype=" . $itemtype . "&items_id=" . $item->getID(); } echo '">' . '<span id="devicea-' . $id . '">' . $item->getName() . '</span></a></h1> <p>' . $nb_ressources . '<font style="font-size: 14px;"> / ' . ($ok + $warning + $critical + $acknowledge) . '</font></p> </div> </div>'; echo "<script>\n fittext('devicea-" . $id . "');\n </script>"; }