function defineTabs($options = array()) { global $LANG, $CFG_GLPI; if (isset($_GET['glpi_tab'])) { setActiveTab("PluginMonitoringDisplay", $_GET['glpi_tab']); } $pmDisplayview = new PluginMonitoringDisplayview(); $ong = array(); if (PluginMonitoringProfile::haveRight("servicescatalog", 'r')) { $ong[1] = $LANG['plugin_monitoring']['servicescatalog'][0]; } if (PluginMonitoringProfile::haveRight("componentscatalog", 'r')) { $ong[2] = $LANG['plugin_monitoring']['componentscatalog'][0]; } $ong[3] = $LANG['plugin_monitoring']['service'][21]; $ong[4] = $LANG['plugin_monitoring']['host'][1]; if (PluginMonitoringProfile::haveRight("view", 'r')) { $i = 5; $a_views = $pmDisplayview->getViews(); foreach ($a_views as $name) { $ong[$i] = htmlentities($name); $i++; } } return $ong; }
function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) { $array_ret = array(); if (PluginMonitoringProfile::haveRight("servicescatalog", 'r')) { $array_ret[49] = self::createTabEntry(__('Monitoring', 'monitoring') . "-" . __('Services catalog', 'monitoring')); } return $array_ret; }
function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) { $array_ret = array(); if ($item->getID() > -1) { if (PluginMonitoringProfile::haveRight("config", 'r')) { $array_ret[0] = self::createTabEntry(__('Monitoring', 'monitoring')); } } return $array_ret; }
static function getMessages() { global $CFG_GLPI; $pmMessage = new self(); // Display if shinken is in restart or if restarted less than 5 minutes echo "<div id='shikenrestart'></div>"; echo "<script type=\"text/javascript\">\n var elshikenrestart = Ext.get(\"shikenrestart\");\n var mgrshikenrestart = elshikenrestart.getUpdateManager();\n mgrshikenrestart.loadScripts=true;\n mgrshikenrestart.showLoadIndicator=false;\n mgrshikenrestart.startAutoRefresh(20, \"" . $CFG_GLPI["root_doc"] . "/plugins/monitoring/ajax/updateshinkenrestartmessage.php\", \"\", \"\", true);"; echo "</script>"; $servicecatalog = ''; $confchanges = ''; if (PluginMonitoringProfile::haveRight("servicescatalog", 'w')) { $servicecatalog = $pmMessage->servicescatalogMessage(); } $confchanges = $pmMessage->configurationchangesMessage(); $runningshinken = $pmMessage->ShinkennotrunMessage(); $i = 0; if ($servicecatalog != '' or $confchanges != '') { echo "<div class='msgboxmonit msgboxmonit-orange'>"; if ($confchanges != '') { echo $confchanges; $i++; } if ($servicecatalog != '') { if ($i > 0) { echo "</div>"; echo "<div class='msgboxmonit msgboxmonit-orange'>"; } echo $servicecatalog; $i++; } if ($runningshinken != '') { if ($i > 0) { echo "</div>"; echo "<div class='msgboxmonit msgboxmonit-red'>"; } echo $runningshinken . "!"; $i++; } echo "</div>"; } }
static function getMessages() { $pmMessage = new self(); $servicecatalog = ''; $confchanges = ''; if (PluginMonitoringProfile::haveRight("servicescatalog", 'w')) { $servicecatalog = $pmMessage->servicescatalogMessage(); } $confchanges = $pmMessage->configurationchangesMessage(); $runningshinken = $pmMessage->ShinkennotrunMessage(); $i = 0; if ($servicecatalog != '' or $confchanges != '') { echo "<div class='msgboxmonit msgboxmonit-orange'>"; if ($confchanges != '') { echo $confchanges; $i++; } if ($servicecatalog != '') { if ($i > 0) { echo "</div>"; echo "<div class='msgboxmonit msgboxmonit-orange'>"; } echo $servicecatalog; $i++; } if ($runningshinken != '') { if ($i > 0) { echo "</div>"; echo "<div class='msgboxmonit msgboxmonit-red'>"; } echo $runningshinken . "!"; $i++; } echo "</div>"; } }
@package Plugin Monitoring for GLPI @author David Durieux @co-author @comment @copyright Copyright (c) 2011-2013 Plugin Monitoring for GLPI team @license AGPL License 3.0 or (at your option) any later version http://www.gnu.org/licenses/agpl-3.0-standalone.html @link https://forge.indepnet.net/projects/monitoring/ @since 2011 ------------------------------------------------------------------------ */ include "../../../inc/includes.php"; Session::checkCentralAccess(); Html::header(__('Monitoring', 'monitoring'), $_SERVER["PHP_SELF"], "plugins", "monitoring", "services"); $pmService = new PluginMonitoringService(); if (isset($_POST['update'])) { foreach ($_POST['arg'] as $key => $value) { if ($value == '') { unset($_POST['arg'][$key]); } } $_POST['arguments'] = exportArrayToDB($_POST['arg']); $pmService->update($_POST); Html::back(); } if (PluginMonitoringProfile::haveRight("componentscatalog", 'w')) { $pmService->showCustomArguments($_GET['id']); } Html::footer();
function plugin_get_headings_monitoring($item, $withtemplate) { global $LANG; switch (get_class($item)) { case 'Computer': case 'Device': case 'Printer': case 'NetworkEquipment': $array = array(); //$array[0] = $LANG['plugin_monitoring']['title'][0]."-".$LANG['state'][0]; if ($_GET['id'] > 0) { $array[2] = $LANG['plugin_monitoring']['title'][0] . "-" . $LANG['plugin_monitoring']['service'][0]; } return $array; break; case 'User': $array = array(); //$array[0] = $LANG['plugin_monitoring']['title'][0]."-".$LANG['state'][0]; if ($_GET['id'] > 0) { $array[1] = $LANG['plugin_monitoring']['title'][0] . "-" . $LANG['plugin_monitoring']['contact'][0]; } return $array; break; case 'PluginMonitoringServicescatalog': $array = array(); if ($_GET['id'] > 0) { if (PluginMonitoringProfile::haveRight("servicescatalog", 'r')) { $array[0] = $LANG['plugin_monitoring']['businessrule'][12]; } } return $array; break; case 'Entity': $array = array(); if (PluginMonitoringProfile::haveRight("config", 'r')) { $array[0] = $LANG['plugin_monitoring']['title'][0]; } return $array; break; case 'Central': if (isset($_SESSION['glpi_tabs']['central'])) { $_SESSION['plugin_monitoring_displaytab'] = $_SESSION['glpi_tabs']['central']; } else { $_SESSION['plugin_monitoring_displaytab'] = ''; } $array = array(); if (PluginMonitoringProfile::haveRight("servicescatalog", 'r')) { $array[0] = $LANG['plugin_monitoring']['title'][0] . "-" . $LANG['plugin_monitoring']['servicescatalog'][0]; } if (PluginMonitoringProfile::haveRight("viewshomepage", 'r')) { $pmDisplayview = new PluginMonitoringDisplayview(); $i = 5; $a_views = $pmDisplayview->getViews(1); foreach ($a_views as $name) { $array[$i] = $LANG['plugin_monitoring']['title'][0] . "-" . htmlentities($name); $i++; } } return $array; break; case 'Profile': $array = array(); if ($_GET['id'] > 0) { $array[0] = $LANG['plugin_monitoring']['title'][0]; } return $array; break; } return false; }
function canView() { return PluginMonitoringProfile::haveRight("servicescatalog", 'r'); }
static function displayLine($data, $displayhost = 1) { global $DB, $CFG_GLPI; $pMonitoringService = new PluginMonitoringService(); $networkPort = new NetworkPort(); $pMonitoringComponent = new PluginMonitoringComponent(); $pmComponentscatalog_Host = new PluginMonitoringComponentscatalog_Host(); $entity = new Entity(); $pMonitoringService->getFromDB($data['id']); echo "<td width='32' class='center'>"; $shortstate = self::getState($data['state'], $data['state_type'], $data['event'], $data['is_acknowledged']); $alt = __('Ok', 'monitoring'); if ($shortstate == 'orange') { $alt = __('Warning (data)', 'monitoring'); } else { if ($shortstate == 'yellow') { $alt = __('Warning (connection)', 'monitoring'); } else { if ($shortstate == 'red') { $alt = __('Critical', 'monitoring'); } else { if ($shortstate == 'redblue') { $alt = __('Critical / Acknowledge', 'monitoring'); } } } } echo "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/pics/box_" . $shortstate . "_32.png'\n title='" . $alt . "' alt='" . $alt . "' />"; echo "</td>"; echo "<td>"; $entity->getFromDB($data['entities_id']); echo $entity->fields['completename']; echo "</td>"; $pMonitoringComponent->getFromDB($data['plugin_monitoring_components_id']); echo "<td class='center'>"; $timezone = '0'; if (isset($_SESSION['plugin_monitoring_timezone'])) { $timezone = $_SESSION['plugin_monitoring_timezone']; } if ($pMonitoringComponent->fields['graph_template'] != '') { echo "<a href='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/display.form.php?itemtype=PluginMonitoringService&items_id=" . $data['id'] . "'>"; $pmServicegraph = new PluginMonitoringServicegraph(); ob_start(); $pmServicegraph->displayGraph($pMonitoringComponent->fields['graph_template'], "PluginMonitoringService", $data['id'], "0", '2h', "div", "600"); $div = ob_get_contents(); ob_end_clean(); $chart = "<table width='600' class='tab_cadre'><tr><td>" . $div . "</td></tr></table>"; Html::showToolTip($chart, array('img' => $CFG_GLPI['root_doc'] . "/plugins/monitoring/pics/stats_32.png")); $pmServicegraph->displayGraph($pMonitoringComponent->fields['graph_template'], "PluginMonitoringService", $data['id'], "0", '2h', "js"); } echo "</a>"; echo "</td>"; if ($displayhost == '1') { $pmComponentscatalog_Host->getFromDB($data["plugin_monitoring_componentscatalogs_hosts_id"]); if (isset($pmComponentscatalog_Host->fields['itemtype']) and $pmComponentscatalog_Host->fields['itemtype'] != '') { $itemtype = $pmComponentscatalog_Host->fields['itemtype']; $item = new $itemtype(); $item->getFromDB($pmComponentscatalog_Host->fields['items_id']); echo "<td>"; echo $item->getTypeName() . " : " . $item->getLink(); if (!is_null($pMonitoringService->fields['networkports_id']) and $pMonitoringService->fields['networkports_id'] > 0) { $networkPort->getFromDB($pMonitoringService->fields['networkports_id']); echo " [" . $networkPort->getLink() . "]"; } echo "</td>"; } else { echo "<td>" . __('Resources', 'monitoring') . "</td>"; } } echo "<td>" . $pMonitoringComponent->getLink(); if (!is_null($pMonitoringService->fields['networkports_id']) and $pMonitoringService->fields['networkports_id'] > 0) { $networkPort->getFromDB($pMonitoringService->fields['networkports_id']); echo " [" . $networkPort->getLink() . "]"; } echo "</td>"; // $nameitem = ''; // if (isset($itemmat->fields['name'])) { // $nameitem = "[".$itemmat->getLink(1)."]"; // } //if ($pMonitoringService->fields['plugin_monitoring_services_id'] == '0') { //echo "<td>".$itemmat->getLink(1)."</td>"; // } else { // $pMonitoringServiceH->getFromDB($pMonitoringService->fields['plugin_monitoring_services_id']); // $itemtypemat = $pMonitoringServiceH->fields['itemtype']; // $itemmat = new $itemtypemat(); // $itemmat->getFromDB($pMonitoringServiceH->fields['items_id']); // echo "<td>".$pMonitoringService->getLink(1).$nameitem." ".__('on', 'monitoring')." ".$itemmat->getLink(1)."</td>"; // } // unset($itemmat); echo "<td class='center'>"; if ($shortstate == 'red') { echo "<table>"; echo "<tr>"; echo "<td>"; echo $data['state']; echo "</td>"; echo "<td>"; echo "<a href='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/acknowledge.form.php?id=" . $data['id'] . "'>" . "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/pics/acknowledge_checked.png'" . " alt='" . __('Define an acknowledge', 'monitoring') . "'" . " title='" . __('Define an acknowledge', 'monitoring') . "'/>" . "</a>"; echo "</td>"; echo "</tr>"; echo "</table>"; } else { echo $data['state']; } echo "</td>"; echo "<td>"; echo Html::convDate($data['last_check']) . ' ' . substr($data['last_check'], 11, 8); echo "</td>"; echo "<td>"; echo $data['event']; echo "</td>"; echo "<td align='center'>"; $segments = CalendarSegment::getSegmentsBetween($pMonitoringComponent->fields['calendars_id'], date('w', date('U')), date('H:i:s'), date('w', date('U')), date('H:i:s')); if (count($segments) == '0') { echo "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/pics/service_pause.png' />"; } else { echo "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/pics/service_run.png' />"; } echo "</td>"; if ($displayhost == '0') { $pmUnavaibility = new PluginMonitoringUnavaibility(); $pmUnavaibility->displayValues($pMonitoringService->fields['id'], 'currentmonth', 1); $pmUnavaibility->displayValues($pMonitoringService->fields['id'], 'lastmonth', 1); $pmUnavaibility->displayValues($pMonitoringService->fields['id'], 'currentyear', 1); echo "<td class='center'>"; echo "<a href='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/unavaibility.php?" . "field[0]=2&searchtype[0]=equals&contains[0]=" . $pMonitoringService->fields['id'] . "&sort=3&order=DESC&itemtype=PluginMonitoringUnavaibility'>\n <img src='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/pics/info.png'/></a>"; echo "</td>"; } echo "<td>"; if ($shortstate == 'redblue') { echo "<i>" . _n('User', 'Users', 1) . " : </i>"; $user = new User(); $user->getFromDB($data['acknowledge_users_id']); echo $user->getName(1); echo "<br/>"; echo "<i>" . __('Comments') . " : </i>" . $data['acknowledge_comment']; } echo "</td>"; if ($displayhost == '0') { echo "<td>"; if (PluginMonitoringProfile::haveRight("componentscatalog", 'w')) { $a_arg = importArrayFromDB($pMonitoringService->fields['arguments']); $cnt = ''; if (count($a_arg) > 0) { $cnt = " (" . count($a_arg) . ")"; } echo "<a href='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/servicearg.form.php?id=" . $data['id'] . "'>" . __('Configure', 'monitoring') . $cnt . "</a>"; } echo "</td>"; } }
function canUndo() { return PluginMonitoringProfile::haveRight("view", 'w'); }
static function canView() { return PluginMonitoringProfile::haveRight("config", 'r'); }
static function canView() { return PluginMonitoringProfile::haveRight("weathermap", 'r'); }
static function canView() { return PluginMonitoringProfile::haveRight("componentscatalog", 'r'); }
function canUndo() { return PluginMonitoringProfile::haveRight("componentscatalog", 'w'); }
function canUndo() { return PluginMonitoringProfile::haveRight("weathermap", 'w'); }
} echo "</th>"; echo "<th rowspan='2'>"; if (PluginMonitoringProfile::haveRight("config", 'r')) { echo "<a href='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/realm.php'>" . $LANG['plugin_monitoring']['realms'][0] . "</a>"; } echo "</th>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<th width='18%' height='25'>"; if (PluginMonitoringProfile::haveRight("command", 'r')) { echo "<a href='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/command.php'>" . $LANG['plugin_monitoring']['command'][0] . "</a>"; } echo "</th>"; echo "<th width='18%'>"; if (PluginMonitoringProfile::haveRight("check", 'r')) { echo "<a href='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/check.php'>" . $LANG['plugin_monitoring']['check'][0] . "</a>"; } echo "</th>"; echo "<th width='18%'>"; if (haveRight('calendar', 'r')) { echo "<a href='" . $CFG_GLPI['root_doc'] . "/front/calendar.php'>" . $LANG['buttons'][15] . "</a>"; } echo "</th>"; echo "<th width='18%'>"; if (PluginMonitoringProfile::haveRight("config", 'r')) { echo "<a href='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/rrdtemplate.php'>" . $LANG['plugin_monitoring']['rrdtemplates'][0] . "</a>"; } echo "</th>"; echo "</table>"; commonFooter();
function canCancel() { return PluginMonitoringProfile::haveRight("config", 'w'); }
static function checkRight($module, $right) { global $CFG_GLPI; if (!PluginMonitoringProfile::haveRight($module, $right)) { // Gestion timeout session if (!Session::getLoginUserID()) { Html::redirect($CFG_GLPI["root_doc"] . "/index.php"); exit; } Html::displayRightError(); } }
echo "</th>"; echo "<th rowspan='2'>"; if (PluginMonitoringProfile::haveRight("config", 'r')) { echo "<a href='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/tag.php'>" . __('Tag', 'monitoring') . "</a>"; } echo "</th>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<th width='15%' height='25'>"; if (PluginMonitoringProfile::haveRight("command", 'r')) { echo "<a href='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/command.php'>" . __('Commands', 'monitoring') . "</a>"; } echo "</th>"; echo "<th width='15%'>"; if (PluginMonitoringProfile::haveRight("check", 'r')) { echo "<a href='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/check.php'>" . __('Check definition', 'monitoring') . "</a>"; } echo "</th>"; echo "<th width='15%'>"; if (Session::haveRight('calendar', 'r')) { echo "<a href='" . $CFG_GLPI['root_doc'] . "/front/calendar.php'>" . __('Calendar') . "</a>"; } echo "</th>"; echo "<th width='15%'>"; if (PluginMonitoringProfile::haveRight("command", 'r')) { echo "<a href='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/eventhandler.php'>" . __('Event handler', 'monitoring') . "</a>"; } echo "</th>"; echo "</table>"; } Html::footer();