This file is indexed.

/usr/share/zabbix/report3.php is in zabbix-frontend-php 1:2.4.7+dfsg-2ubuntu2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
<?php
/*
** Zabbix
** Copyright (C) 2001-2015 Zabbix SIA
**
** 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
**/


require_once dirname(__FILE__).'/include/config.inc.php';
require_once dirname(__FILE__).'/include/services.inc.php';

$page['title'] = _('IT services availability report');
$page['file'] = 'report3.php';
$page['hist_arg'] = array();

require_once dirname(__FILE__).'/include/page_header.php';

//	VAR			TYPE	OPTIONAL FLAGS	VALIDATION	EXCEPTION
$fields = array(
	'serviceid' =>	array(T_ZBX_INT, O_MAND,	P_SYS,	DB_ID,										null),
	'period' =>		array(T_ZBX_STR, O_OPT,		null,	IN('"daily","weekly","monthly","yearly"'),	null),
	'year' =>		array(T_ZBX_INT, O_OPT,		null,	null,										null)
);
check_fields($fields);

$period = getRequest('period', 'weekly');
$year = getRequest('year', date('Y'));

define('YEAR_LEFT_SHIFT', 5);

$service = API::Service()->get(array(
	'output' => array('serviceid', 'name', 'showsla', 'goodsla'),
	'serviceids' => $_REQUEST['serviceid']
));
$service = reset($service);
if (!$service) {
	access_deny();
}

$form = new CForm();
$form->setMethod('get');
$form->addVar('serviceid', $_REQUEST['serviceid']);

$cmbPeriod = new CComboBox('period', $period, 'submit();');
$cmbPeriod->addItem('daily', _('Daily'));
$cmbPeriod->addItem('weekly', _('Weekly'));
$cmbPeriod->addItem('monthly', _('Monthly'));
$cmbPeriod->addItem('yearly', _('Yearly'));
$form->addItem(array(SPACE._('Period').SPACE, $cmbPeriod));

if ($period != 'yearly') {
	$cmbYear = new CComboBox('year', $year, 'submit();');

	for ($y = (date('Y') - YEAR_LEFT_SHIFT); $y <= date('Y'); $y++) {
		$cmbYear->addItem($y, $y);
	}
	$form->addItem(array(SPACE._('Year').SPACE, $cmbYear));
}

show_table_header(array(
	_('IT SERVICES AVAILABILITY REPORT'),
	SPACE.'"',
	new CLink($service['name'], 'srv_status.php?showgraph=1&serviceid='.$service['serviceid']),
	'"'
	), $form
);

$table = new CTableInfo();

$header = array(_('Ok'), _('Problems'), _('Downtime'), _('SLA'), _('Acceptable SLA'));

switch ($period) {
	case 'yearly':
		$from = date('Y') - YEAR_LEFT_SHIFT;
		$to = date('Y');
		array_unshift($header, new CCol(_('Year'), 'center'));

		function get_time($y) {
			return mktime(0, 0, 0, 1, 1, $y);
		}

		function format_time($t) {
			return zbx_date2str(_x('Y', DATE_FORMAT_CONTEXT), $t);
		}

		function format_time2($t) {
			return null;
		}
		break;
	case 'monthly':
		$from = 1;
		$to = 12;
		array_unshift($header, new CCol(_('Month'), 'center'));

		function get_time($m) {
			global $year;
			return mktime(0, 0, 0, $m, 1, $year);
		}

		function format_time($t) {
			return zbx_date2str(_x('F', DATE_FORMAT_CONTEXT), $t);
		}

		function format_time2($t) {
			return null;
		}
		break;
	case 'daily':
		$from = 1;
		$to = DAY_IN_YEAR;
		array_unshift($header, new CCol(_('Day'), 'center'));

		function get_time($d) {
			global $year;
			return mktime(0, 0, 0, 1, $d, $year);
		}

		function format_time($t) {
			return zbx_date2str(DATE_FORMAT, $t);
		}

		function format_time2($t) {
			return null;
		}
		break;
	case 'weekly':
	default:
		$from = 0;
		$to = 52;
		array_unshift($header, new CCol(_('From'), 'center'), new CCol(_('Till'), 'center'));

		function get_time($w) {
			static $beg;
			if (!isset($beg)) {
				global $year;
				$time = mktime(0,0,0,1, 1, $year);
				$wd = date('w', $time);
				$wd = $wd == 0 ? 6 : $wd - 1;
				$beg =  $time - $wd * SEC_PER_DAY;
			}

			return strtotime("+$w week", $beg);
		}

		function format_time($t) {
			return zbx_date2str(DATE_TIME_FORMAT, $t);
		}

		function format_time2($t) {
			return format_time($t);
		}
		break;
}

$table->setHeader($header);

$intervals = array();
for ($t = $from; $t <= $to; $t++) {
	if (($start = get_time($t)) > time()) {
		break;
	}

	if (($end = get_time($t + 1)) > time()) {
		$end = time();
	}

	$intervals[] = array(
		'from' => $start,
		'to' => $end
	);
}

$sla = API::Service()->getSla(array(
	'serviceids' => $service['serviceid'],
	'intervals' => $intervals
));
$sla = reset($sla);

foreach ($sla['sla'] as $intervalSla) {
	$ok = new CSpan(
		sprintf('%dd %dh %dm',
			$intervalSla['okTime'] / SEC_PER_DAY,
			($intervalSla['okTime'] % SEC_PER_DAY) / SEC_PER_HOUR,
			($intervalSla['okTime'] % SEC_PER_HOUR) / SEC_PER_MIN
		), 'off'
	);

	$problems = new CSpan(
		sprintf('%dd %dh %dm',
			$intervalSla['problemTime'] / SEC_PER_DAY,
			($intervalSla['problemTime'] % SEC_PER_DAY) / SEC_PER_HOUR,
			($intervalSla['problemTime'] % SEC_PER_HOUR) /SEC_PER_MIN
		), 'on'
	);

	$downtime = sprintf('%dd %dh %dm',
		$intervalSla['downtimeTime'] / SEC_PER_DAY,
		($intervalSla['downtimeTime'] % SEC_PER_DAY) / SEC_PER_HOUR,
		($intervalSla['downtimeTime'] % SEC_PER_HOUR) / SEC_PER_MIN
	);

	$percentage = new CSpan(sprintf('%2.4f', $intervalSla['sla']), ($intervalSla['sla'] >= $service['goodsla'] ? 'off' : 'on'));

	$table->addRow(array(
		format_time($intervalSla['from']),
		format_time2($intervalSla['to']),
		$ok,
		$problems,
		$downtime,
		($service['showsla']) ? $percentage : '-',
		($service['showsla']) ? new CSpan($service['goodsla']) : '-'
	));
}
$table->show();

require_once dirname(__FILE__).'/include/page_footer.php';