Ejemplo n.º 1
0
function plugin_headings_monitoring_dashboadview($item)
{
    $pmDisplayview = new PluginMonitoringDisplayview();
    $a_views = $pmDisplayview->getViews();
    $i = 5;
    foreach ($a_views as $views_id => $name) {
        if ($_SESSION['plugin_monitoring_displaytab'] == "monitoring_" . $i) {
            $pmDisplayview_item = new PluginMonitoringDisplayview_item();
            $pmDisplayview_item->view($views_id);
        }
        $i++;
    }
}
Ejemplo n.º 2
0
   function slideSlider($id) {
      global $CFG_GLPI, $DB;

      echo "<script type='text/javascript'>
         function fittext(itemid) {
            document.getElementById(itemid).style.fontSize = '50px';
            var fontsize = 50;
            while(document.getElementById(itemid).offsetWidth > 120) {
               fontsize--;
               if (fontsize > 20) {
                  fontsize--;
               }
               document.getElementById(itemid).style.fontSize = fontsize + 'px';
            }
            while(document.getElementById(itemid).offsetHeight > 67) {
               fontsize--;
               document.getElementById(itemid).style.fontSize = fontsize + 'px';
            }
            if (fontsize > 30) {
               document.getElementById(itemid).style.fontSize = '30px';
            }
            if (fontsize < 7) {
               document.getElementById(itemid).style.fontSize = '7px';
            }
         }
      </script>";
      PluginMonitoringToolbox::loadLib();

      $this->getFromDB($id);
      echo '<div id="custom_date" style="display:none"></div>';
      echo '<div id="custom_time" style="display:none"></div>';

      echo '<script src="'.$CFG_GLPI["root_doc"].'/plugins/monitoring/lib/slider.js-14/js/jssor.slider.mini.js"></script>
<script>
    jQuery(document).ready(function ($) {
        //Define an array of slideshow transition code
        var _SlideshowTransitions = [
        {$Duration:0001,$Opacity:2}
        ];
        var options = {
            $AutoPlay: true,
            $AutoPlayInterval: '.$this->fields['duration'].'000,
            $SlideshowOptions: {
                    $Class: $JssorSlideshowRunner$,
                    $Transitions: _SlideshowTransitions,
                    $TransitionsOrder: 1,
                    $ShowLink: true
        }
        };
        var jssor_slider1 = new $JssorSlider$(\'slider1_container\', options);
    });
</script>';
      echo "<table class='tab_cadre'>";

      echo "<tr>";
      echo "<td>";

      $query = "SELECT * FROM `glpi_plugin_monitoring_sliders_items`
              WHERE `plugin_monitoring_sliders_id`='".$id."'";

      $result = $DB->query($query);
      $maxWidth = 0;
      $maxHeight = 0;
      $is_minemap = 0;
      while ($data=$DB->fetch_array($result)) {
         if ($data['itemtype'] == 'PluginMonitoringServicescatalog'
                 || $data['itemtype'] == 'PluginMonitoringComponentscatalog'
                 || $data['itemtype'] == 'PluginMonitoringCustomitem_Gauge'
                 || $data['itemtype'] == 'PluginMonitoringCustomitem_Counter') {
            if ($maxWidth < 180) {
               $maxWidth = 180;
            }
            if ($maxHeight < 180) {
               $maxHeight = 180;
            }
            if ($data['is_minemap'] == 1) {
               $is_minemap = 1;
            }
         } else if ($data['itemtype'] == 'PluginMonitoringService') {
            if ($maxWidth < 475) {
               $maxWidth = 475;
            }
            if ($maxHeight < 330) {
               $maxHeight = 330;
            }
         } else if ($data['itemtype'] == "PluginMapsMap") {
            if ($maxWidth < 950) {
               $maxWidth = 950;
            }
            if ($maxHeight < 800) {
               $maxHeight = 800;
            }
         } else {
            $itemtype = $data['itemtype'];
            $item = new $itemtype();
            $item->getFromDB($data['items_id']);
            if ($maxWidth < $item->fields['width']) {
               $maxWidth = $item->fields['width'];
            }
            if (isset($item->fields['height'])) {
               if ($maxHeight < $item->fields['width']) {
                  $maxHeight = $item->fields['height'];
               }
            }
         }
      }
      if ($is_minemap) {
         $maxHeight = '1500';
      }

      $pm = new PluginMonitoringComponentscatalog();
      echo '<div id="slider1_container" style="position: relative;
top: 0px; left: 0px; width: '.$maxWidth.'px; height: '.$maxHeight.'px;">
    <!-- Slides Container -->
    <div u="slides" style="cursor: move; position: absolute; overflow: hidden;
    left: 0px; top: 0px; width: '.$maxWidth.'px; height: '.$maxHeight.'px;">';

      $result = $DB->query($query);
      while ($data=$DB->fetch_array($result)) {
         $itemtype = $data['itemtype'];
         $item = new $itemtype();
         if ($itemtype == "PluginMonitoringService") {
            echo '<div>';
            echo $item->showWidget($data['items_id'], $data['extra_infos']);
            echo '</div>';
         } else if ($itemtype == "PluginMonitoringWeathermap") {
            echo '<div>';
            echo '<div id="weathermap-'.$data['items_id'].'"></div>';
            echo '</div>';
         } else if ($itemtype == 'PluginMonitoringDisplayview') {
            echo '<div>';
            $pmDisplayview_item = new PluginMonitoringDisplayview_item();
            echo $pmDisplayview_item->view($data['items_id']);
            echo '</div>';
         } else if ($itemtype == "PluginMapsMap") {
            echo '<div>';
            echo '<div id="pluginmap"></div>';
            echo '</div>';
         } else {
            echo '<div>';
            echo $item->showWidget($data['items_id']);
            echo '</div>';
         }

      }
echo '    </div>
</div>';
      $result = $DB->query($query);
      while ($data=$DB->fetch_array($result)) {
         $itemtype = $data['itemtype'];
         $item = new $itemtype();
         // Ajax
         if ($itemtype == "PluginMonitoringService") {
            $pmComponent = new PluginMonitoringComponent();
            $item = new $itemtype();

            $item->getFromDB($data['items_id']);
            $pmComponent->getFromDB($item->fields['plugin_monitoring_components_id']);
            $pmServicegraph = new PluginMonitoringServicegraph();
            $pmServicegraph->displayGraph($pmComponent->fields['graph_template'],
                                          "PluginMonitoringService",
                                          $data['items_id'],
                                          "0",
                                          $data['extra_infos'],
                                          "js");
         } else if($itemtype == "PluginMonitoringComponentscatalog") {
            $pmComponentscatalog = new PluginMonitoringComponentscatalog();
            $pmComponentscatalog->ajaxLoad($data['items_id'], $data['is_minemap']);
         } else if($itemtype == "PluginMonitoringServicescatalog") {
            $pmServicescatalog = new PluginMonitoringServicescatalog();
            $pmServicescatalog->ajaxLoad($data['items_id']);
         } else if($itemtype == "PluginMonitoringDisplayview") {

         } else if($itemtype == "PluginMonitoringCustomitem_Gauge") {
            $pmCustomitem_Gauge = new PluginMonitoringCustomitem_Gauge();
            $pmCustomitem_Gauge->ajaxLoad($data['items_id']);
         } else if($itemtype == "PluginMonitoringCustomitem_Counter") {
            $pmCustomitem_Counter = new PluginMonitoringCustomitem_Counter();
            $pmCustomitem_Counter->ajaxLoad($data['items_id']);
         }
         if ($itemtype == "PluginMonitoringWeathermap") {
            $sess_id = session_id();
            PluginMonitoringSecurity::updateSession();

            echo "<script type='text/javascript'>
            var mgr = new Ext.UpdateManager('weathermap-".$data['items_id']."');
            mgr.startAutoRefresh(50, \"".$CFG_GLPI["root_doc"].
                    "/plugins/monitoring/ajax/widgetWeathermap.php\","
                    . " \"id=".$data['items_id']."&extra_infos=".
                    $data['extra_infos']."&sess_id=".$sess_id.
                    "&glpiID=".$_SESSION['glpiID'].
                    "&plugin_monitoring_securekey=".$_SESSION['plugin_monitoring_securekey'].
                    "\", \"\", true);
            </script>";
         }
         if ($itemtype == "PluginMapsMap") {
            $sess_id = session_id();
            PluginMonitoringSecurity::updateSession();

            echo "<script type='text/javascript'>
            var mgr = new Ext.UpdateManager('pluginmap');
            mgr.startAutoRefresh(50, \"".$CFG_GLPI["root_doc"].
                    "/plugins/monitoring/ajax/widgetPluginmap.php\","
                    . " \"extra_infos=".
                    $data['extra_infos']."&sess_id=".$sess_id.
                    "&glpiID=".$_SESSION['glpiID'].
                    "&plugin_monitoring_securekey=".$_SESSION['plugin_monitoring_securekey'].
                    "\", \"\", true);
            </script>";
         }
      }
      echo "</td>";
      echo "</tr>";
      echo "</table>";
   }
Ejemplo n.º 3
0
  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

  ------------------------------------------------------------------------
*/
// Direct access to file
if (strpos($_SERVER['PHP_SELF'], "loadView.php")) {
    include "../../../inc/includes.php";
    header("Content-Type: text/html; charset=UTF-8");
    Html::header_nocache();
}
if (!defined('GLPI_ROOT')) {
    die("Can not acces directly to this file");
}
Session::checkLoginUser();
$pmDisplayview_item = new PluginMonitoringDisplayview_item();
$pmDisplayview_item->reloadView($_POST['id'], $_POST['config']);
  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-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     2013

  ------------------------------------------------------------------------
*/
// Direct access to file
if (strpos($_SERVER['PHP_SELF'], "showPanel.php")) {
    include "../../../inc/includes.php";
    header("Content-Type: text/html; charset=UTF-8");
    Html::header_nocache();
}
if (!defined('GLPI_ROOT')) {
    die("Can not acces directly to this file");
}
Session::checkLoginUser();
$pmDisplayview_item = new PluginMonitoringDisplayview_item();
if (isset($_GET['id']) && isset($_GET['config'])) {
    $pmDisplayview_item->show_panel($_GET['id'], $_GET['config']);
}
  @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      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>';
    }
Ejemplo n.º 7
0
  @package   Plugin Monitoring for GLPI
  @author    David Durieux
  @co-author 
  @comment   
  @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;
}
$pmDisplayview = new PluginMonitoringDisplayview();
$pmDisplayview_item = new PluginMonitoringDisplayview_item();
switch ($_REQUEST['glpi_tab']) {
    case -1:
        break;
    case 1:
        $pmDisplayview_item->view($_POST['id'], 1);
        break;
    default:
        break;
}
ajaxFooter();
 static function getItemsDynamicly($parm)
 {
     global $DB;
     $pmDisplayview_rule = new PluginMonitoringDisplayview_rule();
     $pmDisplayview_item = new PluginMonitoringDisplayview_item();
     $pmDisplayview = new PluginMonitoringDisplayview();
     $pmSearch = new PluginMonitoringSearch();
     $pmService = new PluginMonitoringService();
     $devices_present = array();
     if ($pmDisplayview_rule->getFromDB($parm->fields['id'])) {
         if ($pmDisplayview->getFromDB($pmDisplayview_rule->fields['plugin_monitoring_displayviews_id'])) {
             // Load right entity
             $default_entity = 0;
             if (isset($_SESSION['glpiactive_entity'])) {
                 $default_entity = $_SESSION['glpiactive_entity'];
             }
             $entities_isrecursive = 0;
             if (isset($_SESSION['glpiactiveentities']) and count($_SESSION['glpiactiveentities']) > 1) {
                 $entities_isrecursive = 1;
             }
             Session::changeActiveEntities($pmDisplayview->fields['entities_id'], $pmDisplayview->fields['is_recursive']);
             $get_tmp = '';
             $itemtype = $pmDisplayview_rule->fields['itemtype'];
             if (isset($_GET)) {
                 $get_tmp = $_GET;
             }
             if (isset($_SESSION["glpisearchcount"][$pmDisplayview_rule->fields['itemtype']])) {
                 unset($_SESSION["glpisearchcount"][$pmDisplayview_rule->fields['itemtype']]);
             }
             if (isset($_SESSION["glpisearchcount2"][$pmDisplayview_rule->fields['itemtype']])) {
                 unset($_SESSION["glpisearchcount2"][$pmDisplayview_rule->fields['itemtype']]);
             }
             $_GET = importArrayFromDB($pmDisplayview_rule->fields['condition']);
             $_GET["glpisearchcount"] = count($_GET['field']);
             if (isset($_GET['field2'])) {
                 $_GET["glpisearchcount2"] = count($_GET['field2']);
             }
             $params = Search::manageParams($pmDisplayview_rule->fields['itemtype'], $_GET);
             //            Search::manageGetValues($pmDisplayview_rule->fields['itemtype']);
             $queryd = "SELECT * FROM `glpi_plugin_monitoring_displayviews_items`\n               WHERE `plugin_monitoring_displayviews_id`='" . $pmDisplayview_rule->fields["plugin_monitoring_displayviews_id"] . "'\n                  AND `itemtype`='" . $pmDisplayview_rule->fields['type'] . "'\n                  AND `extra_infos`='" . $pmDisplayview_rule->fields['itemtype'] . "'";
             $result = $DB->query($queryd);
             while ($data = $DB->fetch_array($result)) {
                 $devices_present[$data['items_id']] = $data['id'];
             }
             $glpilist_limit = $_SESSION['glpilist_limit'];
             $_SESSION['glpilist_limit'] = 500000;
             $result = $pmSearch->constructSQL($itemtype, $_GET);
             $_SESSION['glpilist_limit'] = $glpilist_limit;
             while ($data = $DB->fetch_array($result)) {
                 if (!isset($devices_present[$data['id']])) {
                     // Verify this device has one or more resources
                     $query_h = "SELECT * FROM `glpi_plugin_monitoring_componentscatalogs_hosts`" . " LEFT JOIN `glpi_plugin_monitoring_services`" . "    ON `plugin_monitoring_componentscatalogs_hosts_id`=" . " `glpi_plugin_monitoring_componentscatalogs_hosts`.`id`" . " WHERE `items_id`='" . $data['id'] . "'" . "    AND `itemtype`='" . $pmDisplayview_rule->fields['itemtype'] . "'" . "    AND `glpi_plugin_monitoring_services`.`id` IS NOT NULL";
                     $result_h = $DB->query($query_h);
                     if ($DB->numrows($result_h) > 0) {
                         $input = array();
                         $input['plugin_monitoring_displayviews_id'] = $pmDisplayview_rule->fields["plugin_monitoring_displayviews_id"];
                         $input['x'] = '1';
                         $input['y'] = '1';
                         $input['items_id'] = $data['id'];
                         $input['itemtype'] = $pmDisplayview_rule->fields['type'];
                         $input['extra_infos'] = $pmDisplayview_rule->fields['itemtype'];
                         $pmDisplayview_item->add($input);
                     }
                 } else {
                     // Verify this device has one or more resources
                     $query_h = "SELECT * FROM `glpi_plugin_monitoring_componentscatalogs_hosts`" . " LEFT JOIN `glpi_plugin_monitoring_services`" . "    ON `plugin_monitoring_componentscatalogs_hosts_id`=" . " `glpi_plugin_monitoring_componentscatalogs_hosts`.`id`" . " WHERE `items_id`='" . $data['id'] . "'" . "    AND `itemtype`='" . $pmDisplayview_rule->fields['itemtype'] . "'" . "    AND `glpi_plugin_monitoring_services`.`id` IS NOT NULL";
                     $result_h = $DB->query($query_h);
                     if ($DB->numrows($result_h) > 0) {
                         unset($devices_present[$data['id']]);
                     }
                 }
             }
             // Reload current entity
             Session::changeActiveEntities($default_entity, $entities_isrecursive);
         } else {
             $pmDisplayview->delete(array('id' => $pmDisplayview_rule->fields['plugin_monitoring_displayviews_id']));
         }
     }
     foreach ($devices_present as $id) {
         $pmDisplayview_item->delete(array('id' => $id));
     }
     return true;
 }
Ejemplo n.º 9
0
            unset($_GET['glpi_tab']);
        }
        Search::manageGetValues("PluginMonitoringService");
        Search::showGenericSearch("PluginMonitoringService", $_GET);
        $_SESSION['plugin_monitoring']['service'] = $_GET;
        $pmDisplay->showBoard(950);
        if (isset($_SESSION['glpisearch']['PluginMonitoringService']['reset'])) {
            unset($_SESSION['glpisearch']['PluginMonitoringService']['reset']);
        }
        break;
    case 4:
        PluginMonitoringCanvas::onload();
        $pmCanvas = new PluginMonitoringCanvas();
        $pmCanvas->show();
        break;
    default:
        $i = 5;
        foreach ($a_views as $views_id => $name) {
            if ($_REQUEST['glpi_tab'] == $i) {
                if ($_SESSION['plugin_monitoring_displaytab'] != $_POST['glpi_tab']) {
                    echo '<script language="javascript">window.location.reload();</script>';
                    exit;
                }
                $pmDisplayview_item = new PluginMonitoringDisplayview_item();
                $pmDisplayview_item->view($views_id);
            }
            $i++;
        }
        break;
}
ajaxFooter();
  @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::checkRight("plugin_monitoring_displayview", READ);
