Beispiel #1
0
 static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0)
 {
     if ($item->getID() > 0) {
         if ($tabnum == 0) {
             PluginMonitoringServicegraph::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;
 }
Beispiel #2
0
 function showBoard($width = '', $limit = '')
 {
     global $DB, $CFG_GLPI;
     $order = "ASC";
     if (isset($_GET['order'])) {
         $order = $_GET['order'];
     }
     $where = '';
     if ($limit == 'hosts') {
         $where = "`plugin_monitoring_services_id`='0' ";
     } else {
         if ($limit == 'services') {
             $where = "`plugin_monitoring_services_id`>0 ";
         }
     }
     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 = '';
     $leftjoin .= " LEFT JOIN `glpi_plugin_monitoring_components`\n         ON `plugin_monitoring_components_id` = \n         `glpi_plugin_monitoring_components`.`id` ";
     $leftjoin .= " LEFT JOIN `glpi_entities`\n         ON `" . getTableForItemType("PluginMonitoringService") . "`.`entities_id` = \n               `glpi_entities`.`id`";
     if (isset($_GET['field'])) {
         foreach ($_GET['field'] as $value) {
             if ($value == '20' or $value == '21' or $value == '22') {
                 $leftjoin .= " LEFT JOIN `glpi_plugin_monitoring_componentscatalogs_hosts`\n                  ON `plugin_monitoring_componentscatalogs_hosts_id` = \n                  `glpi_plugin_monitoring_componentscatalogs_hosts`.`id` ";
             } else {
                 if ($value == '7') {
                 } else {
                     if ($value == '8') {
                         if (!strstr($leftjoin, 'LEFT JOIN `glpi_plugin_monitoring_componentscatalogs_hosts`')) {
                             $leftjoin .= " LEFT JOIN `glpi_plugin_monitoring_componentscatalogs_hosts`\n                  ON `plugin_monitoring_componentscatalogs_hosts_id` = \n                  `glpi_plugin_monitoring_componentscatalogs_hosts`.`id` ";
                         }
                         if (!strstr($leftjoin, 'LEFT JOIN `glpi_plugin_monitoring_componentscatalogs`')) {
                             $leftjoin .= " LEFT JOIN `glpi_plugin_monitoring_componentscatalogs`\n                     ON `glpi_plugin_monitoring_componentscatalogs_hosts`.`plugin_monitoring_componentscalalog_id` = \n                     `glpi_plugin_monitoring_componentscatalogs`.`id` ";
                         }
                     }
                 }
             }
         }
     }
     // * ORDER
     $ORDERQUERY = " ORDER BY `name` ";
     $toview = array(3, 6, 7, 10, 4, 9);
     $toviewComplete = array('ITEM_0' => 'state', 'ITEM_1' => 'completename', 'ITEM_2' => 'component_name', 'ITEM_3' => 'state', 'ITEM_4' => 'last_check', 'ITEM_5' => '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 `" . getTableForItemType("PluginMonitoringService") . "`.*,\n            `glpi_plugin_monitoring_components`.`name` as component_name, \n            `glpi_entities`.`completename`\n         FROM `" . getTableForItemType("PluginMonitoringService") . "`\n         " . $leftjoin . "\n         " . $where . "\n         " . $ORDERQUERY;
     $result = $DB->query($query);
     $start = 0;
     if (isset($_GET["start"])) {
         $start = $_GET["start"];
     }
     $numrows = $DB->numrows($result);
     $parameters = '';
     $globallinkto = Search::getArrayUrlLink("field", $_GET['field']) . Search::getArrayUrlLink("link", $_GET['link']) . Search::getArrayUrlLink("contains", $_GET['contains']) . Search::getArrayUrlLink("searchtype", $_GET['searchtype']) . Search::getArrayUrlLink("field2", $_GET['field2']) . Search::getArrayUrlLink("contains2", $_GET['contains2']) . Search::getArrayUrlLink("itemtype2", $_GET['itemtype2']) . Search::getArrayUrlLink("searchtype2", $_GET['searchtype2']) . Search::getArrayUrlLink("link2", $_GET['link2']);
     $parameters = "sort=" . $_GET['sort'] . "&order=" . $_GET['order'] . $globallinkto;
     Html::printPager($_GET['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']);
     $result = $DB->query($query);
     echo '<div id="custom_date" style="display:none"></div>';
     echo '<div id="custom_time" style="display:none"></div>';
     if ($width == '') {
         echo "<table class='tab_cadrehov' style='width:100%;'>";
     } else {
         echo "<table class='tab_cadrehov' style='width:100%;'>";
     }
     $num = 0;
     echo "<tr class='tab_bg_1'>";
     $this->showHeaderItem(__('Status'), 3, $num, $start, $globallinkto);
     $this->showHeaderItem(__('Entity'), 6, $num, $start, $globallinkto);
     echo Search::showHeaderItem(0, __('Show graphics'), $num);
     echo Search::showHeaderItem(0, __('Item type') . " - " . __('Name'), $num);
     $this->showHeaderItem(__('Components', 'monitoring'), 7, $num, $start, $globallinkto);
     $this->showHeaderItem(__('Status'), 10, $num, $start, $globallinkto);
     $this->showHeaderItem(__('Last check', 'monitoring'), 4, $num, $start, $globallinkto);
     $this->showHeaderItem(__('Result details'), 9, $num, $start, $globallinkto);
     echo Search::showHeaderItem(0, __('Check period', 'monitoring'), $num);
     echo '<th>' . __('Acknowledge', 'monitoring') . '</th>';
     echo "</tr>";
     PluginMonitoringServicegraph::loadLib();
     while ($data = $DB->fetch_array($result)) {
         echo "<tr class='tab_bg_3'>";
         $this->displayLine($data);
         echo "</tr>";
     }
     echo "</table>";
     echo "<br/>";
     Html::printPager($_GET['start'], $numrows, $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/service.php", $parameters);
 }
Beispiel #3
0
  (at your option) any later version.

  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    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     2013

  ------------------------------------------------------------------------
*/
include "../../../inc/includes.php";
Session::checkCentralAccess();
Html::header(__('Monitoring', 'monitoring'), $_SERVER["PHP_SELF"], "plugins", "monitoring", "display");
PluginMonitoringServicegraph::loadLib();
$pmService = new PluginMonitoringService();
$pmService->manageServices($_GET['itemtype'], $_GET['items_id']);
Html::footer();
 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>";
     PluginMonitoringServicegraph::loadLib();
     if ($config == '1') {
         $this->addItem($id);
         $pmDisplayview_rule->showReplayRulesForm($id);
         echo "<div id='updatecoordonates'></div>";
     } 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'>";
     echo "<tr class='tab_bg_1'>";
     echo "<th>";
     echo $pmDisplayview->fields['name'];
     echo "</th>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<th>";
     echo "<a onClick='Ext.get(\"date_text\").toggle();Ext.get(\"date_select\").toggle();" . "Ext.get(\"time_text\").toggle();Ext.get(\"time_select\").toggle();'>\n      <img src='" . $CFG_GLPI["root_doc"] . "/pics/deplier_down.png' />&nbsp;\n         " . __('Date and time select', 'monitoring') . "\n      &nbsp;<img src='" . $CFG_GLPI["root_doc"] . "/pics/deplier_down.png' /></a>";
     echo "</th>";
     echo "</tr>";
     echo "<tr class='tab_bg_1' id='date_text' style='display: none;'>";
     echo "<th>";
     echo __('Select date', 'monitoring');
     echo "</th>";
     echo "</tr>";
     echo "<tr class='tab_bg_1' id='date_select' style='display: none;'>";
     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']);
         }
     }
     echo "\n<script type=\"text/javascript\">\n\nExt.onReady(function(){\n\n    var tip = new Ext.slider.Tip({\n        getText: function(thumb){\n            return String.format('<b> ' + new Date(thumb.value * 1000).format('Y-m-d') + '</b>');\n        }\n    });\n\n    new Ext.Slider({\n        renderTo: 'custom-tip-slider',\n        width: 940,\n        increment: 86400,\n        minValue: " . $start . ",\n        maxValue: " . $end . ",\n        value: " . $end . ",\n        plugins: tip,\n        listeners: {\n            dragend: function(slider, thumb, value){\n               document.getElementById('custom_date').textContent = slider.getValue();\n                  ";
     $pmServicegraph = new PluginMonitoringServicegraph();
     foreach ($a_items as $js_id => $js_data) {
         echo "mgr" . $js_data['items_id'] . $js_data['time'] . ".stopAutoRefresh();\n";
         $pmServicegraph->startAutoRefresh($js_data['rrdtool_template'], $js_data['itemtype'], $js_data['items_id'], $js_data['timezone'], $js_data['time'], $js_data['pmComponents_id']);
     }
     echo "\n            }\n        }\n    });\n\n});\n</script>";
     echo '<center><div id="custom-tip-slider"></div></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' id='time_select' style='display: none;'>";
     echo "<td>";
     $start = 0 + 86400 - 3600;
     $end = 86400 + 86400 - 3600 - 300;
     $current = mktime(date('H'), date('i'), 0, 1, 2, 1970);
     echo "\n<script type=\"text/javascript\">\n\nExt.onReady(function(){\n\n   var tiptime = new Ext.slider.Tip({\n        getText: function(thumb){\n            return String.format('<b> ' + new Date(thumb.value * 1000).format('H:i:s') + '</b>');\n        }\n    });\n\n    new Ext.Slider({\n        renderTo: 'custom-tip-slider-time',\n        width: 940,\n        increment: 300,\n        minValue: " . $start . ",\n        maxValue: " . $end . ",\n        value: " . $current . ",\n        plugins: tiptime,\n        listeners: {\n            dragend: function(slider, thumb, value){\n               document.getElementById('custom_time').textContent = slider.getValue();\n                  ";
     $pmServicegraph = new PluginMonitoringServicegraph();
     foreach ($a_items as $js_id => $js_data) {
         echo "mgr" . $js_data['items_id'] . $js_data['time'] . ".stopAutoRefresh();\n";
         $pmServicegraph->startAutoRefresh($js_data['rrdtool_template'], $js_data['itemtype'], $js_data['items_id'], $js_data['timezone'], $js_data['time'], $js_data['pmComponents_id']);
     }
     echo "\n            }\n        }\n    });\n\n});\n</script>";
     echo '<center><div id="custom-tip-slider-time"></div></center>';
     echo "</td>";
     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'>&nbsp;</div>";
         echo "<input type='hidden' name='updatefil' id='updatefil' value='" . $id . "!' />";
         echo "<script type=\"text/javascript\">\n            function reloadfil() {\n               Ext.get('filariane').load({\n                   url: '" . $CFG_GLPI["root_doc"] . "/plugins/monitoring/ajax/updateFilariane.php',\n                   scripts: true,\n                      params:'updatefil=' + Ext.get('updatefil').getValue() + '&id=" . $_GET['id'] . "&currentview=' + Ext.get('updateviewid').getValue()\n               });\n            }\n            reloadfil();\n         </script>";
     }
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td height='1200' id='panel'>";
     echo '<div id="custom_date" style="display:none"></div>';
     echo '<div id="custom_time" style="display:none"></div>';
     echo "<div id='viewform'>";
     echo "<script type='text/javascript'>\n        \n        //Simple 'border layout' panel to house both grids\n        var displayPanel = new Ext.Panel({\n          id       : 'viewpanel',\n          width    : " . $pmDisplayview->fields['width'] . ",\n          height   : 1200,\n          layout: 'absolute',\n          renderTo : 'panel',\n          items    : []\n        });\n\n      </script>";
     echo "</div>";
     echo "<script type=\"text/javascript\">\n         function reloadview() {\n            Ext.get('viewform').load({\n                url: '" . $CFG_GLPI["root_doc"] . "/plugins/monitoring/ajax/loadView.php',\n                scripts: true,\n                   params:'id=' + Ext.get('updateviewid').getValue() + '&config=" . $config . "'\n            });\n         }\n         reloadview();\n      </script>";
     echo "</td>";
     echo "</tr>";
     echo "</table>";
     echo "<br/>";
 }
