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);
                 }
             }
         }
     }
 }