Html::header(__('Monitoring', 'monitoring'), $_SERVER["PHP_SELF"], "plugins", "monitoring", "displayview_item");
$pmDisplayview_item = new PluginMonitoringDisplayview_item();
if (isset($_POST['plugin_monitoring_services_id']) and $_POST['plugin_monitoring_services_id'] > 0) {
    $_POST['items_id'] = $_POST['plugin_monitoring_services_id'];
    $_POST['itemtype'] = "PluginMonitoringService";
}
if (isset($_POST["add"])) {
    if ($_POST['itemtype'] == 'host' || $_POST['itemtype'] == 'service') {
        $input = $_POST;
        $input['itemtype'] = $_POST['type'];
        $input['type'] = $_POST['itemtype'];
        $input['condition'] = exportArrayToDB(array('name' => '', 'itemtype' => $input['itemtype'], 'field' => array(1), 'searchtype' => array('contains')));
        $pmDisplayview_rule = new PluginMonitoringDisplayview_rule();
        $pmDisplayview_rule->add($input);
    } else {
        $pmDisplayview_item->add($_POST);
    }
  @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', 'monitoring'), $_SERVER["PHP_SELF"], "plugins", "PluginMonitoringDashboard", "dashboard");
$pmDisplay = new PluginMonitoringDisplay();
$pmDisplayview = new PluginMonitoringDisplayview();
$pmDisplayview_item = new PluginMonitoringDisplayview_item();
$pmMessage = new PluginMonitoringMessage();
$pmMessage->getMessages();
$pmDisplay->menu();
$pass = 0;
$a_views = $pmDisplayview->getViews();
if (isset($a_views[$_GET['id']])) {
    $pmDisplayview->getFromDB($_GET['id']);
    $pass = $pmDisplayview->haveVisibilityAccess();
}
if ($pass == 0) {
    Session::checkRight("plugin_monitoring_displayview", READ);
}
if (isset($a_views[$_GET['id']])) {
    $pmDisplayview_item->view($_GET['id']);
} else {
Ejemplo n.º 12
0
    /**
     * 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>";
    }