Beispiel #5
0
 /**
  * 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;
     PluginMonitoringServicegraph::loadLib();
     $pmComponentscatalog = new PluginMonitoringComponentscatalog();
     $pmComponent = new PluginMonitoringComponent();
     $pmServicegraph = new PluginMonitoringServicegraph();
     $query = "SELECT * FROM `glpi_plugin_monitoring_componentscatalogs_hosts`\n         WHERE `items_id`='" . $items_id . "'\n            AND `itemtype`='" . $itemtype . "'";
     $result = $DB->query($query);
     echo '<div id="custom_date" style="display:none"></div>';
     echo '<div id="custom_time" style="display:none"></div>';
     echo "<table class='tab_cadre_fixe'>";
     $td = 0;
     while ($data = $DB->fetch_array($result)) {
         $pmComponentscatalog->getFromDB($data['plugin_monitoring_componentscalalog_id']);
         $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)) {
             $pmComponent->getFromDB($datas['plugin_monitoring_components_id']);
             if ($pmComponent->fields['graph_template'] != '') {
                 if ($td == 0) {
                     echo "<tr>";
                 }
                 echo "<td width='425'>";
                 echo "<table class='tab_cadre'>";
                 echo "<tr class='tab_bg_3'>";
                 echo "<th width='475'>";
                 echo $pmComponent->fields['name'];
                 echo "</th>";
                 echo "</tr>";
                 echo "<tr class='tab_bg_1'>";
                 echo "<td>";
                 $pmServicegraph->displayGraph($pmComponent->fields['graph_template'], "PluginMonitoringService", $datas['id'], "0", "2h", "", 450);
                 echo "</td>";
                 echo "</tr>";
                 echo "</table>";
                 $td++;
                 echo "</td>";
                 if ($td == 2) {
                     echo "</tr>";
                     $td = 0;
                 }
             }
         }
     }
     if ($td == 1) {
         echo "<td></td>";
     }
     echo "</tr>";
     echo "</table>";
 }