function make_hint_row($type, $instance)
{
    $state = $instance['state'];
    if ($type == "other" && $instance["stuck_state"] == 1) {
        $state = "stuck";
    }
    $r = new CRow();
    if (in_array($type, array("poweron", "poweroff", "suspend"))) {
        $r->addItem(new CCheckBox("hostids[]", null, null, $instance['hostid']));
    }
    $hostScripts = API::Script()->getScriptsByHosts(zbx_objectValues(array($instance['host']), 'hostid'));
    $hostSpan = new CSpan(nbsp($instance['name']), 'link_menu menu-host');
    $hostSpan->setAttribute('data-menu', hostMenuData($instance['host'], $hostScripts[$instance['hostid']]));
    $r->addItem($hostSpan);
    $r->addItem(new CCol($state, get_item_level($state)));
    $r->addItem($instance['cpu']);
    $r->addItem($instance['memory']);
    $r->addItem($instance['main_interface']);
    if ($type == "other" && $instance["stuck_state"] == 1) {
        $question = $instance['stuck_question'];
        $json = new CJSON();
        $choiceinfos = $json->decode($instance['stuck_choices'], true);
        $answer_form = new CForm();
        $answer_form->setAction('#');
        $answer_form->setAttribute('id', "answer");
        $answer_form->addVar("driver", "vsphere");
        $answer_form->addVar("hostids[]", $instance['hostid']);
        $instancename = $instance['host']['host'];
        $answer_button = new CButton('answer', _('Answer'), "return checkAnswer('answer', 'choice', '{$instancename}', 'Execute');");
        $choice_table = new CTableInfo();
        foreach ($choiceinfos as $choice) {
            $radio = new CRadioButton('choice', $choice['key']);
            $label = new CLabel($choice['label']);
            $choice_table->addRow(new CRow(array($radio, $label)));
        }
        $answer_form->addItem($choice_table);
        $answer_form->addItem($answer_button);
        $question_span = new CSpan($question);
        $question_span->setHint($answer_form);
        $question_col = new CCol($question_span, 'warning');
        $r->addItem($question_col);
    } else {
        if ($type == "poweron") {
            $ssh_link = new CLink(_('connect'), "gateone.php?hostid={$instance['hostid']}");
            $ssh_link->setTarget("_blank");
            $r->addItem($ssh_link);
        }
    }
    return $r;
}
Beispiel #2
0
    if ($cancel_delete == 0) {
        delete_item_level($selected_id);
        display_notification(_('Selected book level has been deleted'));
    }
    //end if Delete group
    $Mode = 'RESET';
}
if ($Mode == 'RESET') {
    $selected_id = -1;
    $sav = get_post('show_inactive');
    unset($_POST);
    if ($sav) {
        $_POST['show_inactive'] = 1;
    }
}
$result = get_item_level(check_value('show_inactive'));
start_form();
start_table(TABLESTYLE, "width=30%");
$th = array(_("No"), _("Description"), "", "");
inactive_control_column($th);
table_header($th);
$k = 0;
while ($myrow = db_fetch($result)) {
    alt_table_row_color($k);
    label_cell($myrow["id"]);
    label_cell($myrow["description"]);
    inactive_control_cell($myrow["id"], $myrow["inactive"], 'levels', 'id');
    edit_button_cell("Edit" . $myrow["id"], _("Edit"));
    delete_button_cell("Delete" . $myrow["id"], _("Delete"));
    end_row();
}
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));
}