summaryrefslogtreecommitdiffstats
path: root/frontends/php/queue.php
blob: 814a7f4525162e7d2dd21641d18811975e3b1ee6 (plain)
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
154
155
<?php
/* 
** ZABBIX
** Copyright (C) 2000-2005 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
	require_once "include/config.inc.php";
	require_once "include/items.inc.php";

	$page["title"] = "S_QUEUE_BIG";
	$page["file"] = "queue.php";
	$page['hist_arg'] = array('show');
	
	define('ZBX_PAGE_DO_REFRESH', 1);

include_once "include/page_header.php";

?>
<?php
//		VAR			TYPE	OPTIONAL FLAGS	VALIDATION	EXCEPTION
	$fields=array(
		"show"=>		array(T_ZBX_INT, O_OPT,	P_SYS,	IN("0,1"),	NULL)
	);

	check_fields($fields);
	
	$available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY,PERM_RES_IDS_ARRAY);
?>

<?php
	$_REQUEST["show"] = get_request("show", 0);

	$form = new CForm();
	$form->SetMethod('get');
	
	$cmbMode = new CComboBox("show", $_REQUEST["show"], "submit();");
	$cmbMode->AddItem(0, S_OVERVIEW);
	$cmbMode->AddItem(1, S_DETAILS);
	$form->AddItem($cmbMode);

	show_table_header(S_QUEUE_OF_ITEMS_TO_BE_UPDATED_BIG, $form);
?>

<?php
	$now = time();

	$item_types = array(
			ITEM_TYPE_ZABBIX,
			ITEM_TYPE_ZABBIX_ACTIVE,
			ITEM_TYPE_SNMPV1,
			//ITEM_TYPE_TRAPPER,
			ITEM_TYPE_SNMPV2C,
			ITEM_TYPE_SNMPV3,
			ITEM_TYPE_SIMPLE,
			ITEM_TYPE_INTERNAL,
			ITEM_TYPE_AGGREGATE,
			//ITEM_TYPE_HTTPTEST,
			ITEM_TYPE_EXTERNAL);

	$result = DBselect('SELECT i.itemid,i.nextcheck,i.description,i.key_,i.type,h.host,h.hostid '.
		' FROM items i,hosts h '.
		' WHERE i.status='.ITEM_STATUS_ACTIVE.
			' AND i.type in ('.implode(',',$item_types).') '.
			' AND ((h.status='.HOST_STATUS_MONITORED.' AND h.available != '.HOST_AVAILABLE_FALSE.') '.
				' OR (h.status='.HOST_STATUS_MONITORED.' AND h.available='.HOST_AVAILABLE_FALSE.' AND h.disable_until<='.$now.')) '.
			' AND i.hostid=h.hostid '.
			' AND i.nextcheck + 5 <'.$now.
			' AND i.key_ NOT IN ('.zbx_dbstr('status').','.zbx_dbstr('icmpping').','.zbx_dbstr('icmppingsec').','.zbx_dbstr('zabbix[log]').') '.
			' AND i.value_type not in ('.ITEM_VALUE_TYPE_LOG.') '.
			' AND '.DBcondition('h.hostid',$available_hosts).
			' AND '.DBin_node('h.hostid', get_current_nodeid()).
		' ORDER BY i.nextcheck,h.host,i.description,i.key_');

	$table = new CTableInfo(S_THE_QUEUE_IS_EMPTY);

	if($_REQUEST["show"]==0){

		foreach($item_types as $type){
			$sec_10[$type]=0;
			$sec_30[$type]=0;
			$sec_60[$type]=0;
			$sec_300[$type]=0;
			$sec_600[$type]=0;
			$sec_rest[$type]=0;
		}

		while($row=DBfetch($result)){
			if($now-$row["nextcheck"]<=10)			$sec_10[$row["type"]]++;
			else if($now-$row["nextcheck"]<=30)		$sec_30[$row["type"]]++;
			else if($now-$row["nextcheck"]<=60)		$sec_60[$row["type"]]++;
			else if($now-$row["nextcheck"]<=300)		$sec_300[$row["type"]]++;
			else if($now-$row["nextcheck"]<=600)		$sec_600[$row["type"]]++;
			else	$sec_rest[$row["type"]]++;

		}
		
		$table->setHeader(array(S_ITEMS,S_5_SECONDS,S_10_SECONDS,S_30_SECONDS,S_1_MINUTE,S_5_MINUTES,S_MORE_THAN_10_MINUTES));
		foreach($item_types as $type){
			$elements=array(
				item_type2str($type),
				new CCol($sec_10[$type],($sec_10[$type])?"unknown_trigger":"normal"),
				new CCol($sec_30[$type],($sec_30[$type])?"information":"normal"),
				new CCol($sec_60[$type],($sec_60[$type])?"warning":"normal"),
				new CCol($sec_300[$type],($sec_300[$type])?"average":"normal"),
				new CCol($sec_300[$type],($sec_600[$type])?"high":"normal"),
				new CCol($sec_rest[$type],($sec_rest[$type])?"disaster":"normal")
			);
			
			$table->addRow($elements);
		}
	}
	else{
		$table->SetHeader(array(
				S_NEXT_CHECK,
				is_show_subnodes() ? S_NODE : null,
				S_HOST,
				S_DESCRIPTION
				));
		while($row=DBfetch($result)){
			$table->AddRow(array(
				date("m.d.Y H:i:s",
					$row["nextcheck"]),
				get_node_name_by_elid($row['hostid']),
				$row['host'],
				item_description($row["description"],$row["key_"])
				));
		}
	}

	$table->Show();

	if($_REQUEST["show"]!=0){
		show_table_header(S_TOTAL.": ".$table->GetNumRows());
	}
?>
<?php

include_once "include/page_footer.php";

?>