Пример #1
0
                    $newTrigger['functions'][$fnum]['itemid'] = $oldFunction['itemid'];
                    $found = true;
                    unset($oldTrigger['functions'][$ofnum]);
                    break;
                }
                if (!$found) {
                    break;
                }
            }
            if (!$found) {
                continue;
            }
            // if we found same trigger we overwriting it's hosts and items for expression compare
            $newTrigger['hosts'] = $oldTrigger['hosts'];
            $newTrigger['items'] = $oldTrigger['items'];
            $newExpression = triggerExpression($newTrigger, false);
            if (strcmp($oldExpression, $newExpression) == 0) {
                $_REQUEST['triggerid'] = $newTrigger['triggerid'];
                $_REQUEST['filter_set'] = 1;
                break;
            }
        }
    }
}
// --------
if (isset($_REQUEST['filter_set']) || isset($_REQUEST['filter_rst'])) {
    CProfile::update('web.events.filter.triggerid', $_REQUEST['triggerid'], PROFILE_TYPE_ID);
    CProfile::update('web.events.filter.hide_unknown', $_REQUEST['hide_unknown'], PROFILE_TYPE_INT);
}
// --------------
CProfile::update('web.events.source', $source, PROFILE_TYPE_INT);
        $status = new CLink(triggerIndicator($trigger['status'], $trigger['state']), 'triggers.php?' . 'action=' . ($trigger['status'] == TRIGGER_STATUS_DISABLED ? 'trigger.massenable' : 'trigger.massdisable') . '&hostid=' . $this->data['hostid'] . '&g_triggerid=' . $triggerid, triggerIndicatorStyle($trigger['status'], $trigger['state']));
    }
    // hosts
    $hosts = null;
    if (empty($this->data['hostid'])) {
        foreach ($trigger['hosts'] as $hostid => $host) {
            if (!empty($hosts)) {
                $hosts[] = ', ';
            }
            $hosts[] = $host['name'];
        }
    }
    // checkbox
    $checkBox = new CCheckBox('g_triggerid[' . $triggerid . ']', null, null, $triggerid);
    $checkBox->setEnabled(empty($trigger['discoveryRule']));
    $triggersTable->addRow(array($checkBox, getSeverityCell($trigger['priority']), $hosts, $description, new CCol(triggerExpression($trigger, true), 'trigger-expression'), $status, $info));
}
// create go button
$actionObject = $this->data['parent_discoveryid'] ? 'triggerprototype' : 'trigger';
$goComboBox = new CComboBox('action');
$goOption = new CComboItem($actionObject . '.massenable', _('Enable selected'));
$goOption->setAttribute('confirm', $this->data['parent_discoveryid'] ? _('Enable selected trigger prototypes?') : _('Enable selected triggers?'));
$goComboBox->addItem($goOption);
$goOption = new CComboItem($actionObject . '.massdisable', _('Disable selected'));
$goOption->setAttribute('confirm', $this->data['parent_discoveryid'] ? _('Disable selected trigger prototypes?') : _('Disable selected triggers?'));
$goComboBox->addItem($goOption);
$goOption = new CComboItem($actionObject . '.massupdateform', _('Mass update'));
$goComboBox->addItem($goOption);
if (empty($this->data['parent_discoveryid'])) {
    $goOption = new CComboItem($actionObject . '.masscopyto', _('Copy selected to ...'));
    $goComboBox->addItem($goOption);
             $triggerDescription[] = new CLink(CHtml::encode($realHost['name']), 'triggers.php?hostid=' . $realHost['hostid'], 'unknown');
             $triggerDescription[] = ':';
         }
     }
     $trigger['hosts'] = zbx_toHash($trigger['hosts'], 'hostid');
     if ($trigger['flags'] == ZBX_FLAG_DISCOVERY_CREATED) {
         $triggerDescription[] = new CSpan(CHtml::encode($trigger['description']));
     } else {
         $triggerDescription[] = new CLink(CHtml::encode($trigger['description']), 'triggers.php?form=update&hostid=' . key($trigger['hosts']) . '&triggerid=' . $trigger['triggerid']);
     }
     if ($trigger['state'] == TRIGGER_STATE_UNKNOWN) {
         $trigger['error'] = '';
     }
     $trigger['items'] = zbx_toHash($trigger['items'], 'itemid');
     $trigger['functions'] = zbx_toHash($trigger['functions'], 'functionid');
     $triggerHintTable->addRow(array(getSeverityCell($trigger['priority']), $triggerDescription, triggerExpression($trigger, true), new CSpan(triggerIndicator($trigger['status'], $trigger['state']), triggerIndicatorStyle($trigger['status'], $trigger['state']))));
     $item['triggers'][$num] = $trigger;
 }
 unset($trigger);
 if (!empty($item['triggers'])) {
     $triggerInfo = new CSpan(_('Triggers'), 'link_menu');
     $triggerInfo->setHint($triggerHintTable);
     $triggerInfo = array($triggerInfo);
     $triggerInfo[] = ' (' . count($item['triggers']) . ')';
     $triggerHintTable = array();
 } else {
     $triggerInfo = SPACE;
 }
 // if item type is 'Log' we must show log menu
 if (in_array($item['value_type'], array(ITEM_VALUE_TYPE_LOG, ITEM_VALUE_TYPE_STR, ITEM_VALUE_TYPE_TEXT))) {
     $triggers = array();
Пример #4
0
     } else {
         if ($trigger['status'] == TRIGGER_STATUS_ENABLED) {
             $status = new CLink(S_ENABLED, $status_link, 'enabled');
         }
     }
     $hosts = null;
     if ($_REQUEST['hostid'] == 0) {
         $hosts = array();
         foreach ($trigger['hosts'] as $hostid => $host) {
             if (!empty($hosts)) {
                 $hosts[] = ', ';
             }
             $hosts[] = $host['host'];
         }
     }
     $table->addRow(array(new CCheckBox('g_triggerid[' . $triggerid . ']', NULL, NULL, $triggerid), $priority, $status, $hosts, $description, triggerExpression($trigger, 1), $error));
     $triggers[$tnum] = $trigger;
 }
 //----- GO ------
 $goBox = new CComboBox('go');
 $goOption = new CComboItem('activate', S_ACTIVATE_SELECTED);
 $goOption->setAttribute('confirm', S_ENABLE_SELECTED_TRIGGERS_Q);
 $goBox->addItem($goOption);
 $goOption = new CComboItem('disable', S_DISABLE_SELECTED);
 $goOption->setAttribute('confirm', S_DISABLE_SELECTED_TRIGGERS_Q);
 $goBox->addItem($goOption);
 $goOption = new CComboItem('massupdate', S_MASS_UPDATE);
 //$goOption->setAttribute('confirm',S_MASS_UPDATE_SELECTED_TRIGGERS_Q);
 $goBox->addItem($goOption);
 $goOption = new CComboItem('copy_to', S_COPY_SELECTED_TO);
 //$goOption->setAttribute('confirm',S_COPY_SELECTED_TRIGGERS_Q);
        $status = new CLink(triggerIndicator($trigger['status']), 'trigger_prototypes.php?' . 'go=' . ($trigger['status'] == TRIGGER_STATUS_DISABLED ? 'activate' : 'disable') . '&hostid=' . $this->data['hostid'] . '&g_triggerid=' . $triggerid . '&parent_discoveryid=' . $this->data['parent_discoveryid'], triggerIndicatorStyle($trigger['status']));
    } else {
        $status = new CLink(triggerIndicator($trigger['status'], $trigger['state']), 'triggers.php?' . 'go=' . ($trigger['status'] == TRIGGER_STATUS_DISABLED ? 'activate' : 'disable') . '&hostid=' . $this->data['hostid'] . '&g_triggerid=' . $triggerid, triggerIndicatorStyle($trigger['status'], $trigger['state']));
    }
    $hosts = null;
    if (empty($this->data['hostid'])) {
        foreach ($trigger['hosts'] as $hostid => $host) {
            if (!empty($hosts)) {
                $hosts[] = ', ';
            }
            $hosts[] = $host['name'];
        }
    }
    $checkBox = new CCheckBox('g_triggerid[' . $triggerid . ']', null, null, $triggerid);
    $checkBox->setEnabled(empty($trigger['discoveryRule']));
    $expressionColumn = new CCol(triggerExpression($trigger, true));
    $expressionColumn->setAttribute('style', 'white-space: normal;');
    $triggersTable->addRow(array($checkBox, $this->data['displayNodes'] ? $trigger['nodename'] : null, getSeverityCell($trigger['priority']), $hosts, $description, $expressionColumn, $status, $data['showErrorColumn'] ? $error : null));
    $triggers[$tnum] = $trigger;
}
// create go button
$goComboBox = new CComboBox('go');
$goOption = new CComboItem('activate', _('Enable selected'));
$goOption->setAttribute('confirm', $this->data['parent_discoveryid'] ? _('Enable selected trigger prototypes?') : _('Enable selected triggers?'));
$goComboBox->addItem($goOption);
$goOption = new CComboItem('disable', _('Disable selected'));
$goOption->setAttribute('confirm', $this->data['parent_discoveryid'] ? _('Disable selected trigger prototypes?') : _('Disable selected triggers?'));
$goComboBox->addItem($goOption);
$goOption = new CComboItem('massupdate', _('Mass update'));
$goComboBox->addItem($goOption);
if (empty($this->data['parent_discoveryid'])) {
Пример #6
0
                    $newTrigger['functions'][$fnum]['itemid'] = $oldFunction['itemid'];
                    $found = true;
                    unset($oldTrigger['functions'][$ofnum]);
                    break;
                }
                if (!$found) {
                    break;
                }
            }
            if (!$found) {
                continue;
            }
            // if we found same trigger we overwriting it's hosts and items for expression compare
            $newTrigger['hosts'] = $oldTrigger['hosts'];
            $newTrigger['items'] = $oldTrigger['items'];
            $newExpression = triggerExpression($newTrigger);
            if (strcmp($oldExpression, $newExpression) == 0) {
                $_REQUEST['triggerid'] = $newTrigger['triggerid'];
                $_REQUEST['filter_set'] = 1;
                break;
            }
        }
    }
}
// --------
if (isset($_REQUEST['filter_set']) || isset($_REQUEST['filter_rst'])) {
    CProfile::update('web.events.filter.triggerid', $_REQUEST['triggerid'], PROFILE_TYPE_ID);
    CProfile::update('web.events.filter.showUnknown', $_REQUEST['showUnknown'], PROFILE_TYPE_INT);
}
// --------------
CProfile::update('web.events.source', $source, PROFILE_TYPE_INT);
     if ($trigger['flags'] == ZBX_FLAG_DISCOVERY_CREATED) {
         $triggerDescription[] = new CSpan($trigger['description']);
     } else {
         $triggerDescription[] = new CLink($trigger['description'], 'triggers.php?form=update&hostid=' . key($trigger['hosts']) . '&triggerid=' . $trigger['triggerid']);
     }
     if ($trigger['value_flags'] == TRIGGER_VALUE_FLAG_UNKNOWN) {
         $trigger['error'] = '';
     }
     if ($trigger['status'] == TRIGGER_STATUS_DISABLED) {
         $triggerStatus = new CSpan(_('Disabled'), 'disabled');
     } elseif ($trigger['status'] == TRIGGER_STATUS_ENABLED) {
         $triggerStatus = new CSpan(_('Enabled'), 'enabled');
     }
     $trigger['items'] = zbx_toHash($trigger['items'], 'itemid');
     $trigger['functions'] = zbx_toHash($trigger['functions'], 'functionid');
     $triggerHintTable->addRow(array(getSeverityCell($trigger['priority']), $triggerDescription, triggerExpression($trigger, true), $triggerStatus));
     $item['triggers'][$num] = $trigger;
 }
 unset($trigger);
 if (!empty($item['triggers'])) {
     $triggerInfo = new CSpan(_('Triggers'), 'link_menu');
     $triggerInfo->setHint($triggerHintTable);
     $triggerInfo = array($triggerInfo);
     $triggerInfo[] = ' (' . count($item['triggers']) . ')';
     $triggerHintTable = array();
 } else {
     $triggerInfo = SPACE;
 }
 // if item type is 'Log' we must show log menu
 if (in_array($item['value_type'], array(ITEM_VALUE_TYPE_LOG, ITEM_VALUE_TYPE_STR, ITEM_VALUE_TYPE_TEXT))) {
     $triggersFlag = false;
Пример #8
0
             $priority = new CCol(S_HIGH, 'high');
             break;
         case 5:
             $priority = new CCol(S_DISASTER, 'disaster');
             break;
         default:
             $priority = $trigger['priority'];
     }
     if ($trigger['status'] == TRIGGER_STATUS_DISABLED) {
         $tstatus = new CSpan(S_DISABLED, 'disabled');
     } else {
         if ($trigger['status'] == TRIGGER_STATUS_ENABLED) {
             $tstatus = new CSpan(S_ENABLED, 'enabled');
         }
     }
     $trigger_hint->addRow(array($priority, $tr_description, triggerExpression($trigger, 1), $tstatus));
     $item['triggers'][$tnum] = $trigger;
 }
 unset($trigger);
 if (!empty($item['triggers'])) {
     $trigger_info = new CSpan(S_TRIGGERS, 'link_menu');
     $trigger_info->setHint($trigger_hint);
     $trigger_info = array($trigger_info);
     $trigger_info[] = ' (' . count($item['triggers']) . ')';
     $trigger_hint = array();
 } else {
     $trigger_info = SPACE;
 }
 //-------
 // if item type is 'Log' we must show log menu
 if ($item['value_type'] == ITEM_VALUE_TYPE_LOG || $item['value_type'] == ITEM_VALUE_TYPE_STR || $item['value_type'] == ITEM_VALUE_TYPE_TEXT) {