'alert_checks', 'entity_type' => NULL]); $navbar['options']['all']['text'] = escape_html(nicecase('all')); if (!isset($vars['entity_type'])) { $navbar['options']['all']['class'] = "active"; $navbar['options']['all']['url'] = generate_url($vars, ['page' => 'alert_checks', 'entity_type' => NULL]); } foreach ($types as $thing) { if ($vars['entity_type'] == $thing['entity_type']) { $navbar['options'][$thing['entity_type']]['class'] = "active"; $navbar['options'][$thing['entity_type']]['url'] = generate_url($vars, ['page' => 'alert_checks', 'entity_type' => NULL]); } else { if ($types_count > 6) { $navbar['options'][$thing['entity_type']]['class'] = "icon"; } $navbar['options'][$thing['entity_type']]['url'] = generate_url($vars, ['page' => 'alert_checks', 'entity_type' => $thing['entity_type']]); } $navbar['options'][$thing['entity_type']]['icon'] = $config['entities'][$thing['entity_type']]['icon']; $navbar['options'][$thing['entity_type']]['text'] = escape_html(nicecase($thing['entity_type'])); } $navbar['options']['export']['text'] = 'Export'; $navbar['options']['export']['icon'] = $config['icon']['export']; $navbar['options']['export']['url'] = generate_url($vars, ['page' => 'alert_checks', 'export' => 'yes']); $navbar['options']['export']['right'] = TRUE; $navbar['options']['export']['userlevel'] = 7; // Print out the navbar defined above print_navbar($navbar); // Generate contacts cache array for use in table $contacts = []; $sql = "SELECT * FROM `alert_contacts_assoc` LEFT JOIN `alert_contacts` USING(`contact_id`) WHERE `aca_type` = ?"; $params = [ 'alert' ]; foreach (dbFetchRows($sql, $params) as $db_contact) { $contacts[$db_contact['alert_checker_id']][] = $db_contact; } if (get_var_true($vars['export'])) { // Export requested if (!get_var_true($vars['saveas'])) { $export_filename = 'observium_alerts_'; $export_filename .= $vars['entity_type'] ?: 'all'; $export_filename .= '.json'; $form = ['type' => 'rows', 'space' => '10px', 'url' => generate_url($vars)]; // Filename $form['row'][0]['filename'] = [ 'type' => 'text', 'name' => 'Filename', 'value' => $export_filename, 'grid_xs' => 8, 'width' => '100%', 'placeholder' => TRUE ]; // Save as human formatted XML $form['row'][0]['formatted'] = [ 'type' => 'select', 'grid_xs' => 4, 'value' => 'yes', 'values' => [ 'yes' => 'Formatted', 'no' => 'Unformatted' ] ]; // search button $form['row'][0]['saveas'] = [ 'type' => 'submit', 'name' => 'Save as..', 'icon' => 'icon-save', 'right' => TRUE, 'value' => 'yes' ]; print_form($form); } json_export('alerts', $vars); unset($export_filename, $form); } foreach (dbFetchRows("SELECT * FROM `alert_table`" . $where) as $entry) { $alert_table[$entry['alert_test_id']][$entry['alert_table_id']] = $entry; } echo generate_box_open(); echo '
Name | Tests | Device Match / Entity Match | Entities | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
'); // Print the conditions applied by this alert echo ' | ';
echo '' . escape_html($check['alert_name']) . ' '; echo '', escape_html($check['alert_message']), ''; echo ' | ';
echo ''; // Loop the tests used by this alert echo ' | ';
$text_block = [];
//r($check);
foreach ($check['conditions'] as $condition) {
$text_block[] = escape_html($condition['metric'] . ' ' . $condition['condition'] . ' ' . $condition['value']);
}
echo ($check['and'] ? ' AND (ALL)' : ' OR (ANY)') . ' '; echo '
| ');
echo('');
if (!is_null($check['alert_assoc'])) {
$check['assoc'] = safe_json_decode($check['alert_assoc']);
echo render_qb_rules($check['entity_type'], $check['assoc']);
} else {
echo generate_box_open();
echo('
| ';
// Print the count of entities this alert applies to and a popup containing a list and Print breakdown of entities by status.
// We assume each row here is going to be two lines, so we just ';
#echo overlib_link('#', count($entities), $entities_content, NULL));
echo '', $check['num_entities'], ' ';
//echo ' '; echo $check['status_numbers']; echo ' '; if ($notifiers_count = safe_count($contacts[$check['alert_test_id']])) { $content = ""; foreach ($contacts[$check['alert_test_id']] as $contact) { $content .= '' . $contact['contact_method'] . ' ' . escape_html($contact['contact_descr']) . ' '; } echo generate_tooltip_link('', '' . $notifiers_count . ' Notifiers', $content); } else { echo 'Default Notifier'; } echo ' | ';
}
echo '