function make_vm_table($type, $instances) { $form_name = "{$type}_vms"; // Create Form $form = new CForm(); $form->setName($form_name); $form->setAttribute('id', $form_name); $form->addVar('driver', 'vsphere'); $form->setAction('#'); // Create Table Header $table = new CTableInfo(); switch ($type) { case 'poweron': $table->setHeader(array(is_show_all_nodes() ? _('Node') : null, new CCheckBox('all_hosts', null, "checkAllHosts('" . $form_name . "','all_hosts','');"), _('Instance name'), _('Status'), _('CPU threads'), _('Memory(GB)'), _('Interface'), _('SSH Connect'))); break; case 'poweroff': case 'suspend': $table->setHeader(array(is_show_all_nodes() ? _('Node') : null, new CCheckBox('all_hosts', null, "checkAllHosts('" . $form_name . "','all_hosts','');"), _('Instance name'), _('Status'), _('CPU threads'), _('Memory(GB)'), _('Interface'))); break; case 'other': $table->setHeader(array(is_show_all_nodes() ? _('Node') : null, _('Instance name'), _('Status'), _('CPU thread'), _('Memory(GB)'), _('Interface'), _('Question'))); break; default: return null; } // Create Row foreach ($instances as $instance) { $table->addRow(make_hint_row($type, $instance)); } $hostids = array_map(function ($instance) { return $instance['hostid']; }, $instances); $footer = get_table_header(make_operation_box_footer($hostids, $form_name)); $form->addItem(array('', $table, '', $footer)); return $form; }
function make_ipmistat_summary($preloading = false) { $form_name = 'ipmi_control'; $table = new CTableInfo(); $ipmicontrol_form = new CForm(); $ipmicontrol_form->setName('ipmi_control'); $ipmicontrol_form->setAttribute('id', 'ipmi_control'); $ipmicontrol_form->addVar('driver', 'ipmi'); $script_itemkey = 'push_message.py[{$HYCLOPS_SERVER},{$HYCLOPS_PORT},ipmi,{HOST.HOST}]'; $table->setHeader(array(is_show_all_nodes() ? S_NODE : null, new CCheckBox('all_physical_hosts', null, "checkAllHosts('" . $ipmicontrol_form->getName() . "', 'all_physical_hosts', '');"), _('Host name'), _('IPMI interface'), _('Status'), _('Problems'))); $hosts = get_ipmi_hosts(); if (empty($hosts)) { return null; } foreach ($hosts as $host) { $triggers = get_triggers($host['hostid']); $trigger_count = count($triggers); // get State if (!$preloading) { if (is_script_success($host['hostid'], $script_itemkey)) { $state = strtolower(get_item_value($host['hostid'], "ipmi.state.text")); } else { $state = _('script failed'); } } else { $state = _('loading...'); } // Check box $checkbox_col = new CCheckBox("hostids[]", null, null, $host['hostid']); if (!is_operation_available("ipmi", $state)) { $checkbox_col->attributes['disabled'] = 'disabled'; } // Host name if ($trigger_count == 0) { $hostname_col = new CCol(new CSpan($host['host'])); } else { $hostname_col = new CLink(new CSpan($host['host']), 'tr_status.php?&hostid=' . $host['hostid'] . '&show_triggers=' . TRIGGERS_OPTION_ONLYTRUE); } // IPMI Interfaces $ipmi_addresses = get_addresses($host['hostid'], INTERFACE_TYPE_IPMI); $ipmi_ip_col = new CCol(reset($ipmi_addresses)); // Status $state_col = new CCol($state, get_item_level($state)); // Problem if ($trigger_count == 0) { $problem_col = new CCol($trigger_count, 'normal'); } else { $problem_col = new CCol($trigger_count, 'high'); $problem_col->setHint(make_trigger_table($triggers, $hostname_col)); } $r = new CRow(); $r->addItem($checkbox_col); $r->addItem($hostname_col); $r->addItem($ipmi_ip_col); $r->addItem($state_col); $r->addItem($problem_col); $table->addRow($r); } $table->setFooter(new CCol(make_operation_box_footer(zbx_objectValues($hosts, 'hostid'), $form_name))); $ipmicontrol_form->addItem($table); $script = new CJSScript(get_js("jQuery('#hat_ipmistat_footer').html('" . _s('Updated: %s', zbx_date2str(_('H:i:s'))) . "')")); return new CDiv(array($ipmicontrol_form, $script)); }