-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathservices.php
More file actions
107 lines (87 loc) · 3.67 KB
/
Copy pathservices.php
File metadata and controls
107 lines (87 loc) · 3.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
# +-----------------------------------------------------------------+
# | |
# | ( ___ \ | \ /\|\ /||\ /|( ( /| |
# | | ( ) ) | \ / /| ) ( || ) ( || \ ( | |
# | | (__/ / | (_/ / | | | || (___) || \ | | |
# | | __ ( | _ ( | | | || ___ || (\ \) | |
# | | ( \ \ | ( \ \ | | | || ( ) || | \ | |
# | | )___) )_ | / \ \| (___) || ) ( || ) \ | |
# | |/ \___/(_) |_/ \/(_______)|/ \||/ )_) |
# | |
# | Copyright Bastian Kuhn 2011 mail@bastian-kuhn.de |
# +-----------------------------------------------------------------+
#
# NagUI more information: http://nagui.de
#
# This is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation in version 2. NagUI is distributed
# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU General Public License for more de-
# ails. You should have received a copy of the GNU General Public
# License along with GNU Make; see the file COPYING. If not, write
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
require("./includes/header.inc.php");
$columns = (isset($_GET['columns'])) ? str_replace(","," ",$_GET['columns']) : str_replace(","," ",$fields_services) ;
$columns_array = (isset($_GET['columns'])) ? explode(',',$_GET['columns']) : explode(',',$fields_services);
$output_format = (isset($_GET['output_format'])) ? $_GET['output_format'] : $output_format;
$query = "GET services\nColumns: $columns\n";
$stats = "";
$status_count = 0;
foreach($_GET AS $index => $wert)
{
switch($index)
{
case "filter_host_name":
$query .= "Filter: host_name ~ $wert\nAnd: 1\n";
break;
case "filter_service":
$query .= "Filter: description ~ $wert\nAnd: 1\n";
break;
case "filter_state_ok":
$status_count++;
$stats .= "Filter: state = 0\n";
break;
case "filter_state_warn":
$status_count++;
$stats .= "Filter: state = 1\n";
break;
case "filter_state_crit":
$status_count++;
$stats .= "Filter: state = 2\n";
break;
case "filter_state_unk":
$status_count++;
$stats .= "Filter: state = 2\n";
break;
case "filter_acknowledged":
$query .= ($wert != "no") ? "Filter: acknowledged = $wert\nAnd: 1\n" : "";
break;
case "filter_state_total":
$query .= "Filter: state > 0\nFilter: scheduled_downtime_depth = 0\nFilter: host_scheduled_downtime_depth = 0\nStats: host_state = 0\nAnd: 4\n";
break;
case "filter_state_unhandled":
$query .= "Filter: state > 0\nFilter: scheduled_downtime_depth = 0\nFilter: host_scheduled_downtime_depth = 0\nFilter: acknowledged = 0\nFilter: host_state = 0\nAnd: 5\n";
break;
case "filter_service_groups":
$query .= "Filter:service_groups >= $wert\nAnd: 1\n";
break;
}
}
//Status Filter setzen
if($status_count != 0)
{
$query .= $stats."Or: $status_count\n";
}
$erg = $livestatus->query($query);
if($output_format == "smarty")
{
$template = (isset($_GET['tpl_file'])) ? $_GET['tpl_file'] : "services.html";
$output->smarty($erg,$columns_array,$template);
}elseif($output_format == "json")
{
$output->json($erg,$columns_array);
}