/* // Display ressources perfdata ? if (isset($_SESSION['plugin_monitoring']['ressources_perfdata'])) { Html::redirect($CFG_GLPI['root_doc']."/plugins/monitoring/front/perfdatas.php"); unset($_SESSION['plugin_monitoring']['ressources_perfdata']); } */ // Reduced or normal interface ? if (! isset($_SESSION['plugin_monitoring_reduced_interface'])) { $_SESSION['plugin_monitoring_reduced_interface'] = false; } if (isset($_POST['reduced_interface'])) { $_SESSION['plugin_monitoring_reduced_interface'] = $_POST['reduced_interface']; } $pmDisplay = new PluginMonitoringDisplay(); $pmMessage = new PluginMonitoringMessage(); $pmMessage->getMessages(); $pmDisplay->menu(); $pmDisplay->refreshPage(); $pmDisplay->showCounters("Ressources", 1, 0); // Manage search if (isset($_SESSION['plugin_monitoring']['service'])) { $_GET = $_SESSION['plugin_monitoring']['service']; } if (isset($_GET['reset'])) { unset($_SESSION['glpisearch']['PluginMonitoringService']);
@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"; Session::checkCentralAccess(); Html::header(__('Monitoring', 'monitoring'), $_SERVER["PHP_SELF"], "plugins", "monitoring", "display"); $pmDisplay = new PluginMonitoringDisplay(); $pmMessage = new PluginMonitoringMessage(); $pmMessage->getMessages(); $pmDisplay->menu(); $pmDisplay->refreshPage(); $pmDisplay->showCounters("Ressources", 1, 0); // Manage search if (isset($_SESSION['plugin_monitoring']['service'])) { $_GET = $_SESSION['plugin_monitoring']['service']; } if (isset($_GET['reset'])) { unset($_SESSION['glpisearch']['PluginMonitoringService']); } if (isset($_GET['glpi_tab'])) { unset($_GET['glpi_tab']); }
Plugin Monitoring for GLPI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Monitoring. If not, see <http://www.gnu.org/licenses/>. ------------------------------------------------------------------------ @package Plugin Monitoring for GLPI @author Frédéric Mohier @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"; Session::checkRight("plugin_monitoring_service", READ); Html::header(__('Monitoring - resources events', 'monitoring'), '', "plugins", "monitoring", "event"); $pmMessage = new PluginMonitoringMessage(); $pmMessage->getMessages(); $pmDisplay = new PluginMonitoringDisplay(); $pmDisplay->menu(); Search::show('PluginMonitoringServiceevent'); Html::footer();
/** * 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 getCounterOfView($id, $a_counter) { global $DB; $a_hosts = $this->find("`itemtype`='host'" . " AND `plugin_monitoring_displayviews_id`='" . $id . "'"); foreach ($a_hosts as $data) { $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`='" . $data['items_id'] . "'" . " AND `itemtype`='" . $data['extra_infos'] . "'" . " AND `glpi_plugin_monitoring_services`.`id` IS NOT NULL"; $result = $DB->query($query); while ($data2 = $DB->fetch_array($result)) { $ret = PluginMonitoringDisplay::getState($data2['state'], $data2['state_type'], '', $data2['is_acknowledged']); if (strstr($ret, '_soft')) { $a_counter['ok']++; } else { if ($ret == 'red') { $a_counter['critical']++; } else { if ($ret == 'redblue') { $a_counter['acknowledge']++; } else { if ($ret == 'orange' || $ret == 'yellow') { $a_counter['warning']++; } else { $a_counter['ok']++; } } } } } } return $a_counter; }
@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::checkCentralAccess(); Html::header(__('Monitoring - dashboard (components catalogs)', 'monitoring'), $_SERVER["PHP_SELF"], "plugins", "PluginMonitoringDashboard", "dashboard"); // Display ressources perfdata ? if (isset($_SESSION['plugin_monitoring']['ressources_perfdata'])) { unset($_SESSION['plugin_monitoring']['ressources_perfdata']); } // Reduced or normal interface ? if (!isset($_SESSION['plugin_monitoring_reduced_interface'])) { $_SESSION['plugin_monitoring_reduced_interface'] = false; } if (isset($_POST['reduced_interface'])) { $_SESSION['plugin_monitoring_reduced_interface'] = $_POST['reduced_interface']; } $pmDisplay = new PluginMonitoringDisplay(); $pmMessage = new PluginMonitoringMessage(); $pmMessage->getMessages(); $pmDisplay->menu(); $pmDisplay->refreshPage(TRUE); $pmDisplay->showCounters("Componentscatalog"); $pmComponentscatalog = new PluginMonitoringComponentscatalog(); $pmComponentscatalog->showChecks($_SESSION['plugin_monitoring_reduced_interface']); Html::footer();
function showBADetail($id) { global $CFG_GLPI; $pMonitoringBusinessrule = new PluginMonitoringBusinessrule(); $pMonitoringBusinessrulegroup = new PluginMonitoringBusinessrulegroup(); $pMonitoringService = new PluginMonitoringService(); $this->getFromDB($id); echo "<table class='tab_cadrehov'>"; $a_groups = $pMonitoringBusinessrulegroup->find("`plugin_monitoring_servicescatalogs_id`='" . $id . "'"); echo "<tr class='tab_bg_1'>"; $color = PluginMonitoringDisplay::getState($this->fields['state'], $this->fields['state_type']); $pic = $color; $color = str_replace("_soft", "", $color); echo "<td rowspan='" . count($a_groups) . "' class='center' width='200' bgcolor='" . $color . "'>"; echo "<strong style='font-size: 20px'>" . $this->getName() . "</strong><br/>"; echo "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/pics/box_" . $pic . "_40.png'/>"; echo "</td>"; $i = 0; foreach ($a_groups as $gdata) { $a_brulesg = $pMonitoringBusinessrule->find("`plugin_monitoring_businessrulegroups_id`='" . $gdata['id'] . "'"); if ($i > 0) { echo "<tr>"; } $state = array(); $state['red'] = 0; $state['red_soft'] = 0; $state['orange'] = 0; $state['orange_soft'] = 0; $state['green'] = 0; $state['green_soft'] = 0; foreach ($a_brulesg as $brulesdata) { $pMonitoringService->getFromDB($brulesdata['plugin_monitoring_services_id']); $state[PluginMonitoringDisplay::getState($pMonitoringService->fields['state'], $pMonitoringService->fields['state_type'])]++; } $color = ""; if ($gdata['operator'] == 'or') { if ($state['green'] >= 1) { $color = "green"; } else { if ($state['orange'] >= 1) { $color = "orange"; } else { if ($state['orange_soft'] >= 1) { $color = "orange"; } else { if ($state['red'] >= 1) { $color = "red"; } else { if ($state['red_soft'] >= 1) { $color = "red"; } } } } } } else { $num_min = str_replace(" of:", "", $gdata['operator']); if ($state['green'] >= $num_min) { $color = "green"; } else { if ($state['orange'] >= $num_min) { $color = "orange"; } else { if ($state['orange_soft'] >= $num_min) { $color = "orange"; } else { if ($state['red'] >= $num_min) { $color = "red"; } else { if ($state['red_soft'] >= $num_min) { $color = "red"; } } } } } } echo "<td class='center' bgcolor='" . $color . "'>"; echo $gdata['name'] . "<br/>[ " . $gdata['operator'] . " ]"; echo "</td>"; echo "<td bgcolor='" . $color . "'>"; echo "<table>"; foreach ($a_brulesg as $brulesdata) { echo "<tr class='tab_bg_1'>"; $pMonitoringService->getFromDB($brulesdata['plugin_monitoring_services_id']); PluginMonitoringDisplay::displayLine($pMonitoringService->fields); echo "</tr>"; } echo "</table>"; echo "</th>"; echo "</tr>"; $i++; } echo "</tr>"; echo "</table>"; }
the Free Software Foundation; either version 2 of the License, or (at your option) any later version. GLPI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GLPI; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -------------------------------------------------------------------------- */ // ---------------------------------------------------------------------- // Original Author of file: David DURIEUX // Purpose of file: // ---------------------------------------------------------------------- // Direct access to file if (strpos($_SERVER['PHP_SELF'], "updateCounter.php")) { include "../../../inc/includes.php"; header("Content-Type: text/html; charset=UTF-8"); Html::header_nocache(); } session_write_close(); if (!defined('GLPI_ROOT')) { die("Can not acces directly to this file"); } Session::checkLoginUser(); $pmDisplay = new PluginMonitoringDisplay(); $pmDisplay->displayCounters($_GET['type']); Html::ajaxFooter();
function view($id, $config = 0) { global $DB, $CFG_GLPI; $pmDisplayview = new PluginMonitoringDisplayview(); $pmDisplayview->getFromDB($id); if ($config == '1') { $this->addItem($id); echo "<div id='updatecoordonates'></div>"; } else { if (!is_null($pmDisplayview->fields['counter'])) { $pmDisplay = new PluginMonitoringDisplay(); $pmDisplay->displayCounters($pmDisplayview->fields['counter']); } } echo "<table class='tab_cadre_fixe' id='test'>"; echo "<tr class='tab_bg_1'>"; echo "<th>"; echo $pmDisplayview->fields['name']; echo "</th>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td height='1000' id='panel'>"; $query = "SELECT * FROM `glpi_plugin_monitoring_displayviews_items`\n WHERE `plugin_monitoring_displayviews_id`='" . $id . "'"; $result = $DB->query($query); $a_items = array(); while ($data = $DB->fetch_array($result)) { $this->displayItem($data, $config); $a_items[] = "item" . $data['id']; } echo "<script type='text/javascript'>\nExt.onReady(function() {\n\n //Simple 'border layout' panel to house both grids\n var displayPanel = new Ext.Panel({\n width : 950,\n height : 1000,\n layout: 'absolute',\n renderTo : 'panel',\n items : [\n " . implode(",", $a_items) . "\n ]\n });\n\n});\n</script>"; echo "</td>"; echo "</tr>"; echo "</table>"; echo "<br/>"; }
@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"; header("Content-Type: text/html; charset=UTF-8"); header_nocache(); if (!isset($_POST["id"])) { exit; } $pmDisplay = new PluginMonitoringDisplay(); $pmBusinessrule = new PluginMonitoringBusinessrule(); $pmDisplayview = new PluginMonitoringDisplayview(); $a_views = $pmDisplayview->getViews(); switch ($_REQUEST['glpi_tab']) { case -1: break; case 1: $pmServicescatalog = new PluginMonitoringServicescatalog(); $pmDisplay->displayCounters("Businessrules"); $pmServicescatalog->showBAChecks(); break; case 2: $pmComponentscatalog = new PluginMonitoringComponentscatalog(); $pmDisplay->displayCounters("Componentscatalog"); $pmComponentscatalog->showChecks();
function getRessources($componentscatalogs_id, $state, $state_type = 'HARD') { global $DB; $a_services = array(); $pmComponentscatalog_Host = new PluginMonitoringComponentscatalog_Host(); $query = "SELECT * FROM `glpi_plugin_monitoring_services` \n LEFT JOIN `" . $pmComponentscatalog_Host->getTable() . "`\n ON `plugin_monitoring_componentscatalogs_hosts_id`=\n `" . $pmComponentscatalog_Host->getTable() . "`.`id`\n WHERE `plugin_monitoring_componentscalalog_id`='" . $componentscatalogs_id . "'\n AND `state_type` LIKE '" . $state_type . "'\n ORDER BY `name`"; $result = $DB->query($query); while ($data = $DB->fetch_array($result)) { if (PluginMonitoringDisplay::getState($data['state'], $data['state_type'], '', $data['is_acknowledged']) == $state) { $a_services[] = $data; } } return $a_services; }
GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Monitoring. If not, see <http://www.gnu.org/licenses/>. ------------------------------------------------------------------------ @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"; Session::checkCentralAccess(); Html::header(__('Monitoring', 'monitoring'), $_SERVER["PHP_SELF"], "plugins", "monitoring", "display"); $pmDisplay = new PluginMonitoringDisplay(); $pmComponentscatalog = new PluginMonitoringComponentscatalog(); $pmMessage = new PluginMonitoringMessage(); $pmMessage->getMessages(); $pmDisplay->menu(); PluginMonitoringProfile::checkRight("componentscatalog", 'r'); $pmDisplay->showCounters("Componentscatalog"); $pmComponentscatalog->showChecks(); Html::footer();
$params = Search::manageParams("PluginMonitoringHost", $_GET); // Display ressources perfdata ? if (isset($_SESSION['plugin_monitoring']['ressources_perfdata'])) { unset($_SESSION['plugin_monitoring']['ressources_perfdata']); } // Reduced or normal interface ? if (! isset($_SESSION['plugin_monitoring_reduced_interface'])) { $_SESSION['plugin_monitoring_reduced_interface'] = false; } if (isset($_POST['reduced_interface'])) { $_SESSION['plugin_monitoring_reduced_interface'] = $_POST['reduced_interface']; } $pmDisplay = new PluginMonitoringDisplay(); $pmMessage = new PluginMonitoringMessage(); $pmMessage->getMessages(); $pmDisplay->menu(); $pmDisplay->refreshPage(); $pmDisplay->showHostsCounters("Hosts", 1, 1); // Manage search if (isset($_SESSION['plugin_monitoring']['host'])) { $_GET = $_SESSION['plugin_monitoring']['host']; } if (isset($_GET['reset'])) {
function showForm($items_id, $servicescatalogs_id, $options = array()) { global $LANG, $CFG_GLPI; if ($items_id != '') { $this->getFromDB($items_id); } else { $this->getEmpty(); } $this->showFormHeader($options); $rand = mt_rand(); echo "<tr class='tab_bg_1'>"; echo "<td>"; echo "<input type='hidden' name='plugin_monitoring_servicescatalogs_id' value='" . $servicescatalogs_id . "'/>"; echo $LANG['common'][16] . " :"; echo "</td>"; echo "<td>"; echo "<input type='text' name='name' value='" . $this->fields["name"] . "' size='30'/>"; echo "</td>"; if ($items_id != '') { echo "<th colspan='2' width='60%'>"; echo $LANG['plugin_monitoring']['service'][0]; echo " "; echo "<img onClick=\"Ext.get('ressources" . $rand . "').setDisplayed('block')\"\n title=\"" . $LANG['buttons'][8] . "\" alt=\"" . $LANG['buttons'][8] . "\"\n class='pointer' src='" . $CFG_GLPI["root_doc"] . "/pics/add_dropdown.png'>"; echo "</th>"; echo "</tr>"; echo "<tr>"; } echo "<td valign='top'>"; echo $LANG['rulesengine'][9] . " :"; echo "</td>"; echo "<td valign='top'>"; $first_operator = array(); $first_operator['or'] = "or"; $first_operator['2 of:'] = $LANG['plugin_monitoring']['businessrule'][2]; $first_operator['3 of:'] = $LANG['plugin_monitoring']['businessrule'][3]; $first_operator['4 of:'] = $LANG['plugin_monitoring']['businessrule'][4]; $first_operator['5 of:'] = $LANG['plugin_monitoring']['businessrule'][5]; $first_operator['6 of:'] = $LANG['plugin_monitoring']['businessrule'][6]; $first_operator['7 of:'] = $LANG['plugin_monitoring']['businessrule'][7]; $first_operator['8 of:'] = $LANG['plugin_monitoring']['businessrule'][8]; $first_operator['9 of:'] = $LANG['plugin_monitoring']['businessrule'][9]; $first_operator['10 of:'] = $LANG['plugin_monitoring']['businessrule'][10]; Dropdown::showFromArray('operator', $first_operator, array("value" => $this->fields['operator'])); echo "</td>"; if ($items_id != '') { echo "<td colspan='2'>"; // ** Dropdown to display echo "<div style='display:none' id='ressources" . $rand . "' >"; echo "<table>"; echo "<tr class='tab_bg_1'>"; echo "<td>"; echo "<form name='form' method='post' action='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/businessrule.form.php'>"; echo "<input type='hidden' name='plugin_monitoring_businessrulegroups_id' value='" . $items_id . "' />"; PluginMonitoringBusinessrule::dropdownService(0, array('name' => 'type')); echo "<input type='submit' name='add' value=\"" . $LANG['buttons'][8] . "\" class='submit'>"; echo "</form>"; echo "</td>"; echo "</tr>"; echo "</table>"; echo "<hr>"; echo "</div>"; echo "<table width='100%'>"; $pmBusinessrule = new PluginMonitoringBusinessrule(); $pmService = new PluginMonitoringService(); $a_services = $pmBusinessrule->find("`plugin_monitoring_businessrulegroups_id`='" . $servicescatalogs_id . "'"); foreach ($a_services as $gdata) { if ($pmService->getFromDB($gdata['plugin_monitoring_services_id'])) { $shortstate = PluginMonitoringDisplay::getState($pmService->fields['state'], $pmService->fields['state_type']); echo "<tr class='tab_bg_1'>"; echo "<td>"; echo "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/pics/box_" . $shortstate . "_32.png'/>"; echo "</td>"; echo "<td>"; $pmComponentscatalog_Host = new PluginMonitoringComponentscatalog_Host(); $pmService->getFromDB($gdata["plugin_monitoring_services_id"]); $pmComponentscatalog_Host->getFromDB($pmService->fields['plugin_monitoring_componentscatalogs_hosts_id']); echo $pmService->getLink(1); echo " " . $LANG['networking'][25] . " "; $itemtype2 = $pmComponentscatalog_Host->fields['itemtype']; $item2 = new $itemtype2(); $item2->getFromDB($pmComponentscatalog_Host->fields['items_id']); echo $item2->getLink(1); echo "</td>"; echo "<td>"; echo "<input type='submit' name='deletebusinessrules-" . $gdata['id'] . "' value=\"" . $LANG['buttons'][6] . "\" class='submit'>"; echo "</td>"; } else { // resource deleted echo "<tr class='tab_bg_1'>"; echo "<td colspan='2' bgcolor='#ff0000'>"; echo $LANG['plugin_monitoring']['service'][23]; echo "</td>"; echo "<td>"; echo "<input type='submit' name='deletebusinessrules-" . $gdata['id'] . "' value=\"" . $LANG['buttons'][53] . "\" class='submit'>"; echo "</td>"; } } echo "</tr>"; } echo "</table>"; echo "</td>"; echo "</tr>"; $this->showFormButtons($options); return true; }
$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();
static function methodDashboard($params, $protocol) { $array = array(); if (!isset($params['view'])) { return array(); } $pm = new PluginMonitoringDisplay(); $array = $pm->displayCounters($params['view'], 0); return $array; }
function checkState($stateevent, $date, $services_id, $event) { $state = PluginMonitoringDisplay::getState($stateevent, "HARD", $event); if ($state == 'red') { // Critial if ($this->currentstate == 'ok') { // Add $input = array(); $input['plugin_monitoring_services_id'] = $this->plugin_monitoring_services_id; $input['begin_date'] = $date; $this->unavaibilities_id = $this->add($input); $this->currentstate = 'critical'; } } else { // Ok if ($this->currentstate == 'critical') { // update $input = array(); $input['id'] = $this->unavaibilities_id; $input['end_date'] = $date; $this->getFromDB($this->unavaibilities_id); $input['duration'] = strtotime($date) - strtotime($this->fields['begin_date']); $this->update($input); $this->unavaibilities_id = 0; $this->currentstate = 'ok'; } } }
function generateConfig($weathermaps_id) { global $DB, $CFG_GLPI; if ($weathermaps_id < 1) { return; } $conf = "\n"; $pmWeathermapnode = new PluginMonitoringWeathermapnode(); $pmComponent = new PluginMonitoringComponent(); $pmService = new PluginMonitoringService(); $this->getFromDB($weathermaps_id); if ($this->fields['background'] != '') { $conf .= "BACKGROUND " . GLPI_PLUGIN_DOC_DIR . "/monitoring/weathermapbg/" . $this->fields['background'] . "\n"; //$conf .= "BACKGROUND http://192.168.20.194".$CFG_GLPI['root_doc']."/plugins/monitoring/front/send.php?file=weathermapbg/".$this->fields['background']."\n"; } // image file to generate $conf .= "IMAGEOUTPUTFILE " . GLPI_PLUGIN_DOC_DIR . "/monitoring/weathermap-" . $weathermaps_id . ".png\n"; $conf .= "\n"; $conf .= "WIDTH " . $this->fields["width"] . "\nHEIGHT " . $this->fields["height"] . "\nHTMLSTYLE overlib\nTITLE " . $this->fields["name"] . "\nTIMEPOS 10 20 Cree le : " . Html::convDateTime(date("Y-m-d H:i:s")) . "\n\nKEYPOS DEFAULT 10 " . ($this->fields["height"] - $this->fields["width"] / 16) . "\nKEYSTYLE DEFAULT horizontal " . $this->fields["width"] / 4 . "\nKEYTEXTCOLOR 0 0 0\nKEYOUTLINECOLOR 0 0 0\nKEYBGCOLOR 255 255 255\nBGCOLOR 255 255 255\nTITLECOLOR 0 0 0\nTIMECOLOR 0 0 0\nSCALE DEFAULT 0.0001 0.1 255 255 255 255 255 255 \nSCALE DEFAULT 0.1 50 0 255 0 255 215 0 \nSCALE DEFAULT 50 100 255 215 0 255 0 0 \n\nSET key_hidezero_DEFAULT 1\n\n# End of global section\n\n# TEMPLATE-only NODEs:\nNODE DEFAULT\n\tMAXVALUE 100\n\n# TEMPLATE-only LINKs:\nLINK DEFAULT\n\tWIDTH 4\n\tBANDWIDTH 100M\n\n# regular NODEs:\n"; $query = "SELECT * FROM `" . getTableForItemType("PluginMonitoringWeathermapnode") . "`\n WHERE `plugin_monitoring_weathermaps_id`='" . $weathermaps_id . "'\n ORDER BY `name`"; $result = $DB->query($query); $link = ''; while ($data = $DB->fetch_array($result)) { $name = $data['name']; if ($name == '') { $itemtype = $data['itemtype']; $item = new $itemtype(); $item->getFromDB($data['items_id']); $name = $item->getName(); $link = $item->getLinkURL(); } $conf .= "NODE " . preg_replace("/[^A-Za-z0-9_]/", "", $data['name']) . "_" . $data['id'] . "\n" . " LABEL " . $name . "\n" . " POSITION " . $data['x'] . " " . $data['y'] . "\n"; if ($link != '') { $conf .= " INFOURL " . $link . "\n"; } $conf .= "\n"; } $conf .= "\n\n# regular LINKs:\n"; $bwlabelpos = array(); $bwlabelpos[0] = "BWLABELPOS 81 39"; $bwlabelpos[1] = "BWLABELPOS 71 29"; $i = 0; $doublelink = array(); $doublelinkbegin = array(); $doublelinkdiff = array(); $doublelinknumber = array(); $query = "SELECT `" . getTableForItemType("PluginMonitoringWeathermaplink") . "`.*, \n count(`" . getTableForItemType("PluginMonitoringWeathermaplink") . "`.`id`) as `cnt` \n FROM `" . getTableForItemType("PluginMonitoringWeathermaplink") . "` \n LEFT JOIN `" . getTableForItemType("PluginMonitoringWeathermapnode") . "`\n ON `plugin_monitoring_weathermapnodes_id_1` = `" . getTableForItemType("PluginMonitoringWeathermapnode") . "`.`id`\n\n WHERE `plugin_monitoring_weathermaps_id`='" . $weathermaps_id . "'\n group by `plugin_monitoring_weathermapnodes_id_1`, `plugin_monitoring_weathermapnodes_id_2`\n HAVING cnt >1"; $result = $DB->query($query); while ($data = $DB->fetch_array($result)) { $tlink = $data['plugin_monitoring_weathermapnodes_id_1'] . "-" . $data['plugin_monitoring_weathermapnodes_id_2']; $doublelink[$tlink] = $data['cnt']; $doublelinknumber[$tlink] = 0; $beg = 0; $diff = 0; switch ($data['cnt']) { case 2: $beg = -22; $diff = 44; break; case 3: $beg = -33; $diff = 33; break; case 4: $beg = -39; $diff = 26; break; case 5: $beg = -60; $diff = 30; break; } $doublelinkbegin[$tlink] = $beg; $doublelinkdiff[$tlink] = $diff; } $query = "SELECT * FROM `" . getTableForItemType("PluginMonitoringWeathermapnode") . "`\n WHERE `plugin_monitoring_weathermaps_id`='" . $weathermaps_id . "'\n ORDER BY `name`"; $result = $DB->query($query); while ($data = $DB->fetch_array($result)) { $queryl = "SELECT * FROM `" . getTableForItemType("PluginMonitoringWeathermaplink") . "`\n WHERE `plugin_monitoring_weathermapnodes_id_1`='" . $data['id'] . "'"; $resultl = $DB->query($queryl); while ($datal = $DB->fetch_array($resultl)) { $bandwidth = $datal['bandwidth_in'] . " " . $datal['bandwidth_out']; if ($datal['bandwidth_in'] == $datal['bandwidth_out']) { $bandwidth = $datal['bandwidth_in']; } $pmWeathermapnode->getFromDB($datal['plugin_monitoring_weathermapnodes_id_2']); $queryevent = "SELECT * FROM `glpi_plugin_monitoring_serviceevents`\n WHERE `plugin_monitoring_services_id`='" . $datal['plugin_monitoring_services_id'] . "'\n ORDER BY `date` DESC\n LIMIT 1"; $resultevent = $DB->query($queryevent); $in = ''; $out = ''; while ($dataevent = $DB->fetch_array($resultevent)) { $pmService->getFromDB($datal['plugin_monitoring_services_id']); $pmComponent->getFromDB($pmService->fields['plugin_monitoring_components_id']); $matches1 = array(); preg_match("/" . $pmComponent->fields['weathermap_regex_in'] . "/m", $dataevent['perf_data'], $matches1); if (isset($matches1[1])) { $in = $matches1[1]; } $matches1 = array(); preg_match("/" . $pmComponent->fields['weathermap_regex_out'] . "/m", $dataevent['perf_data'], $matches1); if (isset($matches1[1])) { $out = $matches1[1]; } } $in = $this->checkBandwidth("in", $in, $bandwidth); $out = $this->checkBandwidth("out", $out, $bandwidth); $nodesuffix = ''; $tlink = $datal['plugin_monitoring_weathermapnodes_id_1'] . "-" . $datal['plugin_monitoring_weathermapnodes_id_2']; if (isset($doublelink[$tlink])) { $nodesuffix = ":" . ($doublelinkbegin[$tlink] + $doublelinknumber[$tlink] * $doublelinkdiff[$tlink]) . ":0"; $doublelinknumber[$tlink]++; } $conf .= "LINK " . preg_replace("/[^A-Za-z0-9_]/", "", $data['name']) . "_" . $data['id'] . "-" . preg_replace("/[^A-Za-z0-9_]/", "", $pmWeathermapnode->fields['name']) . "_" . $pmWeathermapnode->fields['id'] . $nodesuffix . "\n"; $timezone = '0'; if (isset($_SESSION['plugin_monitoring_timezone'])) { $timezone = $_SESSION['plugin_monitoring_timezone']; } $timezone_file = str_replace("+", ".", $timezone); // if (file_exists(GLPI_ROOT."/files/_plugins/monitoring/PluginMonitoringService-".$datal['plugin_monitoring_services_id']."-2h".$timezone_file.".gif")) { $conf .= " INFOURL " . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/display.form.php?itemtype=PluginMonitoringService&items_id=" . $datal['plugin_monitoring_services_id'] . "\n" . " OVERLIBGRAPH " . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/send.php?file=PluginMonitoringService-" . $datal['plugin_monitoring_services_id'] . "-2h" . $timezone_file . ".png\n"; // } $conf .= " " . $bwlabelpos[$i] . "\n"; // Manage for port down $retflag = PluginMonitoringDisplay::getState($pmService->fields['state'], $pmService->fields['state_type'], '', $pmService->fields['is_acknowledged']); if ($retflag == 'red') { $conf .= " TARGET static:" . $datal['bandwidth_in'] . ":" . $datal['bandwidth_out'] . "\n"; } else { $conf .= " TARGET static:" . $in . ":" . $out . "\n"; } $conf .= " NODES " . preg_replace("/[^A-Za-z0-9_]/", "", $data['name']) . "_" . $data['id'] . $nodesuffix . " " . preg_replace("/[^A-Za-z0-9_]/", "", $pmWeathermapnode->fields['name']) . "_" . $pmWeathermapnode->fields['id'] . $nodesuffix . "\n"; $conf .= " BANDWIDTH " . $bandwidth . "\n\n"; $i++; if ($i == '2') { $i = 0; } } } return $conf; }
function showBADetail($id) { global $CFG_GLPI; $pmParentSC = new PluginMonitoringServicescatalog(); $pMonitoringBusinessrule = new PluginMonitoringBusinessrule(); $pMonitoringBusinessrulegroup = new PluginMonitoringBusinessrulegroup(); $pMonitoringService = new PluginMonitoringService(); $this->getFromDB($id); $derivated = false; if ($this->getField('plugin_monitoring_servicescatalogs_id') > 0) { $derivated = true; $pmParentSC->getFromDB($this->getField('plugin_monitoring_servicescatalogs_id')); } // If SC is derivated from a template, get groups from its parent ... if ($derivated) { $a_groups = $pMonitoringBusinessrulegroup->find("`plugin_monitoring_servicescatalogs_id`='" . $pmParentSC->fields['id'] . "'"); } else { $a_groups = $pMonitoringBusinessrulegroup->find("`plugin_monitoring_servicescatalogs_id`='" . $id . "'"); } echo "<table class='tab_cadrehov'>"; echo "<tr class='tab_bg_1'>"; /* $color = $this->getShortState(); // $color = PluginMonitoringHost::getState($this->fields['state'], // $this->fields['state_type'], // 'data', // $this->fields['is_acknowledged']); $pic = $color; $color = str_replace("_soft", "", $color); */ echo "<td rowspan='" . count($a_groups) . "' class='center service" . $this->getField('state') . "' width='200'>"; echo "<strong style='font-size: 20px'>" . $this->getName() . "</strong><br/>"; echo "<img src='" . $this->getShortState(array('image' => '40')) . "'/>"; echo "</td>"; $i = 0; foreach ($a_groups as $gdata) { $a_brulesg = $pMonitoringBusinessrule->find("`plugin_monitoring_businessrulegroups_id`='" . $gdata['id'] . "'"); if ($i > 0) { echo "<tr>"; } $state = array(); $state['OK'] = 0; $state['WARNING'] = 0; $state['CRITICAL'] = 0; $state['UNKNOWN'] = 0; foreach ($a_brulesg as $brulesdata) { // If SC is derivated from a template, do not care about services not from the same entity ... if (!$pMonitoringService->getFromDB($brulesdata['plugin_monitoring_services_id'])) { continue; } if ($derivated && $pMonitoringService->getField('entities_id') != $this->getField('entities_id')) { continue; } $state[$pMonitoringService->getState()]++; } $overall_state = "OK"; if ($gdata['operator'] == 'and') { if ($state['UNKNOWN'] >= 1) { $overall_state = "UNKNOWN"; } else { if ($state['CRITICAL'] >= 1) { $overall_state = "CRITICAL"; } else { if ($state['WARNING'] >= 1) { $overall_state = "WARNING"; } else { if ($state['OK'] >= 1) { $overall_state = "OK"; } } } } } else { if ($gdata['operator'] == 'or') { if ($state['OK'] >= 1) { $overall_state = "OK"; } else { if ($state['WARNING'] >= 1) { $overall_state = "WARNING"; } else { if ($state['CRITICAL'] >= 1) { $overall_state = "CRITICAL"; } else { if ($state['UNKNOWN'] >= 1) { $overall_state = "UNKNOWN"; } } } } } else { $num_min = str_replace(" of:", "", $gdata['operator']); if ($state['OK'] >= $num_min) { $overall_state = "OK"; } else { if ($state['WARNING'] >= $num_min) { $overall_state = "WARNING"; } else { if ($state['CRITICAL'] >= $num_min) { $overall_state = "CRITICAL"; } else { if ($state['UNKNOWN'] >= $num_min) { $overall_state = "UNKNOWN"; } } } } } } echo "<td class='center service" . $overall_state . "'>"; echo $gdata['name'] . "<br/>[ " . $gdata['operator'] . " ]"; echo "</td>"; echo "<td class='service" . $overall_state . "'>"; echo "<table>"; foreach ($a_brulesg as $brulesdata) { // $pMonitoringService->getFromDB($brulesdata['plugin_monitoring_services_id']); // If SC is derivated from a template, do not care about services not from the same entity ... if (!$pMonitoringService->getFromDB($brulesdata['plugin_monitoring_services_id'])) { continue; } if ($derivated && $pMonitoringService->getField('entities_id') != $this->getField('entities_id')) { continue; } // Last parameter is true to display counters/graphs, false if not needed echo "<tr class='tab_bg_1'>"; // Display a line for the service including host information, no counters but graphs PluginMonitoringDisplay::displayLine($pMonitoringService->fields, true, false, true); echo "</tr>"; } echo "</table>"; echo "</th>"; echo "</tr>"; $i++; } echo "</tr>"; echo "</table>"; }
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'))); }
static function methodDashboard($params, $protocol) { $response = array(); if (!isset($params['view'])) { return $response; } $pm = new PluginMonitoringDisplay(); if ($params['view'] == 'Hosts') { return $pm->displayHostsCounters(0); } else { return $pm->displayCounters($params['view'], 0); } }
@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 ------------------------------------------------------------------------ */ if (!defined('GLPI_ROOT')) { define('GLPI_ROOT', '../../..'); } include GLPI_ROOT . "/inc/includes.php"; checkCentralAccess(); commonHeader($LANG['plugin_monitoring']['title'][0], $_SERVER["PHP_SELF"], "plugins", "monitoring", "display"); if (isset($_POST['sessionupdate'])) { $_SESSION['glpi_plugin_monitoring']['_refresh'] = $_POST['_refresh']; glpi_header($_SERVER['HTTP_REFERER']); exit; } if (isset($_POST["plugin_monitoring_timezone"])) { $_SESSION['plugin_monitoring_timezone'] = $_POST["plugin_monitoring_timezone"]; glpi_header($_SERVER['HTTP_REFERER']); } $pMonitoringDisplay = new PluginMonitoringDisplay(); if (isset($_GET['itemtype']) and isset($_GET['items_id'])) { $pMonitoringDisplay->refreshPage(); echo '<meta http-equiv ="refresh" content="' . $_SESSION['glpi_plugin_monitoring']['_refresh'] . '">'; $pmServicegraph = new PluginMonitoringServicegraph(); $pmServicegraph->parseToDB($_GET['items_id']); $pMonitoringDisplay->displayGraphs($_GET['itemtype'], $_GET['items_id']); } commonFooter();
You should have received a copy of the GNU Affero General Public License along with Monitoring. If not, see <http://www.gnu.org/licenses/>. ------------------------------------------------------------------------ @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(); if (!isset($_POST["id"])) { Html::redirect($CFG_GLPI["root_doc"] . "/plugins/monitoring/front/display.php"); } $pmDisplay = new PluginMonitoringDisplay(); $pmBusinessrule = new PluginMonitoringBusinessrule(); $pmDisplayview = new PluginMonitoringDisplayview(); $a_views = $pmDisplayview->getViews(); PluginMonitoringDisplay::addRemoveTab('remove', $_REQUEST['glpi_tab']); PluginMonitoringDisplay::displayTab($_REQUEST['glpi_tab']); Html::ajaxFooter();
/** * 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>"; }
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; }
------------------------------------------------------------------------ @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::checkCentralAccess(); Html::header(__('Monitoring - dashboard (services catalogs)', 'monitoring'), $_SERVER["PHP_SELF"], "plugins", "PluginMonitoringDashboard", "dashboard"); // Reduced or normal interface ? if (!isset($_SESSION['plugin_monitoring_reduced_interface'])) { $_SESSION['plugin_monitoring_reduced_interface'] = false; } $pmDisplay = new PluginMonitoringDisplay(); $pmServicescatalog = new PluginMonitoringServicescatalog(); $pmMessage = new PluginMonitoringMessage(); $pmMessage->getMessages(); $pmDisplay->menu(); Session::checkRight("plugin_monitoring_servicescatalog", PluginMonitoringServicescatalog::DASHBOARD); $pmDisplay->showCounters("Businessrules"); $pmServicescatalog->showChecks($_SESSION['plugin_monitoring_reduced_interface']); Html::footer();
$params = Search::manageParams("PluginMonitoringService", $_GET); /* // Display ressources perfdata ? if (isset($_SESSION['plugin_monitoring']['ressources_perfdata'])) { Html::redirect($CFG_GLPI['root_doc']."/plugins/monitoring/front/perfdatas.php"); unset($_SESSION['plugin_monitoring']['ressources_perfdata']); } */ // Reduced or normal interface ? if (!isset($_SESSION['plugin_monitoring_reduced_interface'])) { $_SESSION['plugin_monitoring_reduced_interface'] = false; } if (isset($_POST['reduced_interface'])) { $_SESSION['plugin_monitoring_reduced_interface'] = $_POST['reduced_interface']; } $pmDisplay = new PluginMonitoringDisplay(); $pmMessage = new PluginMonitoringMessage(); $pmMessage->getMessages(); $pmDisplay->menu('service'); $pmDisplay->showCounters("Ressources", 1, 0); // Manage search if (isset($_SESSION['plugin_monitoring']['service'])) { $_GET = $_SESSION['plugin_monitoring']['service']; } if (isset($_GET['reset'])) { unset($_SESSION['glpisearch']['PluginMonitoringService']); } if (isset($_GET['glpi_tab'])) { unset($_GET['glpi_tab']); } //Search::manageGetValues("PluginMonitoringService");
/** * 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(); }
function plugin_headings_monitoring_dashboadservicecatalog($item) { $pmServicescatalog = new PluginMonitoringServicescatalog(); $pmDisplay = new PluginMonitoringDisplay(); $pmDisplay->displayCounters("Businessrules"); $pmServicescatalog->showBAChecks(); }
include "../../../inc/includes.php"; Session::checkCentralAccess(); Html::header(__('Monitoring - dashboard (hosts)', 'monitoring'), $_SERVER["PHP_SELF"], "plugins", "PluginMonitoringDashboard", "dashboard"); $params = Search::manageParams("PluginMonitoringHost", $_GET); // Display ressources perfdata ? if (isset($_SESSION['plugin_monitoring']['ressources_perfdata'])) { unset($_SESSION['plugin_monitoring']['ressources_perfdata']); } // Reduced or normal interface ? if (!isset($_SESSION['plugin_monitoring_reduced_interface'])) { $_SESSION['plugin_monitoring_reduced_interface'] = false; } if (isset($_POST['reduced_interface'])) { $_SESSION['plugin_monitoring_reduced_interface'] = $_POST['reduced_interface']; } $pmDisplay = new PluginMonitoringDisplay(); $pmMessage = new PluginMonitoringMessage(); $pmMessage->getMessages(); $pmDisplay->menu('service'); $pmDisplay->showHostsCounters("Hosts", 1, 1); // Manage search if (isset($_SESSION['plugin_monitoring']['host'])) { $_GET = $_SESSION['plugin_monitoring']['host']; } if (isset($_GET['reset'])) { unset($_SESSION['glpisearch']['PluginMonitoringHost']); } if (isset($_GET['glpi_tab'])) { unset($_GET['glpi_tab']); } if (isset($_GET['hidesearch'])) {