'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, array('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, array('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, array('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, array('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` ON `alert_contacts`.`contact_id` = `alert_contacts_assoc`.`contact_id`"; $contacts_db = dbFetchRows($sql, $params); foreach($contacts_db as $db_contact) { $contacts[$db_contact['alert_checker_id']][] = $db_contact; } if ($templates_export) { //r($alert_check); //r($alert_assoc); // Export alert checkers as templates $for_export = array(); foreach ($alert_check as $id => $entry) { foreach ($alert_assoc[$id] as $assoc) { // Multiple association sets (device+entity) $entry['associations'][] = $assoc; } $for_export[] = $entry; } $templates_xml = generate_templates('alert', $for_export); if ($templates_export == 'print') { $templates_filename = 'observium_templates_alert_'; if ($vars['entity_type']) { $templates_filename .= $vars['entity_type']; } else{ $templates_filename .= 'all'; } $form = array('type' => 'rows', 'space' => '10px', 'url' => generate_url($vars)); // Filename $form['row'][0]['filename'] = array( 'type' => 'text', 'name' => 'Filename', 'value' => $templates_filename . '.xml', 'grid_xs' => 8, 'width' => '100%', 'placeholder' => TRUE); // Save as human formatted XML $form['row'][0]['formatted'] = array( 'type' => 'select', 'grid_xs' => 4, 'value' => (class_exists('DOMDocument') ? 'yes' : 'no'), 'values' => array('yes' => 'Formatted', 'no' => 'Unformatted')); // search button $form['row'][0]['saveas'] = array( 'type' => 'submit', 'name' => 'Save as..', 'icon' => 'icon-save', 'right' => TRUE, 'value' => 'yes' ); print_form($form); print_xml($templates_xml); //r(xml_to_array($templates_xml)); } else { $templates_filename = $templates_export; download_as_file($templates_xml, $templates_filename, $vars); } unset($for_export, $templates_xml, $templates_export, $templates_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 = array();
//r($check);
foreach ($check['conditions'] as $condition)
{
$text_block[] = escape_html($condition['metric'].' '.$condition['condition'].' '.$condition['value']);
}
echo(''.($check['and'] ? 'ALL' : 'ANY').' '); echo(' '.implode(' ');
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'].' '.$contact['contact_descr'].' '; } echo generate_tooltip_link('', ''.$notifiers_count.' Notifiers', $content); } else { echo 'Default Notifier'; } echo ' | ';
}
echo '