1<?php
2
3/**
4 * Observium Network Management and Monitoring System
5 * Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
6 *
7 * @package    observium
8 * @subpackage webui
9 * @author     Adam Armstrong <adama@observium.org>
10 * @copyright  (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
11 *
12 */
13
14$alert_rules = cache_alert_rules();
15$alert_assoc = cache_alert_assoc();
16$alert_table = cache_device_alert_table($device['device_id']);
17
18if (!isset($vars['status'])) { $vars['status'] = 'failed'; }
19if (!$vars['entity_type']) { $vars['entity_type'] = 'all'; }
20
21// Build Navbar
22
23$navbar['class'] = "navbar-narrow";
24$navbar['brand'] = "Alert Types";
25
26if ($vars['entity_type'] == 'all') { $navbar['options']['all']['class'] = "active"; }
27$navbar['options']['all']['url'] = generate_url(array('page' => 'device', 'device' => $device['device_id'],
28                                                'tab' => 'alerts', 'entity_type' => 'all'));
29$navbar['options']['all']['text'] = "All";
30
31foreach ($alert_table as $entity_type => $thing)
32{
33
34  if (!$vars['entity_type']) { $vars['entity_type'] = $entity_type; }
35  if ($vars['entity_type'] == $entity_type) { $navbar['options'][$entity_type]['class'] = "active"; }
36
37  $navbar['options'][$entity_type]['url'] = generate_url(array('page' => 'device', 'device' => $device['device_id'],
38                                                  'tab' => 'alerts', 'entity_type' => $entity_type));
39  $navbar['options'][$entity_type]['icon'] = $config['entities'][$entity_type]['icon'];
40  $navbar['options'][$entity_type]['text'] = escape_html(nicecase($entity_type));
41}
42
43if (isset($config['enable_syslog']) && $config['enable_syslog'] && OBSERVIUM_EDITION != 'community')
44{
45  $entity_type = "syslog";
46
47  if (!$vars['entity_type']) { $vars['entity_type'] = 'syslog'; }
48  if ($vars['entity_type'] == 'syslog') { $navbar['options'][$entity_type]['class'] = "active"; }
49
50  $navbar['options'][$entity_type]['url'] = generate_url(array('page' => 'device', 'device' => $device['device_id'],
51                                                  'tab' => 'alerts', 'entity_type' => $entity_type));
52  $navbar['options'][$entity_type]['icon'] = $config['icon']['syslog-alerts'];
53  $navbar['options'][$entity_type]['text'] = 'Syslog';
54}
55
56$navbar['options_right']['update']['url']  = generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'alerts', 'action'=>'update'));
57$navbar['options_right']['update']['text'] = 'Rebuild';
58$navbar['options_right']['update']['icon'] = $config['icon']['rebuild'];
59if ($vars['action'] == 'update') { $navbar['options_right']['update']['class'] = 'active'; }
60
61$navbar['options_right']['filters']['url']       = '#';
62$navbar['options_right']['filters']['text']      = 'Filter';
63$navbar['options_right']['filters']['icon']      = $config['icon']['filter'];
64$navbar['options_right']['filters']['link_opts'] = 'data-hover="dropdown" data-toggle="dropdown"';
65
66$filters = array('all'     => array('url'   => generate_url($vars, array('status' => 'all')),
67                                       'url_o' => generate_url($vars, array('status' => 'all')),
68                                       'icon'  => $config['icon']['info'],
69                                       'text'  => 'All'),
70
71                 'failed_delayed' => array('url'   => generate_url($vars, array('status' => 'failed_delayed')),
72                                       'url_o' => generate_url($vars, array('page' => 'alerts', 'status' => 'all')),
73                                       'icon'  => $config['icon']['error'],
74                                       'text'  => 'Failed & Delayed'),
75
76                 'failed'     => array('url'   => generate_url($vars, array('status' => 'failed')),
77                                       'url_o' => generate_url($vars, array('status' => 'all')),
78                                       'icon'  => $config['icon']['cancel'],
79                                       'text'  => 'Failed'),
80
81                 'suppressed' => array('url'   => generate_url($vars, array('status' => 'suppressed')),
82                                       'url_o' => generate_url($vars, array('status' => 'all')),
83                                       'icon'  => $config['icon']['exclamation'],
84                                       'text'  => 'Suppressed')
85);
86
87foreach ($filters as $option => $option_array)
88{
89
90  $navbar['options_right']['filters']['suboptions'][$option]['text'] = $option_array['text'];
91  $navbar['options_right']['filters']['suboptions'][$option]['icon'] = $option_array['icon'];
92
93  if ($vars['status'] == $option)
94  {
95    $navbar['options_right']['filters']['suboptions'][$option]['class'] = "active";
96    if ($vars['status'] != "all") {
97      $navbar['options_right']['filters']['class'] = "active";
98    }
99    $navbar['options_right']['filters']['suboptions'][$option]['url'] = $option_array['url_o'];
100    $navbar['options_right']['filters']['text'] .= " (".$option_array['text'].")";
101    $navbar['options_right']['filters']['icon'] = $option_array['icon'];
102
103  } else {
104    $navbar['options_right']['filters']['suboptions'][$option]['url'] = $option_array['url'];
105  }
106}
107
108print_navbar($navbar);
109unset($navbar);
110
111// Run actions
112
113if($vars['action'] == 'update')
114{
115  echo generate_box_open();
116  update_device_alert_table($device);
117  $alert_table = cache_device_alert_table($device['device_id']);
118  echo generate_box_close();
119}
120
121$vars['pagination'] = TRUE;
122
123if($vars['entity_type'] == "syslog")
124{
125
126  print_logalert_log($vars);
127
128} else {
129  print_alert_table($vars);
130}
131// EOF
132