Exemplo n.º 1
0
 /**
  * Naplní diagram
  */
 function fillUp()
 {
     $host = new IEHost();
     $hosts = $host->getListing(null, false, array('alias', 'address', 'parents', 'notifications_enabled', 'active_checks_enabled', 'passive_checks_enabled', $host->myCreateColumn, $host->myLastModifiedColumn));
     foreach ($hosts as $host => $host_info) {
         $name = $host_info['host_name'];
         if (!$name) {
             continue;
         }
         $alias = $host_info['alias'];
         if (!$alias) {
             $alias = $host_info['host_name'];
         }
         $color = '';
         if ($host_info['active_checks_enabled']) {
             $color = 'lightgreen';
         }
         if ($host_info['passive_checks_enabled']) {
             $color = 'lightblue';
         }
         $this->addNode($name, array('URL' => 'host.php?host_id=' . $host_info['host_id'], 'fontsize' => '10', 'color' => $color, 'height' => '0.2', 'width' => '2.1', 'fixedsize' => false, 'style' => 'filled', 'tooltip' => $host_info['address'], 'label' => $alias));
         if (isset($host_info['host_name'])) {
             if (is_array($host_info['parents'])) {
                 foreach ($host_info['parents'] as $parent_name) {
                     $this->addEdge(array($host_info['host_name'] => $parent_name));
                 }
             }
         }
     }
 }
 /**
  * Formulář pro potvrzení nasazení senzoru
  * @param IEHost $host
  */
 public function __construct($host)
 {
     parent::__construct('sensor');
     $this->addItem(new EaseHtmlInputHiddenTag('operation', 'confirm'));
     $this->addItem(new EaseHtmlInputHiddenTag($host->getmyKeyColumn(), $host->getId()));
     $this->addItem(new EaseTWSubmitButton(_('Senzor je nasazen')));
     $status = $host->getSensorStatus();
     $this->addItem(new IETWBSwitch('confirm', $status == 2));
 }
Exemplo n.º 3
0
/**
 * Formulář cíle cesty pro hosta
 * @param IEHost $host
 * @return \EaseTWBPanel
 */
