Ejemplo n.º 1
0
 function sendRestartArbiter($force = 0)
 {
     $pmTag = new PluginMonitoringTag();
     $pmLog = new PluginMonitoringLog();
     $a_tags = $pmTag->find();
     foreach ($a_tags as $data) {
         if (!$pmLog->isRestartLessThanFiveMinutes() || $force) {
             $url = 'http://' . $data['ip'] . ':7760/';
             $action = 'restart';
             $a_fields = array();
             $auth = $pmTag->getAuth($data['tag']);
             $restart = $this->sendCommand($url, $action, $a_fields, '', $auth);
             if ($restart) {
                 $input = array();
                 $input['user_name'] = $_SESSION['glpifirstname'] . ' ' . $_SESSION['glpirealname'] . ' (' . $_SESSION['glpiname'] . ')';
                 $input['action'] = "restart_planned";
                 $input['date_mod'] = date("Y-m-d H:i:s");
                 $pmLog->add($input);
             }
         }
     }
 }
 function sendRestartArbiter($force = 0, $tag = 0, $command = 'reload')
 {
     $pmTag = new PluginMonitoringTag();
     $pmLog = new PluginMonitoringLog();
     if (!$pmLog->isRestartLessThanFiveMinutes() || $force) {
         if ($tag > 0) {
             $pmTag->getFromDB($tag);
             $url = 'http://' . $pmTag->fields['ip'] . ':' . $pmTag->fields['port'] . '/';
             $auth = $pmTag->getAuth($pmTag->fields['tag']);
             if ($this->sendCommand($url, $command, array(), '', $auth)) {
                 $input = array();
                 $input['user_name'] = $_SESSION['glpifirstname'] . ' ' . $_SESSION['glpirealname'] . ' (' . $_SESSION['glpiname'] . ')';
                 $input['action'] = $command . "_planned";
                 $input['date_mod'] = date("Y-m-d H:i:s");
                 $input['value'] = $pmTag->fields['tag'];
                 $pmLog->add($input);
             }
         } else {
             $a_tagsBrut = $pmTag->find();
             $a_tags = array();
             foreach ($a_tagsBrut as $data) {
                 if (!isset($a_tags[$data['ip'] . ':' . $data['port']])) {
                     $a_tags[$data['ip'] . ':' . $data['port']] = $data;
                 }
             }
             foreach ($a_tags as $data) {
                 // TODO : should be parameters ... Shinken arbiter may use another port and may use HTTPS !
                 $url = 'http://' . $data['ip'] . ':' . $data['port'] . '/';
                 $auth = $pmTag->getAuth($data['tag']);
                 if ($this->sendCommand($url, $command, array(), '', $auth)) {
                     $input = array();
                     $input['user_name'] = $_SESSION['glpifirstname'] . ' ' . $_SESSION['glpirealname'] . ' (' . $_SESSION['glpiname'] . ')';
                     $input['action'] = $command . "_planned";
                     $input['date_mod'] = date("Y-m-d H:i:s");
                     $input['value'] = $data['tag'];
                     $pmLog->add($input);
                 }
             }
         }
     }
 }
