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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
<?php
/*
** ZABBIX
** Copyright (C) 2000-2008 SIA Zabbix
**
** This program 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; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
?>
<?php
function show_report2_header($config,$available_hosts){
$r_form = new CForm();
$r_form->SetMethod('get');
$cmbConf = new CComboBox('config',$config,'submit()');
$cmbConf->AddItem(0,S_BY_HOST);
$cmbConf->AddItem(1,S_BY_TRIGGER_TEMPLATE);
$r_form->AddItem(array(S_MODE.SPACE,$cmbConf,SPACE));
$cmbGroup = new CComboBox('groupid',$_REQUEST['groupid'],'submit()');
$cmbGroup->AddItem(0,S_ALL_SMALL);
$status_filter = ' AND h.status='.HOST_STATUS_MONITORED;
if($config==1)
$status_filter = ' AND h.status='.HOST_STATUS_TEMPLATE;
$sql = 'SELECT DISTINCT g.groupid,g.name '.
' FROM groups g,hosts_groups hg,hosts h'.
' WHERE h.hostid in ('.$available_hosts.') '.
' AND g.groupid=hg.groupid '.
' AND h.hostid=hg.hostid'.$status_filter.
' ORDER BY g.name';
$result=DBselect($sql);
while($row=DBfetch($result)){
$cmbGroup->AddItem($row['groupid'], get_node_name_by_elid($row['groupid']).$row['name']);
}
$r_form->AddItem(array(S_GROUP.SPACE,$cmbGroup));
if(0 == $config){
$cmbHosts = new CComboBox('hostid',$_REQUEST['hostid'],'submit()');
$sql_cond = ' AND h.status='.HOST_STATUS_MONITORED;
}
else{
$cmbTpls = new CComboBox('hostid',$_REQUEST['hostid'],'submit()');
$cmbTrigs = new CComboBox('tpl_triggerid',get_request('tpl_triggerid',0),'submit()');
$cmbTrigs->AddItem(0,S_ALL_SMALL);
$sql_cond = ' AND h.status='.HOST_STATUS_TEMPLATE;
}
if($_REQUEST['groupid'] > 0){
$sql='SELECT h.hostid,h.host '.
' FROM hosts h,items i,hosts_groups hg '.
' WHERE h.hostid=i.hostid '.
' AND hg.groupid='.$_REQUEST['groupid'].
' AND hg.hostid=h.hostid'.
' AND h.hostid in ('.$available_hosts.') '.
$sql_cond.
' GROUP BY h.hostid,h.host '.
' ORDER BY h.host';
}
else{
$sql='SELECT h.hostid,h.host '.
' FROM hosts h,items i '.
' WHERE h.hostid=i.hostid '.
' AND h.hostid in ('.$available_hosts.') '.
$sql_cond.
' GROUP BY h.hostid,h.host '.
' ORDER BY h.host';
if(0 == $config){
$cmbHosts->AddItem(0,S_ALL_SMALL);
}
else{
$cmbTpls->AddItem(0,S_ALL_SMALL);
}
}
$result=DBselect($sql);
while($row=DBfetch($result)){
if(0 == $config){
$cmbHosts->AddItem($row['hostid'],get_node_name_by_elid($row['hostid']).$row['host']);
}
else{
$cmbTpls->AddItem($row['hostid'],get_node_name_by_elid($row['hostid']).$row['host']);
}
}
if(0 == $config){
$r_form->AddItem(array(SPACE.S_HOST.SPACE,$cmbHosts));
}
else{
$r_form->AddItem(array(SPACE.S_TEMPLATE.SPACE,$cmbTpls));
if($_REQUEST['hostid'] > 0){
$sql = 'SELECT DISTINCT t.triggerid,t.description '.
' FROM triggers t,hosts h,items i,functions f '.
' WHERE f.itemid=i.itemid '.
' AND h.hostid=i.hostid '.
' AND t.status='.TRIGGER_STATUS_ENABLED.
' AND t.triggerid=f.triggerid '.
' AND h.hostid='.$_REQUEST['hostid'].
' AND h.status='.HOST_STATUS_TEMPLATE.
' AND '.DBin_node('t.triggerid').
' AND i.status='.ITEM_STATUS_ACTIVE.
' ORDER BY t.description';
}
else{
$sql = 'SELECT DISTINCT t.triggerid,t.description '.
' FROM triggers t,hosts h,items i,functions f '.
' WHERE f.itemid=i.itemid '.
' AND h.hostid=i.hostid '.
' AND t.status='.TRIGGER_STATUS_ENABLED.
' AND t.triggerid=f.triggerid '.
' AND h.status='.HOST_STATUS_TEMPLATE.
' AND h.hostid in ('.$available_hosts.')'.
' AND '.DBin_node('t.triggerid').
' AND i.status='.ITEM_STATUS_ACTIVE.
' ORDER BY t.description';
}
$result=DBselect($sql);
while($row=DBfetch($result)){
$cmbTrigs->AddItem(
$row['triggerid'],
get_node_name_by_elid($row['triggerid']).expand_trigger_description($row['triggerid'])
);
}
$r_form->AddItem(array(BR.S_TRIGGER.SPACE,$cmbTrigs));
}
show_table_header(S_AVAILABILITY_REPORT_BIG, $r_form);
}
?>
|