public function _getContent($refresh = false)
 {
     $table = new CTableInfo(_('No web scenarios found.'));
     $table->setHeader(array(_('Website'), _('Links'), _('Broken Links')));
     $data = array();
     // fetch links between HTTP tests and host groups
     $result = DbFetchArray(DBselect('SELECT website.*, sum(status LIKE "2%") as links_ok, sum(status != "" AND NOT status LIKE "2%") as links_404, sum(status = "" OR status is null) as links_unchecked FROM zabbix_spider.website LEFT JOIN zabbix_spider.page ON page.website = Website.aid group by page.website;'));
     foreach ($result as $row) {
         $deadlinks = DbFetchArray(DBselect('SELECT * FROM zabbix_spider.page  WHERE NOT status IS NULL AND status != "200" AND status != "" and website = ' . $row['aid']));
         $deadlink_output = array();
         $link_options = array("target" => "_blank");
         foreach ($deadlinks as $deadlink) {
             $link_link = new CLink($deadlink['url'] == "" ? "root" : substr($deadlink['url'], 0, 50), ($deadlink['url'] == "" || $deadlink['url'][0] == "/" ? $row['url'] : "") . $deadlink['url']);
             $link_link->setTarget("_blank");
             $map_link = new CLink("map", $this->reportUrl . "?pid={$deadlink['aid']}");
             $map_link->setTarget("_blank");
             $info_link = new CLink($deadlink["status"], "http://www.checkupdown.com/status/E{$deadlink['status']}.html");
             $info_link->setTarget("_blank");
             $deadlink_output[] = new CDiv(array($link_link, " [ ", $map_link, " | ", $info_link, " ]"));
         }
         $link_link = new CLink($row['name'], $row['url']);
         $link_link->setTarget("_blank");
         $map_link = new CLink("map", $this->reportUrl . "?wid={$row['aid']}");
         $map_link->setTarget("_blank");
         $table->addRow(array(new CDiv(array($link_link, " [ ", $map_link, " ]")), new CDiv(array(new CSpan($row['links_ok'], 'green'), " / ", new CSpan($row['links_404'], 'red'), " / ", new CSpan($row['links_unchecked'], 'gray'))), new CDiv($deadlink_output)));
     }
     return $table;
 }
