Example #1
0
 /**
  * Vytvoří nového hosta patřícího rovnou do výchozí skupiny uživatele
  *
  * @param array $data asiciativní pole dat
  *
  * @return int|null id nově vloženého řádku nebo null, pokud se data
  * nepovede vložit
  */
 public function insertToMySQL($data = null)
 {
     if (!is_null($data)) {
         $this->takeData($data);
     }
     $hostgroup = new IEHostgroup($this->user->getUserLogin());
     $this->addMember('hostgroups', $hostgroup->getId(), $hostgroup->getName());
     return parent::insertToMySQL();
 }
$host = new IEHost();
$host->owner =& $oUser;
if ($hostName && $platform) {
    $host->setData(array($host->userColumn => $oUser->getUserID(), 'host_name' => $hostName, 'use' => 'generic-host', 'platform' => 'generic', 'register' => true, 'generate' => TRUE, 'platform' => $platform, 'alias' => $hostName, 'active_checks_enabled' => 0, 'passive_checks_enabled' => 1, 'check_freshness' => 1, 'freshness_threshold' => 900, 'flap_detection_enabled' => 0, 'check_command' => 'return-unknown'));
    if ($host_group) {
        $hostgroup = new IEHostgroup($host_group);
        $host->addMember('hostgroups', $hostgroup->getId(), $hostgroup->getName());
        $hostgroup->addMember('members', $host->getId(), $host->getName());
        $hostgroup->saveToMySQL();
    }
    if ($host->saveToMysql()) {
        $hostGroup = new IEHostgroup();
        if ($hostGroup->loadDefault()) {
            $hostGroup->setDataValue($hostGroup->nameColumn, EaseShared::user()->getUserLogin());
            $hostGroup->addMember('members', $host->getId(), $host->getName());
            $hostGroup->saveToMySQL();
            $host->addMember('hostgroups', $hostGroup->getId(), $hostGroup->getName());
            $host->saveToMysql();
        }
        $oPage->redirect('host.php?host_id=' . $host->getId());
        exit;
    }
} else {
    if ($oPage->isPosted()) {
        $oPage->addStatusMessage(_('Prosím zastejte název sledovaného hosta'), 'warning');
    }
}
$oPage->addItem(new IEPageTop(_('Průvodce založením hosta')));
$oPage->container->addItem(new EaseTWBPanel(_('Nový pasivně sledovaný host'), 'info', new IEPassiveCheckedHostForm('passive')));
$oPage->addItem(new IEPageBottom());
$oPage->draw();
Example #3
0
             $host->loadFromSQL((int) $gmID);
             $host->addMember('contacts', $contact->getId(), $contact->getName());
             if ($host->saveToMySQL()) {
                 $host->addStatusMessage(sprintf(_('<strong>%s</strong> byl přidán mezi kontakty <strong>%s</strong>'), $contact->getName(), $host->getName()), 'success');
             } else {
                 $host->addStatusMessage(sprintf(_('<strong>%s</strong> nebyl přidán mezi kontakty <strong>%s</strong>'), $contact->getName(), $host->getName()), 'warning');
             }
         }
     } else {
         $hostgroup->addStatusMessage(_('Chyba přiřazení kontaktu'), 'warning');
     }
     break;
 default:
     if ($oPage->isPosted()) {
         $hostgroup->takeData($_POST);
         if (!$hostgroup->getId()) {
             $hostgroup->setDataValue('members', array());
         }
         $hostgroupID = $hostgroup->saveToMySQL();
         if (is_null($hostgroupID)) {
             $oUser->addStatusMessage(_('Skupina hostů nebyla uložena'), 'warning');
         } else {
             $oUser->addStatusMessage(_('Skupina hostů byla uložena'), 'success');
         }
         $hostgroup->saveMembers();
     }
     $delete = $oPage->getGetValue('delete', 'bool');
     if ($delete == 'true') {
         $hostgroup->delete();
         $oPage->redirect('hostgroups.php');
         exit;
Example #4
0
 function fixHostHostgroupID()
 {
     $hostgroupsOK = array();
     $hostgroupsErr = array();
     $host = new IEHost();
     $hostgroup = new IEHostgroup();
     $hosts = $host->getColumnsFromMySQL(array($host->myKeyColumn));
     foreach ($hosts as $hostInfo) {
         $hostId = intval(current($hostInfo));
         $host->loadFromMySQL($hostId);
         $hostgroupNames = $host->getDataValue('hostgroups');
         if ($hostgroupNames) {
             foreach ($hostgroupNames as $hostgroupId => $hostgroupName) {
                 $hostgroupFound = $hostgroup->loadFromMySQL($hostgroupName);
                 if ($hostgroupId != $hostgroup->getId()) {
                     if ($host->delMember('hostgroups', $hostgroupId, $hostgroupName) && $host->addMember('hostgroups', $hostgroup->getId(), $hostgroupName)) {
                         $hostgroupsOK[] = $hostgroupName;
                     } else {
                         $hostgroupsErr[] = $hostgroupName;
                     }
                 }
             }
         }
         if (count($hostgroupsOK)) {
             if ($host->saveToMySQL()) {
                 $this->addItemSmart(sprintf(_('<strong>%s</strong> : %s'), $host->getName(), implode(',', $hostgroupsOK)), array('class' => 'list-group-item'));
                 $this->addStatusMessage(sprintf(_('%s : %s'), $host->getName(), implode(',', $hostgroupsOK)), 'success');
                 $hostgroupsOK = array();
             }
         }
     }
 }
Example #5
0
    if (!$ip) {
        $destHost = new IEHost($oPage->getRequestValue('dest_host_id', 'int'));
        $ip = $destHost->getDataValue('address');
    }
    $forceIP = true;
} else {
    $forceIP = false;
}
if (is_null($hostId) || !$ip) {
    $oPage->container->addItem(endRouteForm($host));
} else {
    $defaultContactId = $oUser->getDefaultContact()->getId();
    $defaultContactName = $oUser->getDefaultContact()->getName();
    $hgName = sprintf(_('Cesta k %s'), $host->getName());
    $hostGroup = new IEHostgroup($hgName);
    if ($hostGroup->getId()) {
    } else {
        $hostGroup->setUpUser($oUser);
        $hostGroup->setName($hgName);
    }
    $listing = new EaseHtmlOlTag();
    $infopanel = $oPage->container->addItem(new EaseTWBPanel($hostGroup->getName(), 'info', $listing));
    $trace = array();
    //??? $mtr = shell_exec('mtr -4 --no-dns -c 1 -p   ' . $ip);
    $mtr = shell_exec('traceroute -n -w 1 ' . $ip);
    $mtrlines = explode("\n", $mtr);
    foreach ($mtrlines as $mtrline) {
        $linea = explode(' ', trim($mtrline));
        if ($linea[0] == 'traceroute' || !isset($linea[2])) {
            continue;
        }