/** * Nakonfiguruje režim pasivních testů odesílaných přez NSCA */ function cfgPassiveSet() { $this->addCfg('/modules', 'Scheduler', 'enabled'); $this->addCfg('/modules', 'NSCAClient', 'enabled'); $this->addCfg('/settings/NSCA/client', 'hostname', $this->host->getName()); $this->addCfg('/settings/NSCA/client', 'channel', 'NSCA'); $this->addCfg('/settings/NSCA/client/targets/default', 'allowed ciphers', 'ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH'); $this->addCfg('/settings/NSCA/client/targets/default', 'encryption', '3des'); $this->addCfg('/settings/NSCA/client/targets/default', 'password', $this->prefs['nscapassword']); $this->addCfg('/settings/NSCA/client/targets/default', 'address', $this->prefs['serverip']); $this->addCfg('/settings/NSCA/client/targets/default', 'port', '5667'); $this->addCfg('/settings/NSCA/client/targets/default', 'timeout', '30'); $this->addCfg('/settings/NSCA/client/targets/default', 'interval', '60s'); $host_check_interval = $this->host->getCfgValue('check_interval'); if (is_null($host_check_interval)) { $host_check_interval = 5; } $this->addCfg('/settings/external scripts/alias', 'host_check', 'check_ok message=Host\\ UP'); $this->addCfg('/settings/scheduler/schedules/host_check', 'command', 'host_check'); $this->addCfg('/settings/scheduler/schedules/host_check', 'interval', $host_check_interval . 'm'); }
/** * 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] . '&service_id=' . $serviceID . '&' . $host->getmyKeyColumn() . '=' . $host->getMyKey() . '&' . $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] . '&service_id=' . $serviceID . '&' . $host->getmyKeyColumn() . '=' . $host->getMyKey() . '&' . $host->nameColumn . '=' . $host->getName(), EaseTWBPart::GlyphIcon('remove') . ' ' . _('Přestat sledovat')), new EaseHtmlATag('servicetweak.php?service_id=' . $serviceID . '&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); }