Ejemplo n.º 3
0
   static function methodShinkenHosts($params, $protocol) {
      if (!isset($params['tag'])) {
         $params['tag'] = '';
      }

      // Update ip with Tag
      if (isset($_SERVER['REMOTE_ADDR'])) {
         $pmTag = new PluginMonitoringTag();
         $pmTag->setIP($params['tag'], $_SERVER['REMOTE_ADDR']);
      }

      $pmShinken = new PluginMonitoringShinken();
      $array = $pmShinken->generateHostsCfg(0, $params['tag']);
      return $array;
   }
 /**
  * Restart Shinken buttons :
  * - on main Monitoring plugin page
  * - one button per each declared Shinken tag
  * - one button to restart all Shinken instances
  *
  * @global type $CFG_GLPI
  */
 static function restartShinken()
 {
     global $CFG_GLPI;
     if (Session::haveRight("plugin_monitoring_restartshinken", CREATE)) {
         $pmTag = new PluginMonitoringTag();
         $a_tagsBrut = $pmTag->find();
         $a_tags = array();
         foreach ($a_tagsBrut as $data) {
             if (!isset($a_tags[$data['ip'] . ':' . $data['port']])) {
                 $a_tags[$data['ip'] . ':' . $data['port']] = $data;
             }
         }
         if (count($a_tags) > 0) {
             $shinken_commands = ['reload' => ['command' => 'reload', 'title' => __('Reload Shinken configuration from Glpi database', 'monitoring'), 'button' => __('Reload Shinken config', 'monitoring')], 'restart' => ['command' => 'restart', 'title' => __('Restart all Shinken daemons', 'monitoring'), 'button' => __('Restart Shinken', 'monitoring')]];
             foreach ($shinken_commands as $command) {
                 echo "<table class='tab_cadre_fixe' width='950'>";
                 echo "<tr class='tab_bg_1'>";
                 echo "<th width='400'>";
                 echo $command['title'] . ' : ';
                 echo '</th>';
                 echo '<td> | ';
                 echo "<a href='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/restartshinken.form.php?action=" . $command['command'] . "&tag=0'>" . __('All instances', 'monitoring') . "</a> | ";
                 if (count($a_tags) > 1) {
                     foreach ($a_tags as $taginfo => $data) {
                         echo "<a href='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/restartshinken.form.php?action=" . $command['command'] . "&tag=" . $data['id'] . "'>" . $taginfo . "</a> | ";
                     }
                 }
                 echo '</td>';
                 echo '</tr>';
                 echo '</table>';
             }
             echo '<br/>';
         }
     }
 }
  @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

  ------------------------------------------------------------------------
*/
include "../../../inc/includes.php";
Session::checkRight("plugin_monitoring_tag", READ);
Html::header(__('Monitoring', 'monitoring'), $_SERVER["PHP_SELF"], "plugins", "PluginMonitoringDashboard", "tag");
$pmTag = new PluginMonitoringTag();
if (isset($_POST["add"])) {
    $pmTag->add($_POST);
    Html::back();
} else {
    if (isset($_POST["update"])) {
        $pmTag->update($_POST);
        Html::back();
    } else {
        if (isset($_POST["purge"])) {
            $pmTag->getFromDB($_POST['id']);
            if ($pmTag->fields['tag'] != '') {
                $pmTag->delete($_POST);
                $pmTag->redirectToList();
            }
            Html::back();
 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')));
 }
Ejemplo n.º 7
0
  @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";
PluginMonitoringProfile::checkRight("command", "w");
Html::header(__('Monitoring', 'monitoring'), $_SERVER["PHP_SELF"], "plugins", "monitoring", "tag");
$pmTag = new PluginMonitoringTag();
if (isset($_POST["add"])) {
    $pmTag->add($_POST);
    Html::back();
} else {
    if (isset($_POST["update"])) {
        $pmTag->update($_POST);
        Html::back();
    } else {
        if (isset($_POST["delete"])) {
            if ($_POST['tag'] != '') {
                $pmTag->delete($_POST);
                $pmTag->redirectToList();
            }
            Html::back();
        }
Ejemplo n.º 8
0
Html::header(__('Monitoring - dashboard', 'monitoring'), $_SERVER["PHP_SELF"], "plugins",
             "PluginMonitoringDashboard", "menu");

$pmMessage = new PluginMonitoringMessage();
$pmMessage->getMessages();

$toDisplayArea=0;

// Restart Shinken buttons :
// - on main Monitoring plugin page
// - one button per each declared Shinken tag
// - one button to restart all Shinken instances
if (Session::haveRight("plugin_monitoring_restartshinken", CREATE)) {
   echo '<div style="position: absolute; float: left; width: 30%; max-width: 300px; background: #ccc; border: outset 2px white; padding: 0.5%;">';

   $pmTag = new PluginMonitoringTag();
   $a_tagsBrut = $pmTag->find();

   $a_tags = array();
   foreach ($a_tagsBrut as $data) {
      if (!isset($a_tags[$data['ip'].':'.$data['port']])) {
         $a_tags[$data['ip'].':'.$data['port']] = $data;
      }
   }

   if (count($a_tags) > 0) {
      $shinken_commands = [
            'reload'    => [
                  'command' => 'reload',
                  'title' => __('Reconfigure Shinken from Glpi database', 'monitoring'),
                  'button' => __('Reconfigure Shinken', 'monitoring'),
  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-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();
$pmTag = new PluginMonitoringTag();
$pmDisplay->menu();
$pmTag->servers_status();
Html::footer();