$fields['test_expression'] = array(T_ZBX_STR, O_OPT, P_SYS | P_ACT, null, null);
if (!check_fields($fields)) {
    $test = false;
}
//------------------------ <ACTIONS> ---------------------------
if (isset($_REQUEST['test_expression'])) {
    show_messages();
    $test = true;
} else {
    $test = false;
}
//------------------------ </ACTIONS> --------------------------
//------------------------ <FORM> ---------------------------
$frm_test = new CFormTable(_('Test'), 'tr_testexpr.php');
$frm_test->setHelp('web.testexpr.service.php');
$frm_test->setTableClass('formlongtable formtable');
$frm_test->addVar('form_refresh', get_request('form_refresh', 1));
$frm_test->addVar('expression', $expression);
/* test data */
$frm_test->addRow(_('Test data'), $data_table);
/* result */
$res_table = new CTable(null, 'tableinfo');
$res_table->setAttribute('id', 'result_list');
$res_table->setOddRowClass('even_row');
$res_table->setEvenRowClass('even_row');
$res_table->setHeader(array(_('Expression'), _('Result')));
ksort($rplcts, SORT_NUMERIC);
foreach ($eHTMLTree as $e) {
    $result = '-';
    if ($allowedTesting && $test && isset($e['expression'])) {
        $result = evalExpressionData($e['expression']['value'], $macrosData, $octet);
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
**/
require_once dirname(__FILE__) . '/js/common.filter.trigger.js.php';
$overview = $this->data['overview'];
$filter = $this->data['filter'];
$config = select_config();
$filterForm = new CFormTable(null, null, 'get');
$filterForm->setTableClass('formtable old-filter');
$filterForm->setAttribute('name', 'zbx_filter');
$filterForm->setAttribute('id', 'zbx_filter');
$filterForm->addVar('fullscreen', $filter['fullScreen']);
$filterForm->addVar('groupid', $filter['groupId']);
$filterForm->addVar('hostid', $filter['hostId']);
// trigger status
$filterForm->addRow(_('Triggers status'), new CComboBox('show_triggers', $filter['showTriggers'], null, array(TRIGGERS_OPTION_ALL => _('Any'), TRIGGERS_OPTION_RECENT_PROBLEM => _('Recent problem'), TRIGGERS_OPTION_IN_PROBLEM => _('Problem'))));
// ack status
if ($config['event_ack_enable']) {
    $filterForm->addRow(_('Acknowledge status'), new CComboBox('ack_status', $filter['ackStatus'], null, array(ZBX_ACK_STS_ANY => _('Any'), ZBX_ACK_STS_WITH_UNACK => _('With unacknowledged events'), ZBX_ACK_STS_WITH_LAST_UNACK => _('With last event unacknowledged'))));
}
// events
if (!$overview) {
    $eventsComboBox = new CComboBox('show_events', $filter['showEvents'], null, array(EVENTS_OPTION_NOEVENT => _('Hide all'), EVENTS_OPTION_ALL => _n('Show all (%1$s day)', 'Show all (%1$s days)', $config['event_expire'])));
    if ($config['event_ack_enable']) {
Exemple #3
0
            show_messages($result, _('Trigger added'), _('Cannot add trigger'));
        }
        if ($result) {
            add_audit($audit_action, AUDIT_RESOURCE_TRIGGER, _('Trigger') . ' [' . $triggerid . '] [' . $trigger['description'] . ']');
            unset($_REQUEST['sform']);
            zbx_add_post_js('closeForm("items.php");');
            require_once dirname(__FILE__) . '/include/page_footer.php';
        }
    }
}
//------------------------ </ACTIONS> --------------------------
//------------------------ <FORM> ---------------------------
if (isset($_REQUEST['sform'])) {
    $frmTRLog = new CFormTable(_('Trigger'), 'tr_logform.php', 'POST', null, 'sform');
    $frmTRLog->setHelp('web.triggerlog.service.php');
    $frmTRLog->setTableClass('formlongtable formtable');
    $frmTRLog->addVar('form_refresh', get_request('form_refresh', 1));
    if (isset($_REQUEST['triggerid'])) {
        $frmTRLog->addVar('triggerid', $_REQUEST['triggerid']);
    }
    if (isset($_REQUEST['triggerid']) && !isset($_REQUEST['form_refresh'])) {
        $frmTRLog->addVar('form_refresh', get_request('form_refresh', 1));
        $sql = 'SELECT DISTINCT f.functionid, f.function, f.parameter, t.expression, ' . ' t.description, t.priority, t.comments, t.url, t.status, t.type' . ' FROM functions f, triggers t, items i ' . ' WHERE t.triggerid=' . zbx_dbstr($_REQUEST['triggerid']) . ' AND i.itemid=f.itemid ' . ' AND f.triggerid = t.triggerid ' . ' AND i.value_type IN (' . ITEM_VALUE_TYPE_LOG . ' , ' . ITEM_VALUE_TYPE_TEXT . ', ' . ITEM_VALUE_TYPE_STR . ')';
        $res = DBselect($sql);
        while ($rows = DBfetch($res)) {
            $description = $rows['description'];
            $expression = $rows['expression'];
            $type = $rows['type'];
            $priority = $rows['priority'];
            $comments = $rows['comments'];
            $url = $rows['url'];
Exemple #4
0
// checks
$fields['test_expression'] = array(T_ZBX_STR, O_OPT, P_SYS | P_ACT, null, null);
if (!check_fields($fields)) {
    $test = false;
}
// actions
if (isset($_REQUEST['test_expression'])) {
    show_messages();
    $test = true;
} else {
    $test = false;
}
// form
$testForm = new CFormTable(_('Test'), 'tr_testexpr.php');
$testForm->addHelpIcon();
$testForm->setTableClass('formlongtable formtable');
$testForm->addVar('expression', $expression);
$testForm->addRow(_('Test data'), $dataTable);
$resultTable = new CTable(null, 'tableinfo');
$resultTable->setAttribute('id', 'result_list');
$resultTable->setOddRowClass('even_row');
$resultTable->setEvenRowClass('even_row');
$resultTable->setHeader(array(_('Expression'), _('Result')));
ksort($rplcts, SORT_NUMERIC);
foreach ($eHTMLTree as $e) {
    $result = '-';
    $style = 'text-align: center;';
    if ($allowedTesting && $test && isset($e['expression'])) {
        if (evalExpressionData($e['expression']['value'], $macrosData)) {
            $result = 'TRUE';
            $style = 'background-color: #ccf; color: #00f;';
/**
 * Create report bar for for "Compare values for multiple periods"
 *
 * @return object $reportForm
 */
function valueComparisonFormForMultiplePeriods()
{
    $config = getRequest('config', BR_DISTRIBUTION_MULTIPLE_PERIODS);
    $title = getRequest('title', _('Report 3'));
    $xlabel = getRequest('xlabel', '');
    $ylabel = getRequest('ylabel', '');
    $scaletype = getRequest('scaletype', TIMEPERIOD_TYPE_WEEKLY);
    $avgperiod = getRequest('avgperiod', TIMEPERIOD_TYPE_DAILY);
    $report_timesince = getRequest('report_timesince', date(TIMESTAMP_FORMAT_ZERO_TIME, time() - SEC_PER_DAY));
    $report_timetill = getRequest('report_timetill', date(TIMESTAMP_FORMAT_ZERO_TIME));
    $itemId = getRequest('itemid', 0);
    $hostids = getRequest('hostids', array());
    $hostids = zbx_toHash($hostids);
    $showlegend = getRequest('showlegend', 0);
    $palette = getRequest('palette', 0);
    $palettetype = getRequest('palettetype', 0);
    $reportForm = new CFormTable(null, null, 'get');
    $reportForm->setTableClass('formtable old-filter');
    $reportForm->setAttribute('name', 'zbx_report');
    $reportForm->setAttribute('id', 'zbx_report');
    if (isset($_REQUEST['report_show']) && $itemId) {
        $reportForm->addVar('report_show', 'show');
    }
    $reportForm->addVar('config', $config);
    $reportForm->addVar('report_timesince', date(TIMESTAMP_FORMAT, $report_timesince));
    $reportForm->addVar('report_timetill', date(TIMESTAMP_FORMAT, $report_timetill));
    $reportForm->addRow(_('Title'), new CTextBox('title', $title, 40));
    $reportForm->addRow(_('X label'), new CTextBox('xlabel', $xlabel, 40));
    $reportForm->addRow(_('Y label'), new CTextBox('ylabel', $ylabel, 40));
    $reportForm->addRow(_('Legend'), new CCheckBox('showlegend', $showlegend, null, 1));
    $reportForm->addVar('sortorder', 0);
    $groupids = getRequest('groupids', array());
    $group_tb = new CTweenBox($reportForm, 'groupids', $groupids, 10);
    $db_groups = API::HostGroup()->get(array('real_hosts' => true, 'output' => array('groupid', 'name')));
    order_result($db_groups, 'name');
    foreach ($db_groups as $group) {
        $groupids[$group['groupid']] = $group['groupid'];
        $group_tb->addItem($group['groupid'], $group['name']);
    }
    $reportForm->addRow(_('Groups'), $group_tb->Get(_('Selected groups'), _('Other groups')));
    $groupid = getRequest('groupid', 0);
    $cmbGroups = new CComboBox('groupid', $groupid, 'submit()');
    $cmbGroups->addItem(0, _('All'));
    foreach ($db_groups as $group) {
        $cmbGroups->addItem($group['groupid'], $group['name']);
    }
    $td_groups = new CCol(array(_('Group'), SPACE, $cmbGroups));
    $td_groups->setAttribute('style', 'text-align: right;');
    $host_tb = new CTweenBox($reportForm, 'hostids', $hostids, 10);
    $options = array('real_hosts' => true, 'output' => array('hostid', 'name'));
    if ($groupid > 0) {
        $options['groupids'] = $groupid;
    }
    $db_hosts = API::Host()->get($options);
    $db_hosts = zbx_toHash($db_hosts, 'hostid');
    order_result($db_hosts, 'name');
    foreach ($db_hosts as $hnum => $host) {
        $host_tb->addItem($host['hostid'], $host['name']);
    }
    $options = array('real_hosts' => true, 'output' => array('hostid', 'name'), 'hostids' => $hostids);
    $db_hosts2 = API::Host()->get($options);
    order_result($db_hosts2, 'name');
    foreach ($db_hosts2 as $hnum => $host) {
        if (!isset($db_hosts[$host['hostid']])) {
            $host_tb->addItem($host['hostid'], $host['name']);
        }
    }
    $reportForm->addRow(_('Hosts'), $host_tb->Get(_('Selected hosts'), array(_('Other hosts | Group') . SPACE, $cmbGroups)));
    $reporttimetab = new CTable(null, 'calendar');
    $timeSinceRow = createDateSelector('report_timesince', $report_timesince, 'report_timetill');
    array_unshift($timeSinceRow, _('From'));
    $reporttimetab->addRow($timeSinceRow);
    $timeTillRow = createDateSelector('report_timetill', $report_timetill, 'report_timesince');
    array_unshift($timeTillRow, _('Till'));
    $reporttimetab->addRow($timeTillRow);
    $reportForm->addRow(_('Period'), $reporttimetab);
    $scale = new CComboBox('scaletype', $scaletype);
    $scale->addItem(TIMEPERIOD_TYPE_HOURLY, _('Hourly'));
    $scale->addItem(TIMEPERIOD_TYPE_DAILY, _('Daily'));
    $scale->addItem(TIMEPERIOD_TYPE_WEEKLY, _('Weekly'));
    $scale->addItem(TIMEPERIOD_TYPE_MONTHLY, _('Monthly'));
    $scale->addItem(TIMEPERIOD_TYPE_YEARLY, _('Yearly'));
    $reportForm->addRow(_('Scale'), $scale);
    $avgcmb = new CComboBox('avgperiod', $avgperiod);
    $avgcmb->addItem(TIMEPERIOD_TYPE_HOURLY, _('Hourly'));
    $avgcmb->addItem(TIMEPERIOD_TYPE_DAILY, _('Daily'));
    $avgcmb->addItem(TIMEPERIOD_TYPE_WEEKLY, _('Weekly'));
    $avgcmb->addItem(TIMEPERIOD_TYPE_MONTHLY, _('Monthly'));
    $avgcmb->addItem(TIMEPERIOD_TYPE_YEARLY, _('Yearly'));
    $reportForm->addRow(_('Average by'), $avgcmb);
    $itemName = '';
    if ($itemId) {
        $items = CMacrosResolverHelper::resolveItemNames(array(get_item_by_itemid($itemId)));
        $item = reset($items);
        $itemName = $item['name_expanded'];
    }
    $itemidVar = new CVar('itemid', $itemId, 'itemid');
    $reportForm->addItem($itemidVar);
    $txtCondVal = new CTextBox('item_name', $itemName, 50, true);
    $txtCondVal->setAttribute('id', 'item_name');
    $btnSelect = new CButton('btn1', _('Select'), 'return PopUp("popup.php?dstfrm=' . $reportForm->GetName() . '&dstfld1=itemid' . '&dstfld2=item_name' . '&srctbl=items' . '&srcfld1=itemid' . '&srcfld2=name' . '&monitored_hosts=1");', 'T');
    $reportForm->addRow(_('Item'), array($txtCondVal, $btnSelect));
    $paletteCmb = new CComboBox('palette', $palette);
    $paletteCmb->addItem(0, _s('Palette #%1$s', 1));
    $paletteCmb->addItem(1, _s('Palette #%1$s', 2));
    $paletteCmb->addItem(2, _s('Palette #%1$s', 3));
    $paletteCmb->addItem(3, _s('Palette #%1$s', 4));
    $paletteTypeCmb = new CComboBox('palettetype', $palettetype);
    $paletteTypeCmb->addItem(0, _('Middle'));
    $paletteTypeCmb->addItem(1, _('Darken'));
    $paletteTypeCmb->addItem(2, _('Brighten'));
    $reportForm->addRow(_('Palette'), array($paletteCmb, $paletteTypeCmb));
    $reportForm->addItemToBottomRow(new CSubmit('report_show', _('Show')));
    $reportForm->addItemToBottomRow(new CSubmit('report_reset', _('Reset')));
    return $reportForm;
}