function endRouteForm($host)
{
    $form = new EaseTWBForm('traceto');
    $form->addInput(new IEHostSelect('dest_host_id'), _('Gateway'), null, _('Zvolte již definovanou gateway, nabo zadejte konkrétní adresu.'));
    $form->addInput(new EaseHtmlInputTextTag('ip'), _('IP Adresa'), null, _('První pingnutelná veřejá adresa po cestě z hostu na monitorovací server'));
    $form->addItem(new EaseTWSubmitButton(_('Sledovat cestu'), 'success', array('onClick' => "\$('#preload').css('visibility', 'visible');")));
    EaseShared::webPage()->addItem(new EaseHtmlDivTag('preload', new IEFXPreloader(), array('class' => 'fuelux')));
    return new EaseTWBPanel(_('Volba cíle sledování') . ': ' . $host->getName(), 'default', $form, _('Vyberte hosta nebo zadejte IP adresu'));
}
Exemplo n.º 4
0
 /**
  * Uloží položky
  *
  * @param array $request
  */
 public static function saveMembers($request)
 {
     $host = new IEHost();
     if (isset($request[$host->myKeyColumn])) {
         if ($host->loadFromMySQL($request[$host->myKeyColumn])) {
             if (isset($request['addhost']) || isset($request['delhost'])) {
                 if (isset($request['addhost'])) {
                     $host->addMember('service_name', $request['service_id'], $request['service_name']);
                     if ($host->saveToMySQL()) {
                         $host->addStatusMessage(sprintf(_('položka %s byla přidána'), $request['addhost']), 'success');
                     } else {
                         $host->addStatusMessage(sprintf(_('položka %s nebyla přidána'), $request['addhost']), 'warning');
                     }
                 }
                 if (isset($request['delhost'])) {
                     $host->delMember('service_name', $request['service_id'], $request['service_name']);
                     if ($host->saveToMySQL()) {
                         $host->addStatusMessage(sprintf(_('položka %s byla odebrána'), $request['delhost']), 'success');
                     } else {
                         $host->addStatusMessage(sprintf(_('položka %s nebyla odebrána'), $request['delhost']), 'warning');
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 5
0
 /**
  * Naplní diagram
  */
 function fillUp()
 {
     $members = $this->hostgroup->getDataValue('members');
     $host = new IEHost();
     $hosts = $host->getColumnsFromMySQL(array('alias', 'address', 'parents', 'notifications_enabled', 'active_checks_enabled', 'passive_checks_enabled', '3d_coords', $host->myCreateColumn, $host->myLastModifiedColumn, $host->nameColumn, $host->myKeyColumn), 'host_id IN ( ' . implode(',', array_keys($members)) . ' )');
     foreach ($hosts as $hostNo => $host_info) {
         if (strstr($host_info['3d_coords'], ',')) {
             list($x, $y, $z) = explode(',', $host_info['3d_coords']);
         } else {
             $x = $y = 0;
         }
         if (strlen(trim($host_info['parents']))) {
             $host_info['parents'] = unserialize($host_info['parents']);
         }
         if (isset($host_info[$host->nameColumn])) {
             $name = $host_info[$host->nameColumn];
         } else {
             continue;
         }
         $alias = $host_info['alias'];
         $color = '';
         if ($host_info['active_checks_enabled']) {
             $color = 'lightgreen';
         }
         if ($host_info['passive_checks_enabled']) {
             $color = 'lightblue';
         }
         $this->addNode($name, array('id' => 'host_' . $host_info[$host->myKeyColumn], 'node_id' => $host_info[$host->myKeyColumn], 'color' => $color, 'x' => $x, 'y' => $y, 'fixed' => boolval($x + $y), 'shape' => 'point', 'style' => 'filled', 'tooltip' => $alias, 'label' => $name));
         if (isset($host_info[$host->nameColumn])) {
             if (is_array($host_info['parents'])) {
                 foreach ($host_info['parents'] as $parent_name) {
                     $this->addEdge(array($host_info[$host->nameColumn] => $parent_name));
                 }
             }
         }
     }
 }
Exemplo n.º 6
0
 /**
  * Editor k přidávání členů skupiny
  *
  * @param IEHost $host
  */
 public function __construct($host)
 {
     parent::__construct();
     $fieldName = $host->getmyKeyColumn();
     $initialContent = new EaseTWBPanel(_('rodiče hostu'));
     $addparentForm = $initialContent->addItem(new EaseTWBForm('addparent'));
     $addparentForm->addItem(new EaseTWBFormGroup(_('IP nebo Hostname'), new EaseHtmlInputTextTag('newparent')));
     $addparentForm->addItem(new EaseHtmlInputHiddenTag($fieldName, $host->getId()));
     $addparentForm->addItem(new EaseTWSubmitButton(_('Přidat rodiče'), 'success'));
     $initialContent->setTagCss(array('width' => '100%'));
     if (is_null($host->getMyKey())) {
         $initialContent->addItem(_('Nejprve je potřeba uložit záznam'));
     } else {
         $allParents = $host->getListing();
         unset($allParents[$host->getID()]);
         //Nenabízet sám sebe jako rodiče
         foreach ($allParents as $parentID => $parentInfo) {
             if ($parentInfo['register'] != 1) {
                 unset($allParents[$parentID]);
             }
         }
         $parentsAssigned = array();
         foreach ($host->getDataValue('parents') as $parentAssigned) {
             $parentID = EaseShared::myDbLink()->queryToValue('SELECT `' . $host->myKeyColumn . '` FROM ' . $host->myTable . ' WHERE `' . $host->nameColumn . '` = \'' . addSlashes($parentAssigned) . '\'');
             $parentsAssigned[$parentID][$host->nameColumn] = $parentAssigned;
             $parentsAssigned[$parentID][$host->myKeyColumn] = $parentID;
             unset($allParents[$parentID]);
         }
         if (count($allParents)) {
             foreach ($allParents as $parentID => $parentInfo) {
                 $initialContent->addItem($this->parentButton($parentInfo, 'plus', $host));
             }
         }
         if (count($parentsAssigned)) {
             $initialContent->addItem('</br>');
             foreach ($parentsAssigned as $parentID => $parentInfo) {
                 $initialContent->addItem($this->parentButton($parentInfo, 'remove', $host));
             }
         }
     }
     $this->addItem($initialContent);
 }
Exemplo n.º 7
0
 /**
  * Stav senzoru a jeho nastavení
  *
  * @param IEHost $host
  */
 public function __construct($host)
 {
     $commonWell = new EaseTWBWell();
     $commonRow = new EaseTWBRow();
     $hostColumn = $commonRow->addColumn(6, new EaseHtmlATag('host.php?host_id=' . $host->getId(), new EaseHtmlH1Tag($host->getName())));
     $hostColumn->addItem($host);
     $hostColumn->addItem($host->sensorStatusLabel());
     $commonWell->addItem($commonRow);
     $commonRow->addColumn(4, new EaseTWBPanel(_('Ruční nastavení stavu senzoru'), 'info', new IESensorConfirmForm($host)));
     $sensorTabs = new EaseTWBTabs('sensorTabs');
     switch ($host->getDataValue('platform')) {
         case 'windows':
             $pltIco = 'logos/base/win40.gif';
             $cfgGenerator = new IENSCPConfigGenerator($host);
             if ($host->getCfgValue('active_checks_enabled')) {
                 $windowsActiveTab = $sensorTabs->addTab(_('Windows NRPE'));
                 $windowsActiveTab->addItem(new EaseHtmlH1Tag('<img src="' . $pltIco . '">' . _('aktivní NRPE pro NSC++')));
                 $windowsActiveTab->addItem(new EaseTWBLinkButton('http://www.nsclient.org/download/', ' NSC++ ' . EaseTWBPart::GlyphIcon('download'), 'success', array('style' => "background-image:url('img/nscpp.png'); width: 212px; height: 60px; ", 'title' => 'Download')));
                 $windowsActiveTab->addItem(new EaseTWBLinkButton('host.php?action=populate&host_id=' . $host->getID(), _('Oskenovat a sledovat služby'), null, array('onClick' => "\$('#preload').css('visibility', 'visible');")));
                 $windowsActiveTab->addItem(new EaseTWBLinkButton('nscpcfggen.php?host_id=' . $host->getId(), $host->getName() . '_nscp.bat ' . EaseTWBPart::GlyphIcon('download'), 'success'));
                 $windowsActiveTab->addItem(new EaseTWBContainer('<pre>' . htmlspecialchars($cfgGenerator->getCfg(false)) . '</pre>', array('font-face' => 'fixed')));
             }
             if ($host->getCfgValue('passive_checks_enabled')) {
                 $windowsPassiveTab = $sensorTabs->addTab(_('Windows NSCA'));
                 $windowsPassiveTab->addItem(new EaseHtmlH1Tag('<img src="' . $pltIco . '">' . _('pasivní NSCA pro NSC++')));
                 $windowsPassiveTab->addItem(new EaseTWBLinkButton('http://www.nsclient.org/download/', ' NSC++ ' . EaseTWBPart::GlyphIcon('download'), 'success', array('style' => "background-image:url('img/nscpp.png'); width: 212px; height: 60px; ", 'title' => 'Download')));
                 $windowsPassiveTab->addItem(new EaseTWBLinkButton('nscpcfggen.php?host_id=' . $host->getId(), $host->getName() . '_nscp.bat ' . EaseTWBPart::GlyphIcon('download'), 'success'));
                 $windowsPassiveTab->addItem(new EaseTWBWell('<pre>' . htmlspecialchars($cfgGenerator->getCfg(false), ENT_QUOTES) . '</pre>', array('font-face' => 'fixed')));
             }
             break;
         case 'linux':
             $pltIco = 'logos/base/linux40.gif';
             $preferences = new IEPreferences();
             $prefs = $preferences->getPrefs();
             if ($host->getCfgValue('active_checks_enabled')) {
                 $nrpe_cfgGenerator = new IENRPEConfigGenerator($host);
                 $linuxActiveTab = $sensorTabs->addTab(_('Linux NRPE'));
                 $linuxActiveTab->addItem(new EaseHtmlH1Tag('<img src="' . $pltIco . '">' . _('aktivní NRPE pro NRPE Server')));
                 $linuxActiveTab->addItem(new EaseHtmlPTag(_('Nainstalujte nejprve senzor tímto příkazem') . ':'));
                 $linuxActiveTab->addItem(new EaseHtmlDiv('<pre>sudo aptitude -y install nagios-nrpe-server</pre>', array('class' => 'code')));
                 $linuxActiveTab->addItem(new EaseTWBLinkButton('nrpecfggen.php?host_id=' . $host->getId(), $host->getName() . '_nrpe.sh ' . EaseTWBPart::GlyphIcon('download'), 'success'));
                 $linuxActiveTab->addItem(new EaseTWBContainer('<pre>' . htmlspecialchars($nrpe_cfgGenerator->getCfg(false)) . '</pre>', array('font-face' => 'fixed')));
                 $linuxActiveTab->addItem(new EaseTWBLinkButton('host.php?action=populate&host_id=' . $host->getID(), _('Oskenovat a sledovat služby'), null, array('onClick' => "\$('#preload').css('visibility', 'visible');")));
             }
             if ($host->getCfgValue('passive_checks_enabled')) {
                 $linuxPassiveTab = $sensorTabs->addTab(_('Linux NSCA'));
                 $linuxPassiveTab->addItem(new EaseHtmlH1Tag('<img src="' . $pltIco . '">' . _('pasivní NSCA pro NSCP Senzor')));
                 $linuxPassiveTab->addItem(new EaseTWBLinkButton('nscpcfggen.php?host_id=' . $host->getId(), $host->getName() . '_nscp.sh ' . EaseTWBPart::GlyphIcon('download'), 'success'));
                 $cfgGenerator = new IENSCPConfigGenerator($host);
                 $linuxPassiveTab->addItem(new EaseTWBContainer('<pre>' . htmlspecialchars($cfgGenerator->getCfg(false)) . '</pre>', array('font-face' => 'fixed')));
             }
             break;
         default:
             $pltIco = 'logos/unknown.gif';
             if ($host->getCfgValue('active_checks_enabled')) {
                 $genericActiveTab = $sensorTabs->addTab(_('Generic Active'));
                 $genericActiveTab->addItem(new EaseTWBLinkButton('host.php?action=populate&host_id=' . $host->getID(), _('Oskenovat a sledovat služby'), null, array('onClick' => "\$('#preload').css('visibility', 'visible');")));
             }
             if ($host->getCfgValue('passive_checks_enabled')) {
                 $genericPassiveTab = $sensorTabs->addTab(_('Generic Passive'));
             }
             break;
     }
     parent::__construct($commonWell);
     $this->addItem($sensorTabs);
 }
Exemplo n.º 8
0
<?php

/**
 * Icinga Editor služby
 *
 * @package    IcingaEditor
 * @subpackage WebUI
 * @author     Vitex <*****@*****.**>
 * @copyright  2012 Vitex@hippy.cz (G)
 */
require_once 'includes/IEInit.php';
$oPage->onlyForLogged();
$service = new IEService($oPage->getRequestValue('service_id', 'int'));
$host = new IEHost($oPage->getRequestValue('host_id', 'int'));
switch ($oPage->getRequestValue('action')) {
    case 'clone':
        $service->setDataValue('parent_id', $service->getId());
        $service->unsetDataValue($service->getmyKeyColumn());
        $service->addMember('host_name', $host->getId(), $host->getName());
        $service->setDataValue('hostgroup_name', array());
        $service->setDataValue('user_id', $oUser->getID());
        $service->setDataValue($service->nameColumn, _('Klon') . ' ' . $service->getName());
        if ($service->saveToMySQL()) {
            $oUser->addStatusMessage(_('Služba byla naklonována'), 'success');
            $oPage->redirect('servicetweak.php?service_id=' . $service->getId() . '&host_id=' . $host->getId());
        } else {
            $oUser->addStatusMessage(_('Sužba nebyla naklonována'), 'warning');
        }
        break;
    case 'rename':
        $newname = $oPage->getRequestValue('newname');
Exemplo n.º 9
0
<?php

/**
 * Icinga Editor hosta
 *
 * @package    IcingaEditor
 * @subpackage WebUI
 * @author     Vitex <*****@*****.**>
 * @copyright  2012 Vitex@hippy.cz (G)
 */
require_once 'includes/IEInit.php';
$oPage->onlyForLogged();
$hostId = $oPage->getRequestValue('host_id', 'int');
$host = new IEHost($hostId);
switch ($oPage->getRequestValue('action')) {
    case 'applystemplate':
        $stemplate = new IEStemplate($oPage->getRequestValue('stemplate_id', 'int'));
        $services = $stemplate->getDataValue('services');
        if (count($services)) {
            $service = new IEService();
            foreach ($services as $service_id => $service_name) {
                $service->loadFromMySQL($service_id);
                $service->addMember('host_name', $host->getId(), $host->getName());
                $service->saveToMySQL();
                $service->dataReset();
            }
        }
        $contacts = $stemplate->getDataValue('contacts');
        if (count($contacts)) {
            foreach ($contacts as $contact_id => $contact_name) {
                $host->addMember('contacts', $contact_id, $contact_name);
Exemplo n.º 10
0
 /**
  * Smaže hostgrupu i její použití v hostech
  *
  * @param int $id
  * @return boolean
  */
 function delete($id = null)
 {
     if (isset($id) && $this->getId() != $id) {
         $this->loadFromSQL($id);
     } else {
         $id = $this->getId();
     }
     $host = new IEHost();
     $hosts = $host->getColumnsFromMySQL(array($host->myKeyColumn), array('hostgroups' => '%' . $this->getName() . '%'));
     foreach ($hosts as $hostInfo) {
         $hostId = intval(current($hostInfo));
         $host->loadFromMySQL($hostId);
         $hostgroupNames = $host->getDataValue('hostgroups');
         if ($hostgroupNames) {
             foreach ($hostgroupNames as $hostgroupId => $hostgroupName) {
                 if ($hostgroupId == $this->getId()) {
                     if ($host->delMember('hostgroups', $hostgroupId, $hostgroupName)) {
                         $this->addStatusMessage(sprintf(_('host %s byl odstraněn ze skupiny %s'), $host->getName(), $hostgroupName), 'success');
                     } else {
                         $this->addStatusMessage(sprintf(_('host %s byl odstraněn ze skupiny %s'), $host->getName(), $hostgroupName), 'error');
                     }
                 }
             }
         }
     }
     $subgroup = new IEHostgroup();
     $subgroups = $subgroup->getColumnsFromMySQL(array($subgroup->myKeyColumn), array('hostgroup_members' => '%' . $this->getName() . '%'));
     foreach ($subgroups as $subgroupInfo) {
         $subgroupId = intval(current($subgroupInfo));
         $subgroup->loadFromMySQL($subgroupId);
         $subgroupgroupNames = $subgroup->getDataValue('hostgroup_members');
         if ($subgroupgroupNames) {
             foreach ($subgroupgroupNames as $subgroupgroupId => $subgroupgroupName) {
                 if ($subgroupgroupId == $this->getId()) {
                     if ($subgroup->delMember('hostgroup_members', $subgroupgroupId, $subgroupgroupName)) {
                         $this->addStatusMessage(sprintf(_('subgroup %s byl odstraněn ze skupiny %s'), $subgroup->getName(), $subgroupgroupName), 'success');
                     } else {
                         $this->addStatusMessage(sprintf(_('subgroup %s byl odstraněn ze skupiny %s'), $subgroup->getName(), $subgroupgroupName), 'error');
                     }
                 }
             }
         }
     }
     return parent::delete($id);
 }
Exemplo n.º 11
0
 *
 * @package    IcingaEditor
 * @subpackage WebUI
 * @author     Vitex <*****@*****.**>
 * @copyright  2012 Vitex@hippy.cz (G)
 */
require_once 'includes/IEInit.php';
require_once 'classes/IEHost.php';
require_once 'classes/IEFXPreloader.php';
$oPage->onlyForLogged();
$hostId = $oPage->getRequestValue('host_id', 'int');
if ($hostId == 0) {
    $oPage->redirect('hosts.php');
    exit;
}
$host = new IEHost($hostId);
$operation = $oPage->getRequestValue('operation');
switch ($operation) {
    case 'confirm':
        $state = $oPage->getRequestValue('confirm');
        if ($state == 'on') {
            $host->setDataValue('config_hash', $host->getConfigHash());
        } else {
            $host->setDataValue('config_hash', null);
        }
        if ($host->saveToMySQL()) {
            $host->addStatusMessage(_('Stav nasazení senzoru byl nastaven  ručně.'));
        }
        break;
    default:
        break;
Exemplo n.º 12
0
    }
    if (count($ipSix) < 1) {
        if ($tryA == true) {
            if (count($ipFour) < 1) {
                return false;
            } else {
                return $ipFour;
            }
        } else {
            return false;
        }
    } else {
        return $ipSix;
    }
}
$host = new IEHost();
$host->owner =& $oUser;
if ($hostName || $address || $addressSix) {
    if (!$hostName) {
        if ($address) {
            $hostName = gethostbyaddr($address);
        } else {
            if ($addressSix) {
                $hostName = gethostbyaddr6($addressSix);
            }
        }
    }
    if (!$address) {
        if ($hostName) {
            $address = gethostbyname($hostName);
        }
Exemplo n.º 13
0
    if ($pocTimeperiods) {
        $warning = $oPage->columnII->addItem(new EaseHtmlDivTag('Contact', _('Nemáte definovaný kontakt'), array('class' => 'alert alert-info')));
        $warning->addItem(new EaseTWBLinkButton('contact.php', _('Založit první kontakt ' . EaseTWBPart::GlyphIcon('edit'))));
    } else {
        $oPage->columnII->addItem(new EaseHtmlDivTag('Contact', _('Kontakty vyžadují časovou periodu'), array('class' => 'alert alert-danger')));
    }
}
$contactgroup = new IEContactgroup();
$pocContactgroup = $contactgroup->getMyRecordsCount();
if ($pocContactgroup) {
    $success = $oPage->columnII->addItem(new EaseHtmlDivTag('Contactgroup', new EaseTWBLinkButton('contactgroups.php', _('<i class="icon-list"></i>') . ' ' . sprintf(_('Definováno %s skupin kontaktů'), $pocContactgroup)), array('class' => 'alert alert-success')));
} else {
    $warning = $oPage->columnII->addItem(new EaseHtmlDivTag('Contactgroup', _('Nemáte definovanou skupinu kontaktů'), array('class' => 'alert alert-info')));
    $warning->addItem(new EaseTWBLinkButton('contactgroup.php', _('Založit první skupinu kontaktů ' . EaseTWBPart::GlyphIcon('edit'))));
}
$host = new IEHost();
$pocHostu = $host->getMyRecordsCount();
if ($pocHostu) {
    $success = $oPage->columnI->addItem(new EaseHtmlDivTag('Host', new EaseTWBLinkButton('hosts.php', _('<i class="icon-list"></i>') . ' ' . sprintf(_('Definováno %s hostů'), $pocHostu)), array('class' => 'alert alert-success')));
} else {
    if ($pocTimeperiods) {
        $warning = $oPage->columnI->addItem(new EaseHtmlDivTag('Host', _('Nemáte definovaný žádný host'), array('class' => 'alert alert-info')));
        $warning->addItem(new EaseTWBLinkButton('host.php', _('Založit první host') . ' ' . EaseTWBPart::GlyphIcon('edit')));
    } else {
        $warning = $oPage->columnI->addItem(new EaseHtmlDivTag('Host', _('Hosty vyžadují časovou periodu ..'), array('class' => 'alert alert-danger')));
    }
}
$hostgroup = new IEHostgroup();
$pocHostgroups = $hostgroup->getMyRecordsCount();
if ($pocHostgroups) {
    $success = $oPage->columnI->addItem(new EaseHtmlDivTag('Hostgroup', new EaseTWBLinkButton('hostgroups.php', _('<i class="icon-list"></i>') . ' ' . sprintf(_('Definováno %s skupin hostů'), $pocHostgroups)), array('class' => 'alert alert-success')));
Exemplo n.º 14
0
/**
 * Icinga Editor - skupina hostů
 *
 * @package    IcingaEditor
 * @subpackage WebUI
 * @author     Vitex <*****@*****.**>
 * @copyright  2012 Vitex@hippy.cz (G)
 */
require_once 'includes/IEInit.php';
$oPage->onlyForLogged();
$hostgroup = new IEHostgroup($oPage->getRequestValue('hostgroup_id', 'int'));
switch ($oPage->getRequestValue('action')) {
    case 'contactAsign':
        $contact = new IEContact($oPage->getRequestValue('contact_id', 'int'));
        if ($contact->getId()) {
            $host = new IEHost();
            $groupMembers = $hostgroup->getMembers();
            foreach ($groupMembers as $gmID => $hostName) {
                $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:
Exemplo n.º 15
0
<?php

/**
 * Icinga Editor - titulní strana
 *
 * @package    IcingaEditor
 * @subpackage WebUI
 * @author     Vitex <*****@*****.**>
 * @copyright  2012 Vitex@hippy.cz (G)
 */
require_once 'includes/IEInit.php';
$oPage->onlyForLogged();
$oPage->addItem(new IEPageTop(_('Monitoring')));
$host = new IEHost();
$hosts = $host->getListing(null, false, array('config_hash', 'address', 'parents', 'icon_image', 'contacts', 'contact_groups', $host->myCreateColumn, $host->myLastModifiedColumn));
if (count($hosts)) {
    $oPage->container->addItem(new IEConfigurationsOverview($hosts));
} else {
    $oPage->container->addItem(new EaseTWBLinkButton('wizard-host.php', _('Založte si první sledovaný host'), 'success'));
    $oUser->addStatusMessage(_('Zatím není zaregistrovaný žádný sledovaný host'), 'warning');
}
$oPage->addItem(new IEPageBottom());
$oPage->draw();
Exemplo n.º 16
0
/**
 * Icinga Editor - titulní strana
 *
 * @deprecated since version 222
 * @package    IcingaEditor
 * @subpackage WebUI
 * @author     Vitex <*****@*****.**>
 * @copyright  2012 Vitex@hippy.cz (G)
 */
require_once 'includes/IEInit.php';
require_once 'classes/IEHost.php';
require_once 'classes/IECommand.php';
require_once 'classes/IEPreferences.php';
$oPage->onlyForLogged();
$hostId = $oPage->getRequestValue('host_id', 'int');
$host = new IEHost($hostId);
$preferences = new IEPreferences();
$prefs = $preferences->getPrefs();
$nscabat = '
set NSCLIENT="%ProgramFiles%\\NSClient++\\nscp.exe"
%NSCLIENT% service --stop

del "%ProgramFiles%\\NSClient++\\nsclient.ini"
%NSCLIENT% settings --generate --add-defaults --load-all

%NSCLIENT% settings --path "/modules" --key Scheduler --set enabled
%NSCLIENT% settings --path "/modules" --key CheckDisk --set enabled
%NSCLIENT% settings --path "/modules" --key CheckEventLog --set enabled
%NSCLIENT% settings --path "/modules" --key CheckExternalScripts --set enabled
%NSCLIENT% settings --path "/modules" --key CheckHelpers --set enabled
%NSCLIENT% settings --path "/modules" --key CheckNSCP --set enabled
Exemplo n.º 17
0
 /**
  * Přejmenuje hosta a závistlosti
  * @param type $newname
  */
 public function rename($newname)
 {
     $oldname = $this->getName();
     $this->setDataValue($this->nameColumn, $newname);
     $hostGroup = new IEHostgroup();
     $hostGroup->renameHost($oldname, $newname);
     $renameAll = true;
     $service = new IEService();
     $servicesAssigned = $service->myDbLink->queryToArray('SELECT ' . $service->myKeyColumn . ',' . $service->nameColumn . ' FROM ' . $service->myTable . ' WHERE ' . 'host_name' . ' LIKE \'%"' . $oldname . '"%\'', $service->myKeyColumn);
     foreach ($servicesAssigned as $serviceID => $serviceInfo) {
         $service->loadFromMySQL($serviceID);
         $service->renameHostName($this->getId(), $newname);
         if (!$service->saveToMySQL()) {
             $this->addStatusMessage(sprintf(_('Nepodařilo se přejmenovat %s ve službě %s'), $this->getName(), $service->getName()), $Type);
             $renameAll = false;
         }
     }
     $childsAssigned = $this->myDbLink->queryToArray('SELECT ' . $this->myKeyColumn . ',' . $this->nameColumn . ' FROM ' . $this->myTable . ' WHERE ' . 'parents' . ' LIKE \'%"' . $oldname . '"%\'', $this->myKeyColumn);
     foreach ($childsAssigned as $chid_id => $child_info) {
         $child = new IEHost($chid_id);
         $child->delMember('parents', $this->getId(), $oldname);
         $child->addMember('parents', $this->getId(), $newname);
         $child->updateToMySQL();
     }
     if ($this->save() && $renameAll) {
         return true;
     }
     return false;
 }
/**
 * Icinga Editor - titulní strana
 *
 * @package    IcingaEditor
 * @subpackage WebUI
 * @author     Vitex <*****@*****.**>
 * @copyright  2012 Vitex@hippy.cz (G)
 */
require_once 'includes/IEInit.php';
require_once 'classes/IEPassiveCheckedHostForm.php';
$oPage->onlyForLogged();
$hostName = trim($oPage->getRequestValue('host_name'));
$platform = trim($oPage->getRequestValue('platform'));
$host_group = $oPage->getRequestValue('host_group', 'int');
$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();
 /**
  * Editor k přidávání členů skupiny
  *
  * @param IEHost $host
  */
 public function __construct($host)
 {
     parent::__construct();
     $fieldName = $this->getmyKeyColumn();
     if ($host->getDataValue('platform') == 'generic') {
         $note = '<small><span class="label label-info">Tip:</span> ' . _('Další sledovatelné služby budou nabídnuty po nastavení platformy hosta a vzdáleného senzoru.') . '</small>';
     } else {
         $note = array();
     }
     $initialContent = new EaseTWBPanel(_('Sledované služby'), 'default', null, $note);
     $initialContent->setTagCss(array('width' => '100%'));
     if (is_null($host->getMyKey())) {
         $initialContent->addItem(_('Nejprve je potřeba uložit záznam'));
     } else {
         $hostName = $host->getName();
         $service = new IEService();
         $parentServUsed = array();
         $host_active = (bool) $host->getCfgValue('active_checks_enabled');
         $host_passive = (bool) $host->getCfgValue('passive_checks_enabled');
         $servicesAssigned = $service->myDbLink->queryToArray('SELECT ' . $service->myKeyColumn . ',display_name,' . $service->nameColumn . ' FROM ' . $service->myTable . ' WHERE ' . $fieldName . ' LIKE \'%"' . $host->getName() . '"%\'', $service->myKeyColumn);
         $allServices = $service->getListing(null, true, array('platform', 'parent_id', 'passive_checks_enabled', 'active_checks_enabled', 'display_name'));
         foreach ($allServices as $serviceID => $serviceInfo) {
             $servicePassive = (bool) $serviceInfo['passive_checks_enabled'];
             $serviceActive = (bool) $serviceInfo['active_checks_enabled'];
             if ($serviceInfo['register'] != 1) {
                 unset($allServices[$serviceID]);
                 continue;
             }
             if ($serviceInfo['platform'] != 'generic' && $serviceInfo['platform'] != $host->getDataValue('platform')) {
                 unset($allServices[$serviceID]);
                 continue;
             }
             if ((!$host_passive || !$servicePassive) && (!$host_active || !$serviceActive)) {
                 unset($allServices[$serviceID]);
                 continue;
             }
         }
         foreach ($servicesAssigned as $serviceID => $serviceInfo) {
             if (isset($allServices[$serviceID]) && isset($parentServUsed[$allServices[$serviceID]['parent_id']])) {
                 $parentServUsed[$allServices[$serviceID]['parent_id']] = $allServices[$serviceID]['parent_id'];
             }
             unset($allServices[$serviceID]);
         }
         if (count($allServices)) {
             foreach ($allServices as $serviceID => $serviceInfo) {
                 if (isset($parentServUsed[$serviceInfo['parent_id']])) {
                     continue;
                 }
                 $unchMenu = array();
                 if (intval($serviceInfo['parent_id'])) {
                     $unchMenu[] = new EaseHtmlATag('servicetweak.php?service_id=' . $serviceID, EaseTWBPart::GlyphIcon('wrench') . ' ' . _('Editace'));
                 }
                 $unchMenu[] = new EaseHtmlATag('?addservice=' . $serviceInfo[$service->nameColumn] . '&amp;service_id=' . $serviceID . '&amp;' . $host->getmyKeyColumn() . '=' . $host->getMyKey() . '&amp;' . $host->nameColumn . '=' . $host->getName(), EaseTWBPart::GlyphIcon('plus') . ' ' . _('Začít sledovat'));
                 if (strlen($serviceInfo['display_name'])) {
                     $serviceName = $serviceInfo['display_name'];
                 } else {
                     $serviceName = $serviceInfo[$service->nameColumn];
                 }
                 $initialContent->addItem(new EaseTWBButtonDropdown($serviceName, 'inverse', 'xs', $unchMenu));
             }
         }
         if (count($servicesAssigned)) {
             $saveAsTemplateButton = new EaseTWBLinkButton('stemplate.php?action=copyhost&host_id=' . $host->getId(), _('Uložit jako předlohu'), 'success');
             $initialContent->footer($saveAsTemplateButton);
             $initialContent->addItem('</br>');
             foreach ($servicesAssigned as $serviceID => $serviceInfo) {
                 if (strlen($serviceInfo['display_name'])) {
                     $serviceName = $serviceInfo['display_name'];
                 } else {
                     $serviceName = $serviceInfo[$service->nameColumn];
                 }
                 $initialContent->addItem(new EaseTWBButtonDropdown($serviceName, 'success', 'xs', array(new EaseHtmlATag('?delservice=' . $serviceInfo[$service->nameColumn] . '&amp;service_id=' . $serviceID . '&amp;' . $host->getmyKeyColumn() . '=' . $host->getMyKey() . '&amp;' . $host->nameColumn . '=' . $host->getName(), EaseTWBPart::GlyphIcon('remove') . ' ' . _('Přestat sledovat')), new EaseHtmlATag('servicetweak.php?service_id=' . $serviceID . '&amp;host_id=' . $host->getId(), EaseTWBPart::GlyphIcon('wrench') . ' ' . _('Editace')))));
             }
         } else {
             $presetSelForm = new EaseTWBForm('presetSelForm');
             $presetSelForm->addItem(new EaseHtmlInputHiddenTag($host->getmyKeyColumn(), $host->getId()));
             $presetSelForm->addItem(new EaseHtmlInputHiddenTag('action', 'applystemplate'));
             $presetSelForm->addItem(new IEStemplateSelect('stemplate_id'));
             $presetSelForm->addItem(new EaseTWSubmitButton(_('Aplikovat předlohu'), 'success'));
             $presetSelForm->setTagClass('form-inline');
             $initialContent->footer($presetSelForm);
         }
     }
     $this->addItem($initialContent);
 }
Exemplo n.º 20
0
 /**
  * Uloží ikonu do správné složky
  *
  * @param  string  $tmpfilename
  * @param  IEHost  $host
  * @return boolean
  */
 public static function saveIcon($tmpfilename, $host)
 {
     $id = $host->owner->getUserID();
     $thumbnailImagePath = $tmpfilename . '40';
     list($sourceImageWidth, $sourceImageHeight, $sourceImageType) = getimagesize($tmpfilename);
     switch ($sourceImageType) {
         case IMAGETYPE_ICO:
             $tmpfilenameIco = $tmpfilename . '.ico';
             $tmpfilenameGif = $tmpfilename . '.gif';
             rename($tmpfilename, $tmpfilenameIco);
             system("convert '" . $tmpfilenameIco . "[0]' " . $tmpfilenameGif);
             $tmpfilename = $tmpfilenameGif;
             unlink($tmpfilenameIco);
         case IMAGETYPE_GIF:
             $sourceGdImage = imagecreatefromgif($tmpfilename);
             $suffix = 'gif';
             break;
         case IMAGETYPE_JPEG:
             $sourceGdImage = imagecreatefromjpeg($tmpfilename);
             $suffix = 'jpg';
             break;
         case IMAGETYPE_PNG:
             $sourceGdImage = imagecreatefrompng($tmpfilename);
             $suffix = 'png';
             break;
     }
     if (!$sourceImageHeight || !$sourceImageWidth) {
         return NULL;
     }
     if ($sourceImageWidth > $sourceImageHeight) {
         $thumbnailImageWidth = self::$imageSize;
     } else {
         $thumbnailImageHeight = self::$imageSize;
     }
     if (isset($thumbnailImageWidth) and !isset($thumbnailImageHeight)) {
         // autocompute height if only width is set
         if ($thumbnailImageWidth) {
             $thumbnailImageHeight = 100 / ($sourceImageWidth / $thumbnailImageWidth) * 0.01;
         }
         $thumbnailImageHeight = @round($sourceImageHeight * $thumbnailImageHeight);
     } elseif (isset($thumbnailImageHeight) and !isset($thumbnailImageWidth)) {
         // autocompute width if only height is set
         if ($thumbnailImageHeight) {
             $thumbnailImageWidth = 100 / ($sourceImageHeight / $thumbnailImageHeight) * 0.01;
         }
         $thumbnailImageWidth = @round($sourceImageWidth * $thumbnailImageWidth);
     } elseif (isset($thumbnailImageHeight) and isset($thumbnailImageWidth) and isset($constrain)) {
         // get the smaller resulting image dimension if both height
         // and width are set and $constrain is also set
         $hx = 100 / ($sourceImageWidth / $thumbnailImageWidth) * 0.01;
         $hx = @round($sourceImageHeight * $hx);
         $wx = 100 / ($sourceImageHeight / $thumbnailImageHeight) * 0.01;
         $wx = @round($sourceImageWidth * $wx);
         if ($hx < $thumbnailImageHeight) {
             $thumbnailImageHeight = 100 / ($sourceImageWidth / $thumbnailImageWidth) * 0.01;
             $thumbnailImageHeight = @round($sourceImageHeight * $thumbnailImageHeight);
         } else {
             $thumbnailImageWidth = 100 / ($sourceImageHeight / $thumbnailImageHeight) * 0.01;
             $thumbnailImageWidth = @round($sourceImageWidth * $thumbnailImageWidth);
         }
     }
     $thumbnailGdImage = imagecreatetruecolor($thumbnailImageWidth, $thumbnailImageHeight);
     switch ($sourceImageType) {
         case IMAGETYPE_PNG:
             // integer representation of the color black (rgb: 0,0,0)
             $background = imagecolorallocate($sourceGdImage, 0, 0, 0);
             // removing the black from the placeholder
             imagecolortransparent($thumbnailGdImage, $background);
             // turning off alpha blending (to ensure alpha channel information
             // is preserved, rather than removed (blending with the rest of the
             // image in the form of black))
             imagealphablending($thumbnailGdImage, false);
             // turning on alpha channel information saving (to ensure the full range
             // of transparency is preserved)
             imagesavealpha($sourceGdImage, true);
             break;
         case IMAGETYPE_GIF:
             // integer representation of the color black (rgb: 0,0,0)
             $background = imagecolorallocate($sourceGdImage, 0, 0, 0);
             // removing the black from the placeholder
             imagecolortransparent($thumbnailGdImage, $background);
             break;
     }
     imagecopyresampled($thumbnailGdImage, $sourceGdImage, 0, 0, 0, 0, $thumbnailImageWidth, $thumbnailImageHeight, $sourceImageWidth, $sourceImageHeight);
     switch ($sourceImageType) {
         case IMAGETYPE_ICO:
         case IMAGETYPE_GIF:
             imagegif($thumbnailGdImage, $thumbnailImagePath);
             break;
         case IMAGETYPE_JPEG:
             imagejpeg($thumbnailGdImage, $thumbnailImagePath, 90);
             break;
         case IMAGETYPE_PNG:
             imagepng($thumbnailGdImage, $thumbnailImagePath, 9);
             break;
     }
     imagedestroy($sourceGdImage);
     imagedestroy($thumbnailGdImage);
     $newname = 'custom/' . $id . '-' . $host->getName() . '.' . $suffix;
     if (rename($thumbnailImagePath, self::$webdir . self::$icodir . '/' . $newname)) {
         unlink($tmpfilename);
         return $newname;
     }
     return false;
 }
Exemplo n.º 21
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();
             }
         }
     }
 }
Exemplo n.º 22
0
 /**
  * Editor k přidávání členů skupiny
  *
  * @param IEService|IEHost $holder
  */
 public function __construct($holder)
 {
     $contactsAssigned = array();
     parent::__construct();
     $fieldName = $this->getmyKeyColumn();
     $initialContent = new EaseTWBPanel(_('Cíle notifikací'));
     $initialContent->setTagCss(array('width' => '100%'));
     if (is_null($holder->getMyKey())) {
         $initialContent->addItem(_('Nejprve je potřeba uložit záznam'));
     } else {
         $serviceName = $holder->getName();
         $contact = new IEContact();
         $allContacts = $contact->getListing(null, true, array('alias', 'parent_id'));
         foreach ($holder->getDataValue('contacts') as $contactId => $contactName) {
             if (isset($allContacts[$contactId])) {
                 $contactsAssigned[$contactId] = $allContacts[$contactId];
             }
         }
         foreach ($allContacts as $contactID => $contactInfo) {
             if ($contactInfo['register'] != 1) {
                 unset($allContacts[$contactID]);
             }
             if (!$contactInfo['parent_id']) {
                 unset($allContacts[$contactID]);
             }
         }
         foreach ($contactsAssigned as $contactID => $contactInfo) {
             unset($allContacts[$contactID]);
         }
         if (count($allContacts)) {
             foreach ($allContacts as $contactID => $contactInfo) {
                 $initialContent->addItem(new EaseTWBButtonDropdown($contactInfo[$contact->nameColumn], 'inverse', 'xs', array(new EaseHtmlATag('contacttweak.php?contact_id=' . $contactInfo['parent_id'] . '&amp;service_id=' . $holder->getId(), EaseTWBPart::GlyphIcon('wrench') . ' ' . _('Editace')), new EaseHtmlATag('?addcontact=' . $contactInfo[$contact->nameColumn] . '&amp;contact_id=' . $contactID . '&amp;' . $holder->getmyKeyColumn() . '=' . $holder->getMyKey() . '&amp;' . $holder->nameColumn . '=' . $holder->getName(), EaseTWBPart::GlyphIcon('plus') . ' ' . _('Začít obesílat')))));
             }
         }
         if (count($contactsAssigned)) {
             $initialContent->addItem('<br/>');
             foreach ($contactsAssigned as $contactID => $contactInfo) {
                 $initialContent->addItem(new EaseTWBButtonDropdown($contactInfo[$contact->nameColumn], 'success', 'xs', array(new EaseHtmlATag('?delcontact=' . $contactInfo[$contact->nameColumn] . '&amp;contact_id=' . $contactID . '&amp;' . $holder->getmyKeyColumn() . '=' . $holder->getMyKey() . '&amp;' . $holder->nameColumn . '=' . $holder->getName(), EaseTWBPart::GlyphIcon('remove') . ' ' . _('Přestat obesílat')), new EaseHtmlATag('contacttweak.php?contact_id=' . $contactInfo['parent_id'] . '&amp;service_id=' . $holder->getId(), EaseTWBPart::GlyphIcon('wrench') . ' ' . _('Editace')))));
             }
         }
     }
     $this->addItem($initialContent);
 }
Exemplo n.º 23
0
 public function delete($id = null)
 {
     if (is_null($id)) {
         $id = $this->getId();
     }
     if ($id != $this->getId()) {
         $this->loadFromMySQL($id);
     }
     $userGroup = new IEUserGroup();
     $userGroup->delUser($id);
     $command = new IECommand();
     $myCommand = $command->getOwned($id);
     if ($myCommand) {
         foreach ($myCommand as $command_id => $cmd) {
             $command->loadFromMySQL((int) $command_id);
             $command->delete();
         }
     }
     $contact = new IEContact();
     $myContact = $contact->getOwned($id);
     if ($myContact) {
         foreach ($myContact as $contact_id => $cmd) {
             if ($contact->loadFromMySQL((int) $contact_id)) {
                 $contact->delete();
             }
         }
     }
     $contactgroup = new IEContactgroup();
     $myContactgroup = $contactgroup->getOwned($id);
     if ($myContactgroup) {
         foreach ($myContactgroup as $contactgroup_id => $cmd) {
             $contactgroup->loadFromMySQL((int) $contactgroup_id);
             $contactgroup->delete();
         }
     }
     $hostgroup = new IEHostgroup();
     $myHostgroup = $hostgroup->getOwned($id);
     if ($myHostgroup) {
         foreach ($myHostgroup as $hostgroup_id => $cmd) {
             $hostgroup->loadFromMySQL((int) $hostgroup_id);
             $hostgroup->delete();
         }
     }
     $host = new IEHost();
     $myHost = $host->getOwned($id);
     if ($myHost) {
         foreach ($myHost as $host_id => $cmd) {
             $host->loadFromMySQL((int) $host_id);
             $host->delete();
         }
     }
     $servicegroup = new IEServicegroup();
     $myServicegroup = $servicegroup->getOwned($id);
     if ($myServicegroup) {
         foreach ($myServicegroup as $servicegroup_id => $cmd) {
             $servicegroup->loadFromMySQL((int) $servicegroup_id);
             $servicegroup->delete();
         }
     }
     $service = new IEService();
     $myService = $service->getOwned($id);
     if ($myService) {
         foreach ($myService as $service_id => $cmd) {
             $service->loadFromMySQL((int) $service_id);
             $service->delete();
         }
     }
     $timeperiod = new IETimeperiod();
     $myTimeperiod = $timeperiod->getOwned($id);
     if ($myTimeperiod) {
         foreach ($myTimeperiod as $timeperiod_id => $cmd) {
             $timeperiod->loadFromMySQL((int) $timeperiod_id);
             $timeperiod->delete();
         }
     }
     $cfgfile = constant('CFG_GENERATED') . '/' . $this->getUserLogin() . '.cfg';
     if (file_exists($cfgfile)) {
         if (unlink($cfgfile)) {
             $this->addStatusMessage(sprintf(_('Konfigurace uživatele %s byla smazána'), $this->getUserLogin()), 'success');
         } else {
             $this->addStatusMessage(sprintf(_('Konfigurace uživatele %s nebyla smazána'), $this->getUserLogin()), 'error');
         }
     }
     if ($this->deleteFromMySQL()) {
         $this->addStatusMessage(sprintf(_('Uživatel %s byl smazán'), $this->getUserLogin()));
         require_once 'Ease/EaseMail.php';
         $email = new EaseMail($this->getDataValue('email'), _('Oznámení o zrušení účtu'));
         $email->setMailHeaders(array('From' => EMAIL_FROM));
         $email->addItem(new EaseHtmlDivTag(null, "Právě jste byl/a smazán/a z Aplikace VSMonitoring s těmito přihlašovacími údaji:\n"));
         $email->addItem(new EaseHtmlDivTag(null, ' Login: ' . $this->GetUserLogin() . "\n"));
         $email->send();
         return true;
     } else {
         return FALSE;
     }
 }
Exemplo n.º 24
0
 /**
  * Přehodí
  * @param type $swapToID
  * @return boolean
  */
 public function swapTo($swapToID)
 {
     $newService = new IEService($swapToID);
     $thisName = $this->getName();
     $hostsOK = array();
     $hostsErr = array();
     $hostsAssigned = array();
     $host = new IEHost();
     if (EaseShared::user()->getSettingValue('admin')) {
         $allHosts = $host->getAllFromMySQL(NULL, array($host->myKeyColumn, $host->nameColumn, 'platform', 'register'), null, $host->nameColumn, $host->myKeyColumn);
     } else {
         $allHosts = $host->getListing(null, true, array('platform', 'register'));
     }
     $hosts = $this->getDataValue('host_name');
     foreach ($hosts as $hostId => $hostName) {
         if (isset($allHosts[$hostId])) {
             $hostsAssigned[$hostId] = $allHosts[$hostId];
         }
     }
     foreach ($hostsAssigned as $host_id => $hostAssigned) {
         if ($this->delMember('host_name', $host_id, $hostAssigned['host_name']) && $newService->addMember('host_name', $host_id, $hostAssigned['host_name'])) {
             $hostsOK[] = $hostAssigned['host_name'];
         } else {
             $hostsErr[] = $hostAssigned['host_name'];
         }
     }
     if ($this->saveToMySQL() && $newService->saveToMySQL() && count($hostsOK)) {
         $this->addStatusMessage(sprintf(_('%s byl přesunut z %s/%s do %s'), implode(',', $hostsOK), $this->keyword, $this->getName(), $newService->getName()), 'success');
         return true;
     } else {
         $this->addStatusMessage(sprintf(_(' %s nebyl přesunut z %s/%s do %s'), implode(',', $hostsErr), $this->keyword, $this->getName(), $newService->getName()), 'warning');
         return false;
     }
 }
 function getCfgConfirmUrl()
 {
     return IECfg::getBaseURL() . 'cfgconfirm.php?hash=' . $this->host->getConfigHash() . '&host_id=' . $this->host->getId();
 }
Exemplo n.º 26
0
 /**
  * Zkusí se připojit k portu
  *
  * @param int $port
  */
 public function scan($port)
 {
     $fp = @fsockopen($this->host->getDataValue('address'), $port, $errno, $errstr, 2);
     @fclose($fp);
     return $fp;
 }
Exemplo n.º 27
0
 /**
  * Smaže kontakt i jeho subkontakty
  *
  * @return boolean
  */
 public function delete($id = null)
 {
     if (is_null($id)) {
         $id = $this->getId();
     } else {
         if ($id != $this->getId()) {
             $this->loadFromMySQL($id);
         }
     }
     $childs = $this->getChilds();
     if ($childs) {
         $parent = $id;
         foreach ($childs as $child_id => $child) {
             $this->delete($child_id);
         }
         $this->loadFromMySQL($parent);
         $id = $parent;
     }
     $contactgroup = new IEContactgroup();
     $contactgroups = $this->myDbLink->queryTo2DArray('SELECT ' . $contactgroup->getmyKeyColumn() . ' FROM ' . $contactgroup->myTable . ' WHERE members LIKE \'%' . $this->getName() . '%\'');
     if (count($contactgroups)) {
         foreach ($contactgroups as $contactgroupID) {
             $contactgroup->loadFromMySQL((int) $contactgroupID);
             if ($contactgroup->delMember('members', null, $this->getName())) {
                 if ($contactgroup->saveToMySQL()) {
                     $this->addStatusMessage(sprintf(_('Kontakt <strong>%s</strong> byl odebrán ze skupiny <strong>%s</strong>'), $this->getName(), $contactgroup->getName()), 'success');
                 }
             } else {
                 $this->addStatusMessage(sprintf(_('Kontakt <strong>%s</strong> nebyl odebrán ze skupiny <strong>%s</strong>'), $this->getName(), $contactgroup->getName()), 'warning');
             }
         }
     }
     $service = new IEService();
     $services = $this->myDbLink->queryTo2DArray('SELECT ' . $service->getmyKeyColumn() . ' FROM ' . $service->myTable . ' WHERE contacts LIKE \'%' . $this->getName() . '%\'');
     if (count($services)) {
         foreach ($services as $serviceID) {
             $service->loadFromMySQL((int) $serviceID);
             if ($service->delMember('contacts', $id)) {
                 if ($service->saveToMySQL()) {
                     $this->addStatusMessage(sprintf(_('Kontakt <strong>%s</strong> byl odebrán ze služby <strong>%s</strong>'), $this->getName(), $service->getName()), 'success');
                 }
             } else {
                 $this->addStatusMessage(sprintf(_('Kontakt <strong>%s</strong> nebyl odebrán ze služby <strong>%s</strong>'), $this->getName(), $service->getName()), 'warning');
             }
         }
     }
     $host = new IEHost();
     $hosts = $this->myDbLink->queryTo2DArray('SELECT ' . $host->getmyKeyColumn() . ' FROM ' . $host->myTable . ' WHERE contacts LIKE \'%' . $this->getName() . '%\'');
     if (count($hosts)) {
         foreach ($hosts as $hostID) {
             $host->loadFromMySQL((int) $hostID);
             if ($host->delMember('contacts', $id)) {
                 if ($host->saveToMySQL()) {
                     $this->addStatusMessage(sprintf(_('Kontakt <strong>%s</strong> byl odebrán z hosta <strong>%s</strong>'), $this->getName(), $host->getName()), 'success');
                 }
             } else {
                 $this->addStatusMessage(sprintf(_('Kontakt <strong>%s</strong> nebyl odebrán z hosta <strong>%s</strong>'), $this->getName(), $host->getName()), 'warning');
             }
         }
     }
     $this->myDbLink->exeQuery('DELETE FROM `' . $this->myTable . '` WHERE `parent_id`=' . $id);
     return parent::delete($id);
 }
 /**
  * Přehled hostů bez potvrzeného senzoru, nebo se zastaralou konf. senzoru.
  *
  * @param array $hosts
  */
 public function __construct($hosts)
 {
     $ok = 0;
     $noSensor = array();
     $oldSensor = array();
     $noParents = array();
     $noIcon = array();
     $noContacts = array();
     EaseShared::webPage()->addItem(new EaseHtmlDivTag('preload', new IEFXPreloader(), array('class' => 'fuelux')));
     foreach ($hosts as $host_id => $host_info) {
         if (is_null($host_info['host_name']) || !strlen($host_info['host_name'])) {
             unset($hosts[$host_id]);
             continue;
         }
         if (isset($host_info['config_hash'])) {
             $host = new IEHost((int) $host_id);
             if ($host->getConfigHash() == $host_info['config_hash']) {
                 unset($hosts[$host_id]);
                 $ok++;
             } else {
                 //Zastaralá konfigurace
                 $oldSensor[$host_id] = $host_info;
             }
         } else {
             $noSensor[$host_id] = $host_info;
             //senzor neregistrován
         }
         if (!isset($host_info['parents']) || !count($host_info['parents'])) {
             $noParents[$host_id] = $host_info;
             //Host bez rodičů
         }
         if (!isset($host_info['icon_image']) || !strlen(trim($host_info['icon_image']))) {
             $noIcon[$host_id] = $host_info;
             //Host bez ikony
         }
         if (!isset($host_info['contacts']) || !count($host_info['contacts']) || (!isset($host_info['contact_groups']) || !count($host_info['contact_groups']))) {
             $noContacts[$host_id] = $host_info;
             //Host bez kontaktů
         }
     }
     $hostsTabs = new EaseTWBTabs('hostsTabs');
     if (count($oldSensor)) {
         $oldHostsTable = new EaseHtmlTableTag(null, array('class' => 'table'));
         foreach ($oldSensor as $host_id => $host_info) {
             $row = $oldHostsTable->addRowColumns(array(new EaseHtmlATag('host.php?host_id=' . $host_id, $host_info['host_name']), new EaseTWBLinkButton('sensor.php?host_id=' . $host_id, _('aktualizovat senzor'))));
             $row->setTagClass('warning');
         }
         $hostsTabs->addTab(sprintf(_('Neakt. Senzor <span class="badge">%s</span>'), count($oldSensor)), $oldHostsTable);
     }
     if (count($noSensor)) {
         $noSensorTable = new EaseHtmlTableTag(null, array('class' => 'table'));
         foreach ($noSensor as $host_id => $host_info) {
             $row = $noSensorTable->addRowColumns(array(new EaseHtmlATag('host.php?host_id=' . $host_id, $host_info['host_name']), new EaseTWBLinkButton('sensor.php?host_id=' . $host_id, _('nasadit senzor'))));
             $row->setTagClass('danger');
         }
         $hostsTabs->addTab(sprintf(_('Bez senzoru <span class="badge">%s</span>'), count($noSensor)), $noSensorTable);
     }
     if (count($noParents)) {
         $noParentsTable = new EaseHtmlTableTag(null, array('class' => 'table'));
         foreach ($noParents as $host_id => $host_info) {
             $row = $noParentsTable->addRowColumns(array(new EaseHtmlATag('host.php?host_id=' . $host_id, $host_info['host_name']), new EaseTWBLinkButton('host.php?action=parent&host_id=' . $host_id, _('přiřadit rodiče')), new EaseTWBLinkButton('watchroute.php?action=parent&host_id=' . $host_id, _('sledovat celou cestu'), 'warning', array('onClick' => "\$('#preload').css('visibility', 'visible');"))));
             $row->setTagClass('info');
         }
         $hostsTabs->addTab(sprintf(_('Bez rodičů <span class="badge">%s</span>'), count($noParents)), $noParentsTable);
     }
     if (count($noIcon)) {
         $noIconTable = new EaseHtmlTableTag(null, array('class' => 'table'));
         foreach ($noIcon as $host_id => $host_info) {
             $row = $noIconTable->addRowColumns(array(new EaseHtmlATag('host.php?host_id=' . $host_id, $host_info['host_name']), new EaseTWBLinkButton('host.php?action=icon&host_id=' . $host_id, _('přiřadit ikonu'))));
             $row->setTagClass('default');
         }
         $hostsTabs->addTab(sprintf(_('Bez ikony <span class="badge">%s</span>'), count($noIcon)), $noIconTable);
     }
     if (count($noContacts)) {
         $noContactsTable = new EaseHtmlTableTag(null, array('class' => 'table'));
         foreach ($noContacts as $host_id => $host_info) {
             $row = $noContactsTable->addRowColumns(array(new EaseHtmlATag('host.php?host_id=' . $host_id, $host_info['host_name']), new EaseTWBLinkButton('host.php?host_id=' . $host_id, _('přiřadit kontakty'))));
             $row->setTagClass('default');
         }
         $hostsTabs->addTab(sprintf(_('Bez kontaktů <span class="badge">%s</span>'), count($noContacts)), $noContactsTable);
     }
     parent::__construct(_('Hosty dle stavu konfigurace'), 'info', $hostsTabs, sprintf(_('Celkem %s hostů bez aktuální konfigurace. (%s aktuální)'), count($hosts), $ok));
 }
Exemplo n.º 29
0
$serviceUsages = $service->getColumnsFromMySQL(array($service->getMyKeyColumn(), $service->nameColumn), array('contacts' => '%' . $contact->getName() . '%'), $service->nameColumn, $service->getMyKeyColumn());
$oPage->addItem(new IEPageBottom());
$infopanel = new IEInfoBox($contact);
$tools = new EaseTWBPanel(_('Nástroje'), 'warning');
if ($contact->getId()) {
    $tools->addItem($contact->deleteButton());
    $tools->addItem(new EaseTWBPanel(_('Transfer'), 'warning', $contact->transferForm()));
    if (count($serviceUsages)) {
        $usedBy = new EaseTWBPanel(_('Používaný službami'));
        $listing = $usedBy->addItem(new EaseHtmlUlTag(null, array('class' => 'list-group')));
        foreach ($serviceUsages as $usage) {
            $listing->addItem(new EaseHtmlLiTag(new EaseHtmlATag('service.php?service_id=' . $usage['service_id'], $usage[$service->nameColumn]), array('class' => 'list-group-item')));
        }
        $infopanel->addItem($usedBy);
    }
    $host = new IEHost();
    $hostUsages = $host->getColumnsFromMySQL(array($host->getMyKeyColumn(), $host->nameColumn), array('contacts' => '%' . $contact->getName() . '%'), $host->nameColumn, $host->getMyKeyColumn());
    if (count($hostUsages)) {
        $usedBy = new EaseTWBPanel(_('Používaný hosty'));
        $listing = $usedBy->addItem(new EaseHtmlUlTag(null, array('class' => 'list-group')));
        foreach ($hostUsages as $usage) {
            $listing->addItem(new EaseHtmlLiTag(new EaseHtmlATag('host.php?host_id=' . $usage['host_id'], $usage[$host->nameColumn]), array('class' => 'list-group-item')));
        }
        $infopanel->addItem($usedBy);
    }
}
$pageRow = new EaseTWBRow();
$pageRow->addColumn(2, $infopanel);
$pageRow->addColumn(6, new EaseTWBPanel(_('Příkaz') . ' <strong>' . $contact->getName() . '</strong>', 'default', $form));
$pageRow->addColumn(4, $tools);
$oPage->container->addItem($pageRow);
Exemplo n.º 30
0
 /**
  * Add Groups/Hosts into menu
  *
  * @param IEBootstrapMenu $nav
  */
 private function groupsHostsMenu($nav)
 {
     EaseShared::webPage()->addCss('.dropdown-menu { overflow-y: auto } ');
     EaseShared::webPage()->addJavaScript("\$('.dropdown-menu').css('max-height',\$(window).height()-100);", null, true);
     $user = EaseShared::user();
     $host = new IEHost();
     $hosts = $host->getListing(null, null, array('icon_image', 'platform'));
     $hostsNotInGroup = array();
     $hnames = array();
     foreach ($hosts as $hID => $hInfo) {
         $hnames[$hInfo['host_name']] =& $hosts[$hID];
         $hostsNotInGroup[$hInfo['host_name']] = $hInfo;
     }
     $topItems = array('wizard-host.php' => EaseTWBPart::GlyphIcon('forward') . ' ' . _('Průvodce založením hostu'));
     $topItems['wizard-active-host.php'] = EaseTWBPart::GlyphIcon('star') . ' ' . _('Nový aktivní Host');
     $hostgroup = new IEHostgroup();
     $topItems['hostgroup.php'] = EaseTWBPart::GlyphIcon('plus') . ' ' . _('Nová skupina hostů');
     /* ,
        'exthostinfo.php' => _('Rozšířené informace hostů'),
        'hostdependency.php' => _('Závislosti hostů'),
        'hostescalation.php' => _('Eskalace hostů') */
     $pocHostgroup = $hostgroup->getMyRecordsCount();
     $hostGroupMenuItem = array();
     if ($pocHostgroup) {
         //$hostgroups = $hostgroup->myDbLink->queryToArray('SELECT ' . $hostgroup->getmyKeyColumn() . ', hostgroup_name, DatSave FROM ' . $hostgroup->myTable . ' WHERE user_id=' . $user->getUserID(), 'hostgroup_id');
         $hostgroups = $hostgroup->getListing(null, null, array('members'));
         foreach ($hostgroups as $cID => $hgInfo) {
             $hostGroupMenuItem['hostgroup.php?hostgroup_id=' . $hgInfo['hostgroup_id']] = EaseTWBPart::GlyphIcon('cloud') . ' ' . $hgInfo['hostgroup_name'];
             if (count($hgInfo['members'])) {
                 foreach ($hgInfo['members'] as $hgMember) {
                     if ($hgMember == '*') {
                         $image = null;
                     } else {
                         $hInfo =& $hnames[$hgMember];
                         $image = $hInfo['icon_image'];
                         unset($hostsNotInGroup[$hgMember]);
                     }
                     if (!$image) {
                         $image = 'unknown.gif';
                     }
                     if (isset($hInfo) && !is_null($hInfo)) {
                         $hostGroupMenuItem['host.php?host_id=' . $hInfo['host_id']] = '&nbsp;' . new IEHostIcon($hInfo) . ' ' . $hInfo['host_name'] . ' ' . new IEPlatformIcon($hInfo['platform']);
                     }
                 }
             }
         }
         $topItems['hostgroups.php'] = EaseTWBPart::GlyphIcon('list-alt') . ' ' . _('Přehled skupin hostů');
     } else {
         if (count($hostGroupMenuItem)) {
             $hostGroupMenuItem[] = '';
         }
     }
     if (count($hostsNotInGroup)) {
         foreach ($hostsNotInGroup as $menuHost) {
             $hostGroupMenuItem['host.php?host_id=' . $menuHost['host_id']] = '&nbsp;' . new IEHostIcon($menuHost) . ' ' . $menuHost['host_name'] . ' ' . new IEPlatformIcon($menuHost['platform']);
         }
     }
     $topItems['hosts.php'] = EaseTWBPart::GlyphIcon('list') . ' ' . _('Detailní přehled hostů');
     $topItems['map.php'] = EaseTWBPart::GlyphIcon('globe') . ' ' . _('Topologie');
     $nav->addDropDownMenu(_('Hosti'), array_merge($topItems, array('' => ''), $hostGroupMenuItem));
 }