/**
  * Editor k přidávání členů skupiny
  *
  * @param IEHosts $Host
  */
 public function __construct($Host)
 {
     $FieldName = 'parents';
     $InitialContent = new EaseTWBPanel(_('Potomci'));
     $InitialContent->setTagCss(array('width' => '100%'));
     if (is_null($Host->getMyKey())) {
         $InitialContent->addItem(_('Nejprve je potřeba uložit záznam'));
     } else {
         $Service = new IEService();
         $ServicesAssigned = $Service->myDbLink->queryToArray('SELECT ' . $Service->myKeyColumn . ',' . $Service->nameColumn . ' FROM ' . $Service->myTable . ' WHERE ' . $FieldName . ' LIKE \'%"' . $Host->getName() . '"%\'', $Service->myKeyColumn);
         $AllServices = $Service->getListing();
         foreach ($AllServices as $ServiceID => $ServiceInfo) {
             if ($ServiceInfo['register'] != 1) {
                 unset($AllServices[$ServiceID]);
             }
         }
         foreach ($ServicesAssigned as $ServiceID => $ServiceInfo) {
             unset($AllServices[$ServiceID]);
         }
         if (count($AllServices)) {
             foreach ($AllServices as $ServiceID => $ServiceInfo) {
                 $Jellybean = new EaseHtmlSpanTag($ServiceInfo[$Service->nameColumn], null, array('class' => 'jellybean gray'));
                 $Jellybean->addItem(new EaseHtmlATag('?addservice=' . $ServiceInfo[$Service->nameColumn] . '&service_id=' . $ServiceID . '&' . $Host->getmyKeyColumn() . '=' . $Host->getMyKey() . '&' . $Host->nameColumn . '=' . $Host->getName(), $ServiceInfo[$Service->nameColumn]));
                 $InitialContent->addItem($Jellybean);
             }
         }
         if (count($ServicesAssigned)) {
             $InitialContent->addItem('</br>');
             foreach ($ServicesAssigned as $ServiceID => $ServiceInfo) {
                 $Jellybean = new EaseHtmlSpanTag($ServiceInfo[$Service->nameColumn], null, array('class' => 'jellybean'));
                 $Jellybean->addItem($ServiceInfo[$Service->nameColumn]);
                 $Jellybean->addItem(new EaseHtmlATag('?delservice=' . $ServiceInfo[$Service->nameColumn] . '&amp;service_id=' . $ServiceID . '&amp;' . $Host->getmyKeyColumn() . '=' . $Host->getMyKey() . '&amp;' . $Host->nameColumn . '=' . $Host->getName(), EaseTWBPart::GlyphIcon('remove')));
                 $InitialContent->addItem($Jellybean);
             }
         }
     }
     parent::__construct($InitialContent);
 }
 function cfgServices()
 {
     $service = new IEService();
     $servicesAssigned = $service->myDbLink->queryToArray('SELECT ' . $service->myKeyColumn . ',' . $service->nameColumn . ',`use` FROM ' . $service->myTable . ' WHERE host_name LIKE \'%"' . $this->host->getName() . '"%\'', $service->myKeyColumn);
     $allServices = $service->getListing(null, true, array('platform', 'check_command-remote', 'check_command-params', 'passive_checks_enabled', 'active_checks_enabled', 'use', 'check_interval', 'check_command-remote'));
     foreach ($allServices as $serviceID => $serviceInfo) {
         if (!array_key_exists($serviceID, $servicesAssigned)) {
             unset($allServices[$serviceID]);
             continue;
             //Služba není přiřazena k hostu
         }
     }
     /* Naplní hodnoty z předloh */
     $usedCache = array();
     $commandsCache = array();
     foreach ($allServices as $rowId => $service) {
         if (isset($service['use'])) {
             $remote = $service['check_command-remote'];
             if (!isset($commandsCache[$remote])) {
                 $command = new IECommand($remote);
                 $script_id = $command->getDataValue('script_id');
                 if ($script_id) {
                     $this->scriptsToDeploy[$command->getName()] = $script_id;
                 }
                 $commandsCache[$remote] = $command->getData();
             }
         }
         if (isset($service['use'])) {
             $use = $service['use'];
             if (!isset($usedCache[$use])) {
                 $used = new IEService();
                 $used->nameColumn = 'name';
                 if ($used->loadFromMySQL($use)) {
                     $used->resetObjectIdentity();
                     $usedCache[$use] = $used->getData();
                 }
             }
             if (isset($usedCache[$use])) {
                 foreach ($usedCache[$use] as $templateKey => $templateValue) {
                     if ($templateKey != 'check_interval') {
                         continue;
                     }
                     if (!is_null($templateValue) && !isset($allServices[$rowId][$templateKey])) {
                         $allServices[$rowId][$templateKey] = $templateValue;
                     }
                 }
             }
         }
     }
     foreach ($allServices as $serviceId => $service) {
         $serviceName = $service['service_description'];
         $serviceCmd = $service['check_command-remote'];
         if (is_null($serviceCmd)) {
             continue;
         }
         $serviceParams = $service['check_command-params'];
         switch ($this->platform) {
             case 'windows':
                 $this->nscBatArray[] = "\n\nREM #" . $service['service_id'] . ' ' . $serviceName . "\n";
                 break;
             case 'linux':
                 $this->nscBatArray[] = "\n\n# #" . $service['service_id'] . ' ' . $serviceName . "\n";
                 break;
             default:
                 break;
         }
         if (isset($commandsCache[$serviceCmd])) {
             $cmdline = $commandsCache[$serviceCmd]['command_line'];
         } else {
             $cmdline = $serviceCmd;
         }
         $checkCommand = str_replace('\\', '\\\\', $cmdline . ' ' . $serviceParams);
         if (preg_match("/\\.(vbs|bat|ps1|wsf)/", $cmdline)) {
             $this->addCfg('/settings/external scripts/wrapped scripts', $this->stripServiceName($serviceName), $checkCommand);
         } else {
             $this->addCfg('/settings/external scripts/alias', $this->stripServiceName($serviceName), $checkCommand);
         }
         if ($this->hostPassiveMode) {
             $this->addCfg('/settings/scheduler/schedules/' . $this->stripServiceName($serviceName) . '-' . EaseShared::user()->getUserLogin(), 'command', $this->stripServiceName($serviceName));
             $this->addCfg('/settings/scheduler/schedules/' . $this->stripServiceName($serviceName) . '-' . EaseShared::user()->getUserLogin(), 'interval', $service['check_interval'] . 'm');
         }
     }
 }
 /**
  * Vložení menu
  */
 public function afterAdd()
 {
     $nav = $this->addItem(new IEBootstrapMenu());
     $user = EaseShared::user();
     $userID = $user->getUserID();
     if ($userID) {
         //Authenticated user
         $nav->addMenuItem(new IENavBarSearchBox('search', 'search.php'));
         if ($user->getSettingValue('admin')) {
             $users = $user->getColumnsFromMySQL(array('id', 'login'), array('id' => '!0'), 'login', $user->getmyKeyColumn());
             $userList = array();
             if ($users) {
                 foreach ($users as $uID => $uInfo) {
                     $userList['userinfo.php?user_id=' . $uInfo['id']] = EaseTWBPart::GlyphIcon('user') . '&nbsp;' . $uInfo['login'];
                 }
                 if (count($userList)) {
                     $userList[] = '';
                 }
             }
             //                $usergroups = $this->myDbLink->queryToArray('SELECT * FROM user_groups' . 'usergroup_id');
             $nav->addDropDownMenu(_('Uživatelé'), array_merge($userList, array('createaccount.php' => EaseTWBPart::GlyphIcon('plus') . ' ' . _('Nový uživatel'), 'users.php' => EaseTWBPart::GlyphIcon('list') . '&nbsp;' . _('Přehled uživatelů'), 'usergroup.php' => EaseTWBPart::GlyphIcon('plus') . ' ' . _('Nová skupina uživatelů'), 'usergroups.php' => EaseTWBPart::GlyphIcon('list') . '&nbsp;' . _('Přehled skupin uživatelů'))));
         }
         $this->changesButton($nav);
         $this->groupsHostsMenu($nav);
         //            $nav->addDropDownMenu(_('Hosti'), $hostGroupHostsMenuItem);
         if (EaseShared::user()->getSettingValue('admin')) {
             $nav->addDropDownMenu(_('Služby'), array('wizard-service.php' => EaseTWBPart::GlyphIcon('forward') . ' ' . _('Průvodce založením služby'), 'service.php' => EaseTWBPart::GlyphIcon('plus') . ' ' . _('Nová služba'), 'services.php' => EaseTWBPart::GlyphIcon('list') . ' ' . _('Přehled služeb'), 'servicegroup.php' => EaseTWBPart::GlyphIcon('plus') . ' ' . _('Nová skupina služeb'), 'servicegroups.php' => EaseTWBPart::GlyphIcon('list') . ' ' . _('Přehled skupin služeb'), '' => '', 'stemplate.php?action=new' => EaseTWBPart::GlyphIcon('plus') . ' ' . _('Nová předloha sledované služby'), 'stemplates.php' => EaseTWBPart::GlyphIcon('list') . ' ' . _('Přehled předloh sled. sl.')));
         } else {
             $service = new IEService();
             $services = $service->getListing(null, null, array('icon_image', 'platform'));
             if (count($services)) {
                 $services_menu = array('services.php' => EaseTWBPart::GlyphIcon('list') . ' ' . _('Přehled služeb'));
                 foreach ($services as $serviceID => $serviceInfo) {
                     $services_menu['servicetweak.php?service_id=' . $serviceID] = $serviceInfo[$service->nameColumn];
                 }
                 $nav->addDropDownMenu(_('Služby'), $services_menu);
             }
         }
         $contact = new IEContact();
         $contacts = $contact->getListing(null, null, array('parent_id'));
         foreach ($contacts as $contactID => $contactInfo) {
             //Vyfiltrovat pouze primární kontakty
             if ($contactInfo['parent_id']) {
                 unset($contacts[$contactID]);
             }
         }
         if (count($contacts)) {
             $contacts_menu = array('contacts.php' => EaseTWBPart::GlyphIcon('list') . ' ' . _('Přehled Kontaktů'));
             foreach ($contacts as $contactID => $contactInfo) {
                 $contacts_menu['contacttweak.php?contact_id=' . $contactID] = $contactInfo[$contact->nameColumn];
             }
             $contacts_menu[] = '';
         } else {
             $contacts_menu = array();
         }
         $nav->addDropDownMenu(_('Kontakty'), array_merge($contacts_menu, array('contacts.php' => EaseTWBPart::GlyphIcon('list') . ' ' . _('Přehled kontaktů'), 'newcontact.php' => EaseTWBPart::GlyphIcon('plus') . ' ' . _('Nový kontakt'), 'contactgroups.php' => EaseTWBPart::GlyphIcon('list') . ' ' . _('Přehled skupin kontaktů'), 'contactgroup.php' => EaseTWBPart::GlyphIcon('edit') . ' ' . _('Nová skupina kontaktů'))));
         if ($user->getSettingValue('admin')) {
             $nav->addDropDownMenu(_('Příkaz'), array('command.php' => EaseTWBPart::GlyphIcon('edit') . ' ' . _('Nový příkaz'), 'commands.php' => EaseTWBPart::GlyphIcon('list-alt') . ' ' . _('Přehled příkazů'), 'importcommand.php' => EaseTWBPart::GlyphIcon('import') . ' ' . _('Importovat'), '', 'script.php' => EaseTWBPart::GlyphIcon('edit') . ' ' . _('Nový skript'), 'scripts.php' => EaseTWBPart::GlyphIcon('list-alt') . ' ' . _('Přehled skriptů')));
             $nav->addDropDownMenu(_('Rozšířené'), array('timeperiods.php' => EaseTWBPart::GlyphIcon('list') . ' ' . _('Přehled časových period'), 'timeperiod.php' => EaseTWBPart::GlyphIcon('plus') . ' ' . _('Nová časová perioda'), 'preferences.php' => EaseTWBPart::GlyphIcon('wrench') . ' ' . _('Nastavení icingy'), 'regenall.php' => EaseTWBPart::GlyphIcon('ok') . ' ' . _('Přegenerovat všechny konfiguráky'), 'reset.php' => EaseTWBPart::GlyphIcon('cog') . ' ' . _('Reset Objektů'), 'dbrecreate.php' => EaseTWBPart::GlyphIcon('wrench') . ' ' . _('Reinicializovat databázi'), 'fixer.php' => EaseTWBPart::GlyphIcon('ok-circle') . ' ' . _('Opravit databázi'), 'import.php' => EaseTWBPart::GlyphIcon('import') . ' ' . _('Importovat')));
         }
         $results = array('nagstamon.php' => EaseTWBPart::GlyphIcon('info') . ' ' . _('PC Lin/Win/Mac'), 'anag.php' => EaseTWBPart::GlyphIcon('info') . ' ' . _('Android'), 'wpnag.php' => EaseTWBPart::GlyphIcon('Info') . ' ' . _('Win Phone'));
         if (file_exists('/etc/apache2/conf-enabled/icinga-web.conf')) {
             $results['/icinga-web/'] = EaseTWBPart::GlyphIcon('Info') . ' ' . _('Web');
         }
         $nav->addDropDownMenu(_('Výsledky testů'), $results);
     }
 }
 /**
  * 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);
 }
Beispiel #5
0
%NSCLIENT% settings --path /settings/NSCA/client/targets/default --key "allowed ciphers" --set "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH"
%NSCLIENT% settings --path /settings/NSCA/client/targets/default --key encryption --set 3des
%NSCLIENT% settings --path /settings/NSCA/client/targets/default --key password --set ' . $prefs['nscapassword'] . '
%NSCLIENT% settings --path /settings/NSCA/client/targets/default --key address --set ' . $prefs['serverip'] . '
%NSCLIENT% settings --path /settings/NSCA/client/targets/default --key port --set 5667
%NSCLIENT% settings --path /settings/NSCA/client/targets/default --key timeout --set 30
%NSCLIENT% settings --path /settings/scheduler/schedules/default --key interval --set 60s
';
$hostName = $host->getName();
$service = new IEService();
$host_passive = (bool) $host->getDataValue('passive_checks_enabled');
if (!$host_passive) {
    die(_('Host neni konfigurovan pro pasivni checky'));
}
$servicesAssigned = $service->myDbLink->queryToArray('SELECT ' . $service->myKeyColumn . ',' . $service->nameColumn . ',`use` FROM ' . $service->myTable . ' WHERE host_name LIKE \'%"' . $host->getName() . '"%\'', $service->myKeyColumn);
$allServices = $service->getListing(null, true, array('platform', 'check_command-remote', 'check_command-params', 'passive_checks_enabled', 'active_checks_enabled', 'use', 'check_interval', 'check_command-remote'));
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 (!$servicePassive) {
        unset($allServices[$serviceID]);
        continue;
    }
 /**
  * Konfigurace sluzeb
  */
 function cfgServices()
 {
     $service = new IEService();
     $servicesAssigned = $service->myDbLink->queryToArray('SELECT ' . $service->myKeyColumn . ',' . $service->nameColumn . ',`use` FROM ' . $service->myTable . ' WHERE host_name LIKE \'%"' . $this->host->getName() . '"%\'', $service->myKeyColumn);
     $allServices = $service->getListing(null, true, array('platform', 'check_command-remote', 'check_command-params', 'passive_checks_enabled', 'active_checks_enabled', 'use', 'check_interval', 'check_command-remote'));
     foreach ($allServices as $serviceID => $serviceInfo) {
         if (!array_key_exists($serviceID, $servicesAssigned)) {
             unset($allServices[$serviceID]);
             continue;
             //Služba není přiřazena k hostu
         }
     }
     /* Naplní hodnoty z předloh */
     $usedCache = array();
     $commandsCache = array();
     foreach ($allServices as $rowId => $service) {
         if (isset($service['use'])) {
             $remote = $service['check_command-remote'];
             if (!isset($commandsCache[$remote])) {
                 $command = new IECommand($remote);
                 $commandsCache[$remote] = $command->getData();
             }
         }
         if (isset($service['use'])) {
             $use = $service['use'];
             if (!isset($usedCache[$use])) {
                 $used = new IEService();
                 $used->nameColumn = 'name';
                 if ($used->loadFromMySQL($use)) {
                     $used->resetObjectIdentity();
                     $usedCache[$use] = $used->getData();
                 }
             }
             if (isset($usedCache[$use])) {
                 foreach ($usedCache[$use] as $templateKey => $templateValue) {
                     if ($templateKey != 'check_interval') {
                         continue;
                     }
                     if (!is_null($templateValue) && !isset($allServices[$rowId][$templateKey])) {
                         $allServices[$rowId][$templateKey] = $templateValue;
                     }
                 }
             }
         }
     }
     foreach ($allServices as $serviceId => $service) {
         $serviceName = $service['service_description'];
         $serviceCmd = $service['check_command-remote'];
         if (is_null($serviceCmd)) {
             continue;
         }
         $serviceParams = $service['check_command-params'];
         $this->nscCfgArray[] = "\n# #" . $service['service_id'] . ' ' . $serviceName;
         if (isset($commandsCache[$serviceCmd])) {
             if (isset($commandsCache[$serviceCmd]['deploy'])) {
                 $this->nscCfgArray[] = $commandsCache[$serviceCmd]['deploy'];
             }
             $cmdline = $commandsCache[$serviceCmd]['command_line'];
         } else {
             $cmdline = $serviceCmd;
         }
         $this->addCfg('command[' . str_replace(' ', '_', $serviceName) . ']', $cmdline . ' ' . $serviceParams);
     }
 }