/**
  * 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.º 2
0
 public function fullEditor()
 {
     $tabs = new EaseTWBTabs('editorTabs');
     $tabs->addTab(_('Více nastavení:'));
     if (EaseShared::user()->getSettingValue('admin')) {
         $this->objectEdited->keywordsInfo[$this->objectEdited->userColumn] = array('severity' => 'advanced', 'title' => 'vlastník');
         $this->objectEdited->useKeywords[$this->objectEdited->userColumn] = 'USER';
     }
     if ($this->objectEdited->allowTemplating) {
         if (!$this->objectEdited->getCfgValue('register')) {
             $this->addStatusMessage('toto je pouze předloha');
             foreach ($this->objectEdited->keywordsInfo as $Kw => $Props) {
                 unset($this->objectEdited->keywordsInfo[$Kw]['required']);
             }
             $this->objectEdited->keywordsInfo['name']['required'] = true;
             $this->objectEdited->keywordsInfo['register']['required'] = true;
         } else {
             $this->objectEdited->keywordsInfo['name']['required'] = false;
             $this->objectEdited->keywordsInfo['register']['required'] = false;
         }
     }
     if (isset($this->objectEdited->useKeywords['generate']) && !(int) $this->objectEdited->getDataValue('generate')) {
         $this->addStatusMessage(_('tento záznam se nebude generovat do konfigurace'), 'warning');
     }
     if ($this->objectEdited->publicRecords) {
         if ((int) $this->objectEdited->getDataValue('public')) {
             $this->addStatusMessage(_('tento záznam je veřejný'));
         }
     }
     $this->addItem('<div class="error" style=""><span></span><br clear="all"></div>');
     $use = $this->objectEdited->getDataValue('use');
     if (!is_null($use)) {
         $template = clone $this->objectEdited;
         $template->loadFromMySQL((int) $use);
     }
     foreach ($this->objectEdited->useKeywords as $fieldName => $fieldType) {
         $keywordInfo = $this->objectEdited->keywordsInfo[$fieldName];
         if (!isset($keywordInfo['severity'])) {
             $this->addStatusMessage(sprintf(_('Sloupeček %s/%s nemá uvedenou závažnost'), $fieldName, get_class($this->objectEdited)), 'warning');
             $keywordInfo['severity'] = null;
         }
         if (!count($keywordInfo)) {
             continue;
         }
         if (isset($keywordInfo['hidden'])) {
             continue;
         }
         if (!isset($keywordInfo)) {
             $this->addStatusMessage(_('Info Chybí') . '   ' . $fieldType . ' ' . $fieldName, 'warning');
             continue;
         }
         if (!isset($keywordInfo['title'])) {
             $this->addStatusMessage(_('sloupec bez popisku') . ' ' . $fieldName, 'warning');
         }
         if (!strlen($keywordInfo['title'])) {
             continue;
         }
         if (isset($keywordInfo['required']) && $keywordInfo['required']) {
             $this->reqFields[$fieldName] = $fieldType;
             $required = true;
         } else {
             $required = false;
         }
         $value = $this->objectEdited->getDataValue($fieldName);
         //            if (is_null($value)) {
         //                if (!EaseShared::webPage()->isPosted()) {
         //                    $value = '';
         //                } else {
         //                    continue;
         //                }
         //            }
         if ($value === 'NULL') {
             $value = null;
         }
         if ($this->objectEdited->allowTemplating) {
             if ($this->objectEdited->isTemplate()) {
                 if (EaseShared::webPage()->isPosted() && is_null($value) && $required) {
                     $this->addStatusMessage(_('Není vyplněna povinná položka') . ' ' . $keywordInfo['title'], 'warning');
                 }
             }
         } else {
             if (EaseShared::webPage()->isPosted() && is_null($value) && $required) {
                 $this->addStatusMessage(_('Není vyplněna povinná položka') . ' ' . $keywordInfo['title'], 'warning');
             }
         }
         switch ($keywordInfo['severity']) {
             case 'advanced':
                 if (!isset($advancedTab)) {
                     $advancedTab = $tabs->addTab(_('Rozšířené'));
                 }
                 $mainFieldBlock = $advancedTab->addItem(new EaseHtmlDivTag($fieldName . '-block', null, array('class' => 'fieldblock')));
                 break;
             case 'optional':
                 if (!isset($optionalTab)) {
                     $optionalTab = $tabs->addTab(_('Volitelné'));
                 }
                 $mainFieldBlock = $optionalTab->addItem(new EaseHtmlDivTag($fieldName . '-block', null, array('class' => 'fieldblock')));
                 break;
             default:
                 $mainFieldBlock = $this->addItem(new EaseHtmlDivTag($fieldName . '-block', null, array('class' => 'fieldblock')));
                 break;
         }
         $fieldLabel = $mainFieldBlock->addItem(new EaseHtmlDivTag(null, '<a>' . $fieldName . '</a>&nbsp;', array('class' => 'FieldLabel', 'onClick' => "\$('#" . $fieldName . "-controls').toggle('slow');")));
         /**
         
          if (!$required || !(int) $this->objectEdited->getDataValue('register')) {
          $fieldLabel->addItem(new EaseHtmlATag('#', EaseTWBPart::GlyphIcon('remove'), array('onClick' => '$(\'#' . $fieldName . '-block\').empty().html(\'<input type=hidden name=' . $fieldName . ' value=NULL><div class=FieldLabel>' . $fieldName . '</div>\'); return false;')));
          $fieldLabel->setTagClass('FieldLabel');
          } else {
          $mainFieldBlock->setTagClass('fieldblock req');
          }
         */
         $fieldBlock = $mainFieldBlock->addItem(new EaseHtmlDivTag($fieldName . '-controls'));
         if (!$this->objectEdited->isOwnedBy() && !EaseShared::user()->getSettingValue('admin')) {
             //Editovat může pouze vlastník
             if ($this->objectEdited->getId()) {
                 if (substr($value, 0, 2) == 'a:') {
                     $value = unserialize($value);
                     if (is_array($value)) {
                         $value = implode(',', $value);
                     }
                 }
                 $fieldBlock->addItem($value);
                 continue;
             }
         }
         if (isset($template)) {
             $tempValue = $template->getDataValue($fieldName);
             if (!is_null($tempValue) && $fieldName != $this->objectEdited->nameColumn && !$required) {
                 //Skrýt nedůležité položky
                 // EaseShared::webPage()->addJavaScript("$('#" . $fieldName . "-controls').hide();", null, true);
             }
         }
         $this->insertWidget($fieldBlock, $fieldName, $value);
     }
     $this->addItem($tabs);
 }
Exemplo n.º 3
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);
 }