コード例 #1
0
function make_vspherestat_summary($preloading = false)
{
    $table = new CTableInfo();
    $table->setHeader(array(is_show_all_nodes() ? S_NODE : null, _('Host name'), _('Interface'), _('CPU threads [used/total]'), _('Memory(GB) [used/total]'), _('Datastores'), _('PoweredOn'), _('Suspended'), _('PoweredOff'), _('Others')));
    $hidden = new CDiv(null, "hidden");
    $hidden->setAttribute("type", "hidden");
    $script_itemkey = 'push_message.py[{$HYCLOPS_SERVER},{$HYCLOPS_PORT},vsphere,{HOST.HOST}]';
    $hosts = get_vsphere_hosts();
    if (empty($hosts)) {
        return null;
    }
    foreach ($hosts as $host) {
        if (!$preloading) {
            if (is_script_success($host['hostid'], $script_itemkey)) {
                $hardware_profiles = get_hardware_profiles($host['hostid']);
                $datastores = get_datastores($host['hostid']);
                $instances = get_instances($host['hostid']);
                $instances = filter_instances($instances);
                $r = new CRow();
                // Host name
                $col = new CCol($host['host'], 'vsphere');
                $col->setAttribute("hostid", $host['hostid']);
                $r->addItem($col);
                // IP
                $snmp_addresses = get_addresses($host['hostid'], INTERFACE_TYPE_SNMP);
                $r->addItem(reset($snmp_addresses));
                // CPU thread
                $r->addItem(level_check($hardware_profiles['cpu_assigned'], $hardware_profiles['cpu']));
                // Memory
                $r->addItem(level_check($hardware_profiles['memory_assigned'], $hardware_profiles['memory']));
                // Datastores
                $datastores_count = new CSpan(count($datastores), 'pointer');
                if (!empty($datastores)) {
                    $datastores_count->setHint(make_datastore_table($host['hostid'], $datastores));
                }
                $r->addItem(new CCol($datastores_count));
                // PowerOn
                $poweron_vms = $instances["running"];
                $poweron_count = new CSpan(count($poweron_vms), 'pointer');
                if (!empty($poweron_vms)) {
                    $poweron_count->setHint(make_vm_table('poweron', $poweron_vms));
                }
                $r->addItem(new CCol($poweron_count));
                // Suspended
                $suspend_vms = $instances["pending"];
                $suspend_count = new CSpan(count($suspend_vms), 'pointer');
                if (!empty($suspend_vms)) {
                    $suspend_count->setHint(make_vm_table('suspend', $suspend_vms));
                }
                $r->addItem(new CCol($suspend_count));
                // PowerOff
                $poweroff_vms = $instances["stopped"];
                $poweroff_count = new CSpan(count($poweroff_vms), 'pointer');
                if (!empty($poweroff_vms)) {
                    $poweroff_count->setHint(make_vm_table('poweroff', $poweroff_vms));
                }
                $r->addItem(new CCol($poweroff_count));
                // Other
                $other_vms = $instances["other"];
                $other_count = new CSpan(count($other_vms), 'pointer');
                if (!empty($other_vms)) {
                    $other_count->setHint(make_vm_table('other', $other_vms));
                }
                $other_state_col = new CCol($other_count, count($other_vms) > 0 ? 'high' : null);
                $r->addItem($other_state_col);
                $table->addRow($r);
                zbx_add_post_js('chkbxRange.pageGoName = "vms";');
            } else {
                $snmp_addresses = get_addresses($host['hostid'], INTERFACE_TYPE_SNMP);
                $r = new CRow();
                $r->addItem($host['host']);
                $r->addItem(reset($snmp_addresses));
                $r->addItem(new CCol(_('script failed'), "high"));
                $r->addItem(array("-", "-", "-", "-", "-", "-"));
                $table->addRow($r);
            }
        } else {
            // display loading message
            $snmp_addresses = get_addresses($host['hostid'], INTERFACE_TYPE_SNMP);
            $r = new CRow();
            $r->addItem($host['host']);
            $r->addItem(reset($snmp_addresses));
            $r->addItem(_('loading...'));
            $r->addItem(array("-", "-", "-", "-", "-", "-"));
            $table->addRow($r);
        }
    }
    #insert_js('init_vsphere_contextmenu()');
    $script = new CJSScript(get_js("jQuery('#hat_vspherestat_footer').html('" . _s('Updated: %s', zbx_date2str(_('H:i:s'))) . "')"));
    return new CDiv(array($table, $script));
}
コード例 #2
0
ファイル: add.php プロジェクト: yunsite/easysns
<?php

if (!is_login()) {
    info_page('请登录后查看');
}
if (!level_check(app_config('add_level'))) {
    info_page('您没有权限进行此操作');
}
include_once dirname(__FILE__) . '/function.php';
$data = array();
$data['ci_top_title'] = '添加' . app_config('model_name');
$width = intval(app_config('pic_width')) ? 'width:' . intval(app_config('pic_width')) . 'px;' : '90px';
$height = intval(app_config('pic_height')) ? 'height:' . intval(app_config('pic_height')) . 'px;' : '120px';
$data['pic_style'] = ' style="' . $width . $height . '" ';
layout($data, 'default', 'app');