Beispiel #2
0
define('PAGE_HEADER_LOADED', 1);
if (isset($_REQUEST['print'])) {
    define('ZBX_PAGE_NO_MENU', 1);
    $req = substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], 'print') - 1);
    $link = new CLink(bold('«' . S_BACK_BIG), $req, 'small_font');
    $link->setAttribute('style', 'padding-left: 10px;');
    $printview = new CDiv($link, 'printless');
    $printview->setAttribute('style', 'border: 1px #333 dotted;');
    $printview->Show();
}
if (!defined('ZBX_PAGE_NO_MENU')) {
    COpt::compare_files_with_menu($ZBX_MENU);
    $help = new CLink(S_HELP, 'http://www.zabbix.com/documentation.php', 'small_font', null, 'nosid');
    $help->setTarget('_blank');
    $support = new CLink(S_GET_SUPPORT, 'http://www.zabbix.com/support.php', 'small_font', null, 'nosid');
    $support->setTarget('_blank');
    $printview = new CLink(S_PRINT, $_SERVER['REQUEST_URI'] . (empty($_GET) ? '?' : '&') . 'print=1', 'small_font', null, 'nosid');
    $page_header_r_col = array($help, '|', $support, '|', $printview);
    if ($USER_DETAILS['alias'] != ZBX_GUEST_USER) {
        $page_header_r_col[] = array('|');
        array_push($page_header_r_col, new CLink(S_PROFILE, 'profile.php', 'small_font', null, 'nosid'), '|');
        if ($USER_DETAILS['debug_mode'] == GROUP_DEBUG_MODE_ENABLED) {
            $debug = new CLink(S_DEBUG, '#debug', 'small_font', null, 'nosid');
            $debug->setAttribute('onclick', "javascript: ShowHide('zbx_gebug_info');");
            array_push($page_header_r_col, $debug, '|');
        }
        array_push($page_header_r_col, new CLink(S_LOGOUT, 'index.php?reconnect=1', 'small_font', null, 'nosid'));
    } else {
        $page_header_r_col[] = array('|', new CLink(S_LOGIN, 'index.php?reconnect=1', 'small_font', null, 'nosid'));
    }
    $logo = new CLink(new CDiv(SPACE, 'zabbix_logo'), 'http://www.zabbix.com/', 'image', null, 'nosid');
Beispiel #3
0
function make_favorite_maps()
{
    $favList = new CList(null, 'favorites', _('No maps added.'));
    $fav_sysmaps = CFavorite::get('web.favorite.sysmapids');
    if (!$fav_sysmaps) {
        return $favList;
    }
    $sysmapids = array();
    foreach ($fav_sysmaps as $favorite) {
        $sysmapids[$favorite['value']] = $favorite['value'];
    }
    $sysmaps = API::Map()->get(array('sysmapids' => $sysmapids, 'output' => array('sysmapid', 'name')));
    foreach ($sysmaps as $sysmap) {
        $sysmapid = $sysmap['sysmapid'];
        $link = new CLink(get_node_name_by_elid($sysmapid, null, NAME_DELIMITER) . $sysmap['name'], 'maps.php?sysmapid=' . $sysmapid);
        $link->setTarget('blank');
        $favList->addItem($link, 'nowrap');
    }
    return $favList;
}
Beispiel #4
0
function make_system_summary($args = array())
{
    global $USER_DETAILS;
    $config = select_config();
    $available_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_ONLY, PERM_RES_IDS_ARRAY);
    $available_groups = get_accessible_groups_by_user($USER_DETAILS, PERM_READ_ONLY, PERM_RES_IDS_ARRAY);
    $available_triggers = get_accessible_triggers(PERM_READ_ONLY, array(), PERM_RES_IDS_ARRAY);
    if (isset($args['hosts']) && !empty($args['hosts'])) {
        $available_hosts = zbx_uint_array_intersect($args['hosts'], $available_hosts);
    }
    if (isset($args['groups']) && !empty($args['groups'])) {
        $available_groups = zbx_uint_array_intersect($args['groups'], $available_groups);
    }
    $sql_where = '';
    if (isset($args['severity']) && ctype_digit($args['severity'])) {
        $sql_where = ' AND t.priority>=' . $args['severity'];
    }
    $table = new CTableInfo();
    $table->setHeader(array(is_show_all_nodes() ? S_NODE : null, S_HOST_GROUP, S_DISASTER, S_HIGH, S_AVERAGE, S_WARNING, S_INFORMATION, S_NOT_CLASSIFIED));
    $sql = 'SELECT DISTINCT g.groupid,g.name ' . ' FROM groups g, hosts_groups hg, hosts h, items i, functions f, triggers t ' . ' WHERE ' . DBcondition('h.hostid', $available_hosts) . ' AND ' . DBcondition('g.groupid', $available_groups) . ' AND hg.groupid=g.groupid ' . ' AND h.status=' . HOST_STATUS_MONITORED . ' AND h.hostid=i.hostid ' . ' AND hg.hostid=h.hostid ' . ' AND i.status=' . ITEM_STATUS_ACTIVE . ' AND i.itemid=f.itemid ' . ' AND t.triggerid=f.triggerid ' . ' AND t.status=' . TRIGGER_STATUS_ENABLED . ' ORDER BY g.name';
    $gr_result = DBselect($sql);
    while ($group = DBFetch($gr_result)) {
        $group_row = new CRow();
        if (is_show_all_nodes()) {
            $group_row->addItem(get_node_name_by_elid($group['groupid']));
        }
        $name = new CLink($group['name'], 'tr_status.php?groupid=' . $group['groupid'] . '&show_triggers=' . TRIGGERS_OPTION_ONLYTRUE);
        $name->setTarget('blank');
        $group_row->addItem($name);
        $tab_priority[TRIGGER_SEVERITY_DISASTER] = 0;
        $tab_priority[TRIGGER_SEVERITY_HIGH] = 0;
        $tab_priority[TRIGGER_SEVERITY_AVERAGE] = 0;
        $tab_priority[TRIGGER_SEVERITY_WARNING] = 0;
        $tab_priority[TRIGGER_SEVERITY_INFORMATION] = 0;
        $tab_priority[TRIGGER_SEVERITY_NOT_CLASSIFIED] = 0;
        $sql = 'SELECT count(DISTINCT t.triggerid) as tr_cnt,t.priority ' . ' FROM hosts h,items i,hosts_groups hg, functions f, triggers t ' . ' WHERE h.status=' . HOST_STATUS_MONITORED . ' AND h.hostid=i.hostid ' . ' AND hg.groupid=' . $group['groupid'] . ' AND hg.hostid=h.hostid' . ' AND i.status=' . ITEM_STATUS_ACTIVE . ' AND i.itemid=f.itemid ' . ' AND t.triggerid=f.triggerid ' . ' AND t.value=' . TRIGGER_VALUE_TRUE . ' AND t.status=' . TRIGGER_STATUS_ENABLED . ' AND ' . DBcondition('h.hostid', $available_hosts) . ' GROUP BY t.priority';
        //SDI($sql);
        $tr_result = DBSelect($sql);
        while ($group_stat = DBFetch($tr_result)) {
            $tab_priority[$group_stat['priority']] = $group_stat['tr_cnt'];
        }
        foreach ($tab_priority as $key => $value) {
            $tr_count = 0;
            if ($value) {
                //* trigger list
                $table_inf = new CTableInfo();
                $table_inf->setAttribute('style', 'width: 400px;');
                $table_inf->setHeader(array(is_show_all_nodes() ? S_NODE : null, S_HOST, S_ISSUE, S_AGE, $config['event_ack_enable'] ? S_ACK : NULL, S_ACTIONS));
                $sql = 'SELECT DISTINCT t.triggerid,t.status,t.description,t.expression,t.priority,t.lastchange,t.value,h.host,h.hostid ' . ' FROM triggers t,hosts h,items i,functions f, hosts_groups hg ' . ' WHERE f.itemid=i.itemid ' . ' AND hg.groupid=' . $group['groupid'] . ' AND h.hostid=i.hostid ' . ' AND hg.hostid=h.hostid ' . ' AND t.triggerid=f.triggerid ' . ' AND t.status=' . TRIGGER_STATUS_ENABLED . ' AND i.status=' . ITEM_STATUS_ACTIVE . ' AND ' . DBcondition('t.triggerid', $available_triggers) . ' AND h.status=' . HOST_STATUS_MONITORED . ' AND t.value=' . TRIGGER_VALUE_TRUE . ' AND t.priority=' . $key . ' ORDER BY t.lastchange DESC';
                $result = DBselect($sql);
                while ($row_inf = DBfetch($result)) {
                    // Check for dependencies
                    if (trigger_dependent($row_inf["triggerid"])) {
                        continue;
                    }
                    $tr_count++;
                    if ($tr_count > 30) {
                        continue;
                    }
                    $host = new CSpan($row_inf['host']);
                    $event_sql = 'SELECT e.eventid, e.value, e.clock, e.objectid as triggerid, e.acknowledged, t.type ' . ' FROM events e, triggers t ' . ' WHERE e.object=' . EVENT_SOURCE_TRIGGERS . ' AND e.objectid=' . $row_inf['triggerid'] . ' AND t.triggerid=e.objectid ' . ' AND e.value=' . TRIGGER_VALUE_TRUE . ' ORDER by e.object DESC, e.objectid DESC, e.eventid DESC';
                    if ($row_inf_event = DBfetch(DBselect($event_sql, 1))) {
                        if ($config['event_ack_enable']) {
                            if ($row_inf_event['acknowledged'] == 1) {
                                $ack = new CLink(S_YES, 'acknow.php?eventid=' . $row_inf_event['eventid'], 'action');
                            } else {
                                $ack = new CLink(S_NO, 'acknow.php?eventid=' . $row_inf_event['eventid'], 'on');
                            }
                        }
                        $description = expand_trigger_description_by_data(array_merge($row_inf, array('clock' => $row_inf_event['clock'])), ZBX_FLAG_EVENT);
                        //actions
                        $actions = get_event_actions_status($row_inf_event['eventid']);
                        //--------
                    } else {
                        $description = expand_trigger_description_by_data($row_inf, ZBX_FLAG_EVENT);
                        $ack = '-';
                        $actions = S_NO_DATA_SMALL;
                        $row_inf_event['clock'] = $row_inf['clock'];
                    }
                    $table_inf->addRow(array(get_node_name_by_elid($row_inf['triggerid']), $host, new CCol($description, get_severity_style($row_inf['priority'])), zbx_date2age($row_inf_event['clock']), $config['event_ack_enable'] ? new CCol($ack, 'center') : NULL, $actions));
                    unset($row_inf, $description, $actions);
                }
                $value = new CSpan($tr_count, 'pointer');
                $value->setHint($table_inf);
                //-------------*/
            }
            $group_row->AddItem(new CCol($value, get_severity_style($key, $tr_count)));
            unset($table_inf);
        }
        $table->addRow($group_row);
    }
    $table->setFooter(new CCol(S_UPDATED . ': ' . date("H:i:s", time())));
    return $table;
}
$mediaTypeForm->setName('mediaTypeForm');
$mediaTypeForm->addVar('form', $this->data['form']);
$mediaTypeForm->addVar('mediatypeid', $this->data['mediatypeid']);
// create form list
$mediaTypeFormList = new CFormList('mediaTypeFormList');
$nameTextBox = new CTextBox('description', $this->data['description'], ZBX_TEXTBOX_STANDARD_SIZE, false, 100);
$nameTextBox->attr('autofocus', 'autofocus');
$mediaTypeFormList->addRow(_('Name'), $nameTextBox);
// append type to form list
$cmbType = new CComboBox('type', $this->data['type'], 'submit()');
$cmbType->addItems(array(MEDIA_TYPE_EMAIL => _('Email'), MEDIA_TYPE_EXEC => _('Script'), MEDIA_TYPE_SMS => _('SMS'), MEDIA_TYPE_JABBER => _('Jabber')));
$cmbType->addItemsInGroup(_('Commercial'), array(MEDIA_TYPE_EZ_TEXTING => _('Ez Texting')));
$cmbTypeRow = array($cmbType);
if ($this->data['type'] == MEDIA_TYPE_EZ_TEXTING) {
    $ez_texting_link = new CLink('https://app.eztexting.com', 'https://app.eztexting.com/', null, null, 'nosid');
    $ez_texting_link->setTarget('_blank');
    $cmbTypeRow[] = $ez_texting_link;
}
$mediaTypeFormList->addRow(_('Type'), $cmbTypeRow);
// append others fields to form list
if ($this->data['type'] == MEDIA_TYPE_EMAIL) {
    $mediaTypeFormList->addRow(_('SMTP server'), new CTextBox('smtp_server', $this->data['smtp_server'], ZBX_TEXTBOX_STANDARD_SIZE));
    $mediaTypeFormList->addRow(_('SMTP helo'), new CTextBox('smtp_helo', $this->data['smtp_helo'], ZBX_TEXTBOX_STANDARD_SIZE));
    $mediaTypeFormList->addRow(_('SMTP email'), new CTextBox('smtp_email', $this->data['smtp_email'], ZBX_TEXTBOX_STANDARD_SIZE));
} elseif ($this->data['type'] == MEDIA_TYPE_SMS) {
    $mediaTypeFormList->addRow(_('GSM modem'), new CTextBox('gsm_modem', $this->data['gsm_modem'], ZBX_TEXTBOX_STANDARD_SIZE));
} elseif ($this->data['type'] == MEDIA_TYPE_EXEC) {
    $mediaTypeFormList->addRow(_('Script name'), new CTextBox('exec_path', $this->data['exec_path'], ZBX_TEXTBOX_STANDARD_SIZE));
} elseif ($this->data['type'] == MEDIA_TYPE_JABBER || $this->data['type'] == MEDIA_TYPE_EZ_TEXTING) {
    // create password field
    if (!empty($this->data['password'])) {
    }
}
$divTabs->addTab('templateTab', _('Template'), $templateList);
// FULL CLONE }
// } TEMPLATE WIDGET
// TEMPLATES{
$tmplList = new CFormList('tmpllist');
// create linked template table
$linkedTemplateTable = new CTable(_('No templates linked.'), 'formElementTable');
$linkedTemplateTable->attr('id', 'linkedTemplateTable');
$linkedTemplateTable->setHeader(array(_('Name'), _('Action')));
$ignoredTemplates = array();
foreach ($this->data['linkedTemplates'] as $template) {
    $tmplList->addVar('templates[]', $template['templateid']);
    $templateLink = new CLink($template['name'], 'templates.php?form=update&templateid=' . $template['templateid']);
    $templateLink->setTarget('_blank');
    $linkedTemplateTable->addRow(array($templateLink, array(new CSubmit('unlink[' . $template['templateid'] . ']', _('Unlink'), null, 'link_menu'), SPACE, SPACE, isset($this->data['original_templates'][$template['templateid']]) ? new CSubmit('unlink_and_clear[' . $template['templateid'] . ']', _('Unlink and clear'), null, 'link_menu') : SPACE)), null, 'conditions_' . $template['templateid']);
    $ignoredTemplates[$template['templateid']] = $template['name'];
}
$tmplList->addRow(_('Linked templates'), new CDiv($linkedTemplateTable, 'template-link-block objectgroup inlineblock border_dotted ui-corner-all'));
// create new linked template table
$newTemplateTable = new CTable(null, 'formElementTable');
$newTemplateTable->attr('id', 'newTemplateTable');
$newTemplateTable->attr('style', 'min-width: 400px;');
$newTemplateTable->addRow(array(new CMultiSelect(array('name' => 'add_templates[]', 'objectName' => 'templates', 'ignored' => $ignoredTemplates, 'popup' => array('parameters' => 'srctbl=templates&srcfld1=hostid&srcfld2=host&dstfrm=' . $frmHost->getName() . '&dstfld1=add_templates_&templated_hosts=1&multiselect=1', 'width' => 450, 'height' => 450)))));
$newTemplateTable->addRow(array(new CSubmit('add_template', _('Add'), null, 'link_menu')));
$tmplList->addRow(_('Link new templates'), new CDiv($newTemplateTable, 'template-link-block objectgroup inlineblock border_dotted ui-corner-all'));
$divTabs->addTab('tmplTab', _('Linked templates'), $tmplList);
// } TEMPLATES
// macros
if (empty($macros)) {
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;
}
function make_favorite_maps()
{
    $table = new CTableInfo();
    $fav_sysmaps = get_favorites('web.favorite.sysmapids');
    $sysmapids = array();
    foreach ($fav_sysmaps as $key => $favorite) {
        $sysmapids[$favorite['value']] = $favorite['value'];
    }
    $options = array('sysmapids' => $sysmapids, 'output' => API_OUTPUT_EXTEND);
    $sysmaps = CMap::get($options);
    foreach ($sysmaps as $snum => $sysmap) {
        $sysmapid = $sysmap['sysmapid'];
        $link = new CLink(get_node_name_by_elid($sysmapid, null, ': ') . $sysmap['name'], 'maps.php?sysmapid=' . $sysmapid);
        $link->setTarget('blank');
        $capt = new CSpan($link);
        $capt->setAttribute('style', 'line-height: 14px; vertical-align: middle;');
        $icon = new CLink(new CImg('images/general/chart.png', 'map', 18, 18, 'borderless'), 'maps.php?sysmapid=' . $sysmapid . '&fullscreen=1');
        $icon->setTarget('blank');
        $table->addRow(new CCol(array($icon, SPACE, $capt)));
    }
    $td = new CCol(array(new CLink(S_MAPS . ' »', 'maps.php', 'highlight')));
    $td->setAttribute('style', 'text-align: right;');
    $table->setFooter($td);
    return $table;
}