/**
  * Function for getting class object, implements Singleton.
  *
  * @static
  * @return object
  */
 public static function i()
 {
     if (null === self::$_instance) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
예제 #2
0
function make_status_of_zbx()
{
    global $ZBX_SERVER, $ZBX_SERVER_PORT;
    $table = new CTableInfo();
    $table->setHeader(array(_('Parameter'), _('Value'), _('Details')));
    show_messages();
    // because in function get_status(); function clear_messages() is called when fsockopen() fails.
    $status = get_status();
    $table->addRow(array(_('Zabbix server is running'), new CSpan($status['zabbix_server'], $status['zabbix_server'] == _('Yes') ? 'off' : 'on'), isset($ZBX_SERVER, $ZBX_SERVER_PORT) ? $ZBX_SERVER . ':' . $ZBX_SERVER_PORT : _('Zabbix server IP or port is not set!')));
    $title = new CSpan(_('Number of hosts (monitored/not monitored/templates)'));
    $title->setAttribute('title', 'asdad');
    $table->addRow(array(_('Number of hosts (monitored/not monitored/templates)'), $status['hosts_count'], array(new CSpan($status['hosts_count_monitored'], 'off'), ' / ', new CSpan($status['hosts_count_not_monitored'], 'on'), ' / ', new CSpan($status['hosts_count_template'], 'unknown'))));
    $title = new CSpan(_('Number of items (monitored/disabled/not supported)'));
    $title->setAttribute('title', _('Only items assigned to enabled hosts are counted'));
    $table->addRow(array($title, $status['items_count'], array(new CSpan($status['items_count_monitored'], 'off'), ' / ', new CSpan($status['items_count_disabled'], 'on'), ' / ', new CSpan($status['items_count_not_supported'], 'unknown'))));
    $title = new CSpan(_('Number of triggers (enabled/disabled) [problem/ok]'));
    $title->setAttribute('title', _('Only triggers assigned to enabled hosts and depending on enabled items are counted'));
    $table->addRow(array($title, $status['triggers_count'], array($status['triggers_count_enabled'], ' / ', $status['triggers_count_disabled'], ' [', new CSpan($status['triggers_count_on'], 'on'), ' / ', new CSpan($status['triggers_count_off'], 'off'), ']')));
    $table->addRow(array(_('Number of users (online)'), $status['users_count'], new CSpan($status['users_online'], 'green')));
    $table->addRow(array(_('Required server performance, new values per second'), $status['qps_total'], ' - '));
    // check requirements
    if (CWebUser::$data['type'] == USER_TYPE_SUPER_ADMIN) {
        $frontendSetup = new FrontendSetup();
        $reqs = $frontendSetup->checkRequirements();
        foreach ($reqs as $req) {
            if ($req['result'] != FrontendSetup::CHECK_OK) {
                $class = $req['result'] == FrontendSetup::CHECK_WARNING ? 'notice' : 'fail';
                $table->addRow(array(new CSpan($req['name'], $class), new CSpan($req['current'], $class), new CSpan($req['error'], $class)));
            }
        }
    }
    $script = new CJSScript(get_js("jQuery('#hat_stszbx_footer').html('" . _s('Updated: %s', zbx_date2str(_('H:i:s'))) . "')"));
    return new CDiv(array($table, $script));
}
예제 #3
0
 function stage5()
 {
     $dbType = $this->getConfig('DB_TYPE');
     $frontendSetup = new FrontendSetup();
     $databases = $frontendSetup->getSupportedDatabases();
     $table = new CTable(null, 'requirements');
     $table->setAlign('center');
     $table->addRow(array(new CCol(_('Database type'), 'header'), $databases[$dbType]));
     switch ($dbType) {
         case ZBX_DB_SQLITE3:
             $table->addRow(array(new CCol(_('Database file'), 'header'), $this->getConfig('DB_DATABASE')));
             break;
         default:
             $table->addRow(array(new CCol(_('Database server'), 'header'), $this->getConfig('DB_SERVER')));
             $dbPort = $this->getConfig('DB_PORT');
             $table->addRow(array(new CCol(_('Database port'), 'header'), $dbPort == 0 ? _('default') : $dbPort));
             $table->addRow(array(new CCol(_('Database name'), 'header'), $this->getConfig('DB_DATABASE')));
             $table->addRow(array(new CCol(_('Database user'), 'header'), $this->getConfig('DB_USER')));
             $table->addRow(array(new CCol(_('Database password'), 'header'), preg_replace('/./', '*', $this->getConfig('DB_PASSWORD'))));
             if ($dbType == ZBX_DB_DB2) {
                 $table->addRow(array(new CCol(_('Database schema'), 'header'), $this->getConfig('DB_SCHEMA')));
             }
             break;
     }
     $table->addRow(BR());
     $table->addRow(array(new CCol(_('Zabbix server'), 'header'), $this->getConfig('ZBX_SERVER')));
     $table->addRow(array(new CCol(_('Zabbix server port'), 'header'), $this->getConfig('ZBX_SERVER_PORT')));
     $table->addRow(array(new CCol(_('Zabbix server name'), 'header'), $this->getConfig('ZBX_SERVER_NAME')));
     return array('Please check configuration parameters.', BR(), 'If all is correct, press "Next" button, or "Previous" button to change configuration parameters.', BR(), BR(), $table);
 }
 function stage2()
 {
     $table = new CTable(null, 'requirements');
     $table->setAlign('center');
     $final_result = true;
     $table->addRow(array(SPACE, new CCol(_('Current value'), 'header'), new CCol(_('Required'), 'header')));
     $reqs = FrontendSetup::i()->checkRequirements();
     foreach ($reqs as $req) {
         $result = null;
         if ($req['result']) {
             $result = new CSpan(_('OK'), 'green');
         } else {
             $result = new CSpan(_('Fail'), 'link_menu fail');
             $result->setHint($req['error']);
         }
         $table->addRow(array(new CCol($req['name'], 'header'), $req['current'], $req['required'] ? $req['required'] : SPACE, $result), $req['result'] ? SPACE : 'fail');
         $final_result &= (bool) $req['result'];
     }
     if (!$final_result) {
         $this->DISABLE_NEXT_BUTTON = true;
         $this->addVar('trouble', true);
         $final_result = array(_('Please correct all issues and press "Retry" button'), BR(), new CSubmit('retry', _('Retry')));
     } else {
         $this->DISABLE_NEXT_BUTTON = false;
         $final_result = array(new CSpan(_('OK'), 'ok'));
     }
     return array(new CDiv(array(BR(), $table, BR()), 'table_wraper'), new CDiv($final_result, 'info_bar'));
 }