1
|
<?php
|
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
|
if (!defined('GLPI_ROOT')) {
|
44
|
die("Sorry. You can't access directly to this file");
|
45
|
}
|
46
|
|
47
|
class PluginMonitoringDisplay extends CommonDBTM {
|
48
|
|
49
|
function menu() {
|
50
|
global $CFG_GLPI;
|
51
|
|
52
|
$redirect = FALSE;
|
53
|
$a_url = array();
|
54
|
|
55
|
echo "<table class='tab_cadre_fixe' width='950'>";
|
56
|
echo "<tr class='tab_bg_3'>";
|
57
|
echo "<td>";
|
58
|
|
59
|
if (PluginMonitoringProfile::haveRight("restartshinken", 'w')
|
60
|
|| PluginMonitoringProfile::haveRight("servicescatalog", 'r')
|
61
|
|| PluginMonitoringProfile::haveRight("componentscatalog", 'r')
|
62
|
|| PluginMonitoringProfile::haveRight("allressources", 'r')) {
|
63
|
echo "<table class='tab_cadre_fixe' width='950'>";
|
64
|
echo "<tr class='tab_bg_1'>";
|
65
|
echo "<th width='19%' colspan='2'>";
|
66
|
if (PluginMonitoringProfile::haveRight("restartshinken", 'w')) {
|
67
|
echo "<a href='".$CFG_GLPI['root_doc']."/plugins/monitoring/front/restartshinken.form.php'>".
|
68
|
__('Restart Shinken', 'monitoring')."</a>";
|
69
|
}
|
70
|
echo "</th>";
|
71
|
echo "<th width='27%' colspan='2'>";
|
72
|
if (PluginMonitoringProfile::haveRight("servicescatalog", 'r')) {
|
73
|
$this->displayPuce('display_servicescatalog');
|
74
|
echo "<a href='".$CFG_GLPI['root_doc']."/plugins/monitoring/front/display_servicescatalog.php'>";
|
75
|
echo __('Services catalog', 'monitoring');
|
76
|
echo "</a>";
|
77
|
$a_url[] = $CFG_GLPI['root_doc']."/plugins/monitoring/front/display_servicescatalog.php";
|
78
|
} else {
|
79
|
if (basename($_SERVER['PHP_SELF']) == 'display_servicescatalog.php') {
|
80
|
$redirect = TRUE;
|
81
|
}
|
82
|
}
|
83
|
echo "</th>";
|
84
|
echo "<th width='27%' colspan='2'>";
|
85
|
if (PluginMonitoringProfile::haveRight("componentscatalog", 'r')) {
|
86
|
$this->displayPuce('display_componentscatalog');
|
87
|
echo "<a href='".$CFG_GLPI['root_doc']."/plugins/monitoring/front/display_componentscatalog.php'>";
|
88
|
echo __('Components catalog', 'monitoring');
|
89
|
echo "</a>";
|
90
|
$a_url[] = $CFG_GLPI['root_doc']."/plugins/monitoring/front/display_componentscatalog.php";
|
91
|
} else {
|
92
|
if (basename($_SERVER['PHP_SELF']) == 'display_componentscatalog.php') {
|
93
|
$redirect = TRUE;
|
94
|
}
|
95
|
}
|
96
|
echo "</th>";
|
97
|
echo "<th colspan='2'>";
|
98
|
if (PluginMonitoringProfile::haveRight("allressources", 'r')) {
|
99
|
$this->displayPuce('service');
|
100
|
echo "<a href='".$CFG_GLPI['root_doc']."/plugins/monitoring/front/service.php'>";
|
101
|
echo __('All resources', 'monitoring');
|
102
|
echo "</a>";
|
103
|
$a_url[] = $CFG_GLPI['root_doc']."/plugins/monitoring/front/service.php";
|
104
|
} else {
|
105
|
if (basename($_SERVER['PHP_SELF']) == 'service.php') {
|
106
|
$redirect = TRUE;
|
107
|
}
|
108
|
}
|
109
|
echo "</th>";
|
110
|
echo "</tr>";
|
111
|
echo "</table>";
|
112
|
} else {
|
113
|
if (basename($_SERVER['PHP_SELF']) == 'display_servicescatalog.php') {
|
114
|
$redirect = TRUE;
|
115
|
} else if (basename($_SERVER['PHP_SELF']) == 'display_componentscatalog.php') {
|
116
|
$redirect = TRUE;
|
117
|
} else if (basename($_SERVER['PHP_SELF']) == 'service.php') {
|
118
|
$redirect = TRUE;
|
119
|
}
|
120
|
}
|
121
|
|
122
|
$i = 1;
|
123
|
$pmDisplayview = new PluginMonitoringDisplayview();
|
124
|
$a_views = $pmDisplayview->getViews();
|
125
|
if (count($a_views) > 0) {
|
126
|
echo "<table class='tab_cadre_fixe' width='950'>";
|
127
|
echo "<tr class='tab_bg_1'>";
|
128
|
|
129
|
foreach ($a_views as $views_id=>$name) {
|
130
|
$pmDisplayview->getFromDB($views_id);
|
131
|
if ($pmDisplayview->haveVisibilityAccess()) {
|
132
|
if ($i == 6) {
|
133
|
echo "</tr>";
|
134
|
echo "<tr class='tab_bg_1'>";
|
135
|
$i = 1;
|
136
|
}
|
137
|
echo "<th width='20%'>";
|
138
|
$this->displayPuce('display_view', $views_id);
|
139
|
echo "<a href='".$CFG_GLPI['root_doc']."/plugins/monitoring/front/display_view.php?id=".$views_id."'>";
|
140
|
echo htmlentities($name);
|
141
|
echo "</a>";
|
142
|
echo "</th>";
|
143
|
$i++;
|
144
|
$a_url[] = $CFG_GLPI['root_doc']."/plugins/monitoring/front/display_view.php?id=".$views_id;
|
145
|
}
|
146
|
}
|
147
|
for ($i;$i < 6; $i++) {
|
148
|
echo "<td width='20%'>";
|
149
|
echo "</td>";
|
150
|
}
|
151
|
echo "</tr>";
|
152
|
echo "</table>";
|
153
|
}
|
154
|
|
155
|
echo "</td>";
|
156
|
echo "</tr>";
|
157
|
echo "</table>";
|
158
|
|
159
|
if ($redirect) {
|
160
|
Html::redirect(array_shift($a_url));
|
161
|
}
|
162
|
}
|
163
|
|
164
|
|
165
|
|
166
|
function defineTabs($options=array()){
|
167
|
global $CFG_GLPI;
|
168
|
|
169
|
if (isset($_GET['glpi_tab'])) {
|
170
|
Session::setActiveTab("PluginMonitoringDisplay",$_GET['glpi_tab']);
|
171
|
}
|
172
|
|
173
|
$pmDisplayview = new PluginMonitoringDisplayview();
|
174
|
|
175
|
$ong = array();
|
176
|
if (PluginMonitoringProfile::haveRight("servicescatalog", 'r')) {
|
177
|
$ong[1] = __('Services catalog', 'monitoring');
|
178
|
}
|
179
|
if (PluginMonitoringProfile::haveRight("componentscatalog", 'r')) {
|
180
|
$ong[2] = __('Components catalog', 'monitoring');
|
181
|
}
|
182
|
$ong[3] = __('All resources', 'monitoring');
|
183
|
$ong[4] = __('Dependencies;', 'monitoring');
|
184
|
if (PluginMonitoringProfile::haveRight("view", 'r')) {
|
185
|
$i = 5;
|
186
|
$a_views = $pmDisplayview->getViews();
|
187
|
foreach ($a_views as $name) {
|
188
|
$ong[$i] = htmlentities($name);
|
189
|
$i++;
|
190
|
}
|
191
|
}
|
192
|
return $ong;
|
193
|
}
|
194
|
|
195
|
|
196
|
|
197
|
function showTabs($options=array()) {
|
198
|
global $CFG_GLPI;
|
199
|
|
200
|
|
201
|
$ID = 0;
|
202
|
if (isset($this->fields['id'])) {
|
203
|
$ID = $this->fields['id'];
|
204
|
}
|
205
|
|
206
|
$target = $_SERVER['PHP_SELF'];
|
207
|
$extraparamhtml = "";
|
208
|
$extraparam = "";
|
209
|
$withtemplate = "";
|
210
|
|
211
|
if (is_array($options) && count($options)) {
|
212
|
if (isset($options['withtemplate'])) {
|
213
|
$withtemplate = $options['withtemplate'];
|
214
|
}
|
215
|
foreach ($options as $key => $val) {
|
216
|
$extraparamhtml .= "&$key=$val";
|
217
|
$extraparam .= "&$key=$val";
|
218
|
}
|
219
|
}
|
220
|
|
221
|
if (empty($withtemplate) && $ID && $this->getType() && $this->displaylist) {
|
222
|
$glpilistitems =& $_SESSION['glpilistitems'][$this->getType()];
|
223
|
$glpilisttitle =& $_SESSION['glpilisttitle'][$this->getType()];
|
224
|
$glpilisturl =& $_SESSION['glpilisturl'][$this->getType()];
|
225
|
|
226
|
if (empty($glpilisturl)) {
|
227
|
$glpilisturl = $this->getSearchURL();
|
228
|
}
|
229
|
|
230
|
echo "<div id='menu_navigate'>";
|
231
|
|
232
|
$next = $prev = $first = $last = -1;
|
233
|
$current = false;
|
234
|
if (is_array($glpilistitems)) {
|
235
|
$current = array_search($ID,$glpilistitems);
|
236
|
if ($current !== false) {
|
237
|
|
238
|
if (isset($glpilistitems[$current+1])) {
|
239
|
$next = $glpilistitems[$current+1];
|
240
|
}
|
241
|
|
242
|
if (isset($glpilistitems[$current-1])) {
|
243
|
$prev = $glpilistitems[$current-1];
|
244
|
}
|
245
|
|
246
|
$first = $glpilistitems[0];
|
247
|
if ($first == $ID) {
|
248
|
$first = -1;
|
249
|
}
|
250
|
|
251
|
$last = $glpilistitems[count($glpilistitems)-1];
|
252
|
if ($last == $ID) {
|
253
|
$last = -1;
|
254
|
}
|
255
|
|
256
|
}
|
257
|
}
|
258
|
$cleantarget = Html::cleanParametersURL($target);
|
259
|
echo "<ul>";
|
260
|
echo "<li><a href=\"javascript:showHideDiv('tabsbody','tabsbodyimg','".$CFG_GLPI["root_doc"].
|
261
|
"/pics/deplier_down.png','".$CFG_GLPI["root_doc"]."/pics/deplier_up.png')\">";
|
262
|
echo "<img alt='' name='tabsbodyimg' src=\"".$CFG_GLPI["root_doc"]."/pics/deplier_up.png\">";
|
263
|
echo "</a></li>";
|
264
|
|
265
|
echo "<li><a href=\"".$glpilisturl."\">";
|
266
|
|
267
|
if ($glpilisttitle) {
|
268
|
if (Toolbox::strlen($glpilisttitle) > $_SESSION['glpidropdown_chars_limit']) {
|
269
|
$glpilisttitle = Toolbox::substr($glpilisttitle, 0,
|
270
|
$_SESSION['glpidropdown_chars_limit'])
|
271
|
. "…";
|
272
|
}
|
273
|
echo $glpilisttitle;
|
274
|
|
275
|
} else {
|
276
|
echo __('List');
|
277
|
}
|
278
|
echo "</a> : </li>";
|
279
|
|
280
|
if ($first > 0) {
|
281
|
echo "<li><a href='$cleantarget?id=$first$extraparamhtml'><img src='".
|
282
|
$CFG_GLPI["root_doc"]."/pics/first.png' alt=\"".__('First').
|
283
|
"\" title=\"".__('First')."\"></a></li>";
|
284
|
} else {
|
285
|
echo "<li><img src='".$CFG_GLPI["root_doc"]."/pics/first_off.png' alt=\"".
|
286
|
__('First')."\" title=\"".__('First')."\"></li>";
|
287
|
}
|
288
|
|
289
|
if ($prev > 0) {
|
290
|
echo "<li><a href='$cleantarget?id=$prev$extraparamhtml'><img src='".
|
291
|
$CFG_GLPI["root_doc"]."/pics/left.png' alt=\"".__('Previous').
|
292
|
"\" title=\"".__('Previous')."\"></a></li>";
|
293
|
} else {
|
294
|
echo "<li><img src='".$CFG_GLPI["root_doc"]."/pics/left_off.png' alt=\"".
|
295
|
__('Previous')."\" title=\"".__('Previous')."\"></li>";
|
296
|
}
|
297
|
|
298
|
if ($current !== false) {
|
299
|
echo "<li>".($current+1) . "/" . count($glpilistitems)."</li>";
|
300
|
}
|
301
|
|
302
|
if ($next > 0) {
|
303
|
echo "<li><a href='$cleantarget?id=$next$extraparamhtml'><img src='".
|
304
|
$CFG_GLPI["root_doc"]."/pics/right.png' alt=\"".__('Next').
|
305
|
"\" title=\"".__('Next')."\"></a></li>";
|
306
|
} else {
|
307
|
echo "<li><img src='".$CFG_GLPI["root_doc"]."/pics/right_off.png' alt=\"".
|
308
|
__('Next')."\" title=\"".__('Next')."\"></li>";
|
309
|
}
|
310
|
|
311
|
if ($last > 0) {
|
312
|
echo "<li><a href='$cleantarget?id=$last$extraparamhtml'><img src=\"".
|
313
|
$CFG_GLPI["root_doc"]."/pics/last.png\" alt=\"".__('Last').
|
314
|
"\" title=\"".__('Last')."\"></a></li>";
|
315
|
} else {
|
316
|
echo "<li><img src='".$CFG_GLPI["root_doc"]."/pics/last_off.png' alt=\"".
|
317
|
__('Last')."\" title=\"".__('Last')."\"></li>";
|
318
|
}
|
319
|
echo "</ul></div>";
|
320
|
echo "<div class='sep'></div>";
|
321
|
}
|
322
|
|
323
|
echo "<div id='tabspanel' class='center-h'></div>";
|
324
|
|
325
|
$onglets = $this->defineTabs($options);
|
326
|
$display_all = true;
|
327
|
if (isset($onglets['no_all_tab'])) {
|
328
|
$display_all = false;
|
329
|
unset($onglets['no_all_tab']);
|
330
|
}
|
331
|
$class = $this->getType();
|
332
|
if ($_SESSION['glpi_use_mode']==Session::DEBUG_MODE
|
333
|
&& ($ID > 0 || $this->showdebug)
|
334
|
&& (method_exists($class, 'showDebug')
|
335
|
|| in_array($class, $CFG_GLPI["infocom_types"])
|
336
|
|| in_array($class, $CFG_GLPI["reservation_types"]))) {
|
337
|
|
338
|
$onglets[-2] = __('Debug');
|
339
|
}
|
340
|
|
341
|
if (count($onglets)) {
|
342
|
$tabpage = $this->getTabsURL();
|
343
|
$tabs = array();
|
344
|
|
345
|
foreach ($onglets as $key => $val ) {
|
346
|
$tabs[$key] = array('title' => $val,
|
347
|
'url' => $tabpage,
|
348
|
'params' => "target=$target&itemtype=".$this->getType().
|
349
|
"&glpi_tab=$key&id=$ID$extraparam");
|
350
|
}
|
351
|
|
352
|
$plug_tabs = Plugin::getTabs($target,$this, $withtemplate);
|
353
|
$tabs += $plug_tabs;
|
354
|
|
355
|
if ($display_all && empty($withtemplate) && count($tabs)>1) {
|
356
|
$tabs[-1] = array('title' => __('All'),
|
357
|
'url' => $tabpage,
|
358
|
'params' => "target=$target&itemtype=".$this->getType().
|
359
|
"&glpi_tab=-1&id=$ID$extraparam");
|
360
|
}
|
361
|
Ajax::createTabs('tabspanel', 'tabcontent', $tabs, $this->getType(), "'100%'");
|
362
|
}
|
363
|
}
|
364
|
|
365
|
|
366
|
|
367
|
function showBoard($width='', $limit='') {
|
368
|
global $DB,$CFG_GLPI;
|
369
|
|
370
|
$order = "ASC";
|
371
|
if (isset($_GET['order'])) {
|
372
|
$order = $_GET['order'];
|
373
|
}
|
374
|
|
375
|
$where = '';
|
376
|
if ($limit == 'hosts') {
|
377
|
$where = "`plugin_monitoring_services_id`='0' ";
|
378
|
} else if ($limit == 'services') {
|
379
|
$where = "`plugin_monitoring_services_id`>0 ";
|
380
|
}
|
381
|
if (isset($_GET['field'])) {
|
382
|
foreach ($_GET['field'] as $key=>$value) {
|
383
|
$wheretmp = '';
|
384
|
if (isset($_GET['link'][$key])) {
|
385
|
$wheretmp.= " ".$_GET['link'][$key]." ";
|
386
|
}
|
387
|
$wheretmp .= Search::addWhere(
|
388
|
"",
|
389
|
0,
|
390
|
"PluginMonitoringService",
|
391
|
$_GET['field'][$key],
|
392
|
$_GET['searchtype'][$key],
|
393
|
$_GET['contains'][$key]);
|
394
|
if (!strstr($wheretmp, "``.``")) {
|
395
|
if ($where != ''
|
396
|
AND !isset($_GET['link'][$key])) {
|
397
|
$where .= " AND ";
|
398
|
}
|
399
|
$where .= $wheretmp;
|
400
|
}
|
401
|
}
|
402
|
}
|
403
|
if ($where != '') {
|
404
|
$where = "(".$where;
|
405
|
$where .= ") AND ";
|
406
|
}
|
407
|
$where .= ' `glpi_plugin_monitoring_services`.`entities_id` IN ('.$_SESSION['glpiactiveentities_string'].')';
|
408
|
|
409
|
if ($where != '') {
|
410
|
$where = " WHERE ".$where;
|
411
|
$where = str_replace("`".getTableForItemType("PluginMonitoringDisplay")."`.",
|
412
|
"", $where);
|
413
|
|
414
|
}
|
415
|
|
416
|
$leftjoin = '';
|
417
|
$leftjoin .= " LEFT JOIN `glpi_plugin_monitoring_components`
|
418
|
ON `plugin_monitoring_components_id` =
|
419
|
`glpi_plugin_monitoring_components`.`id` ";
|
420
|
$leftjoin .= " LEFT JOIN `glpi_entities`
|
421
|
ON `".getTableForItemType("PluginMonitoringService")."`.`entities_id` =
|
422
|
`glpi_entities`.`id`";
|
423
|
if (isset($_GET['field'])) {
|
424
|
foreach ($_GET['field'] as $value) {
|
425
|
if ($value == '20'
|
426
|
OR $value == '21'
|
427
|
OR $value == '22') {
|
428
|
$leftjoin .= " LEFT JOIN `glpi_plugin_monitoring_componentscatalogs_hosts`
|
429
|
ON `plugin_monitoring_componentscatalogs_hosts_id` =
|
430
|
`glpi_plugin_monitoring_componentscatalogs_hosts`.`id` ";
|
431
|
} else if ($value == '7') {
|
432
|
} else if ($value == '8') {
|
433
|
if (!strstr($leftjoin, 'LEFT JOIN `glpi_plugin_monitoring_componentscatalogs_hosts`')) {
|
434
|
$leftjoin .= " LEFT JOIN `glpi_plugin_monitoring_componentscatalogs_hosts`
|
435
|
ON `plugin_monitoring_componentscatalogs_hosts_id` =
|
436
|
`glpi_plugin_monitoring_componentscatalogs_hosts`.`id` ";
|
437
|
}
|
438
|
if (!strstr($leftjoin, 'LEFT JOIN `glpi_plugin_monitoring_componentscatalogs`')) {
|
439
|
$leftjoin .= " LEFT JOIN `glpi_plugin_monitoring_componentscatalogs`
|
440
|
ON `glpi_plugin_monitoring_componentscatalogs_hosts`.`plugin_monitoring_componentscalalog_id` =
|
441
|
`glpi_plugin_monitoring_componentscatalogs`.`id` ";
|
442
|
}
|
443
|
}
|
444
|
}
|
445
|
}
|
446
|
|
447
|
|
448
|
$ORDERQUERY = " ORDER BY `name` ";
|
449
|
$toview = array(3, 6, 7, 10, 4, 9);
|
450
|
$toviewComplete = array(
|
451
|
'ITEM_0' => 'state',
|
452
|
'ITEM_1' => 'completename',
|
453
|
'ITEM_2' => 'component_name',
|
454
|
'ITEM_3' => 'state',
|
455
|
'ITEM_4' => 'last_check',
|
456
|
'ITEM_5' => 'event'
|
457
|
);
|
458
|
foreach ($toview as $key => $val) {
|
459
|
if ($_GET['sort']==$val) {
|
460
|
$ORDERQUERY = Search::addOrderBy("PluginMonitoringService", $_GET['sort'],
|
461
|
$_GET['order'], $key);
|
462
|
foreach ($toviewComplete as $keyi=>$vali) {
|
463
|
$ORDERQUERY= str_replace($keyi, $vali, $ORDERQUERY);
|
464
|
}
|
465
|
}
|
466
|
}
|
467
|
|
468
|
$query = "SELECT `".getTableForItemType("PluginMonitoringService")."`.*,
|
469
|
`glpi_plugin_monitoring_components`.`name` as component_name,
|
470
|
`glpi_entities`.`completename`
|
471
|
FROM `".getTableForItemType("PluginMonitoringService")."`
|
472
|
".$leftjoin."
|
473
|
".$where."
|
474
|
".$ORDERQUERY;
|
475
|
$result = $DB->query($query);
|
476
|
|
477
|
$start = 0;
|
478
|
if (isset($_GET["start"])) {
|
479
|
$start = $_GET["start"];
|
480
|
}
|
481
|
|
482
|
$numrows = $DB->numrows($result);
|
483
|
$parameters = '';
|
484
|
|
485
|
$globallinkto = Search::getArrayUrlLink("field",$_GET['field']).
|
486
|
Search::getArrayUrlLink("link",$_GET['link']).
|
487
|
Search::getArrayUrlLink("contains",$_GET['contains']).
|
488
|
Search::getArrayUrlLink("searchtype",$_GET['searchtype']).
|
489
|
Search::getArrayUrlLink("field2",$_GET['field2']).
|
490
|
Search::getArrayUrlLink("contains2",$_GET['contains2']).
|
491
|
Search::getArrayUrlLink("itemtype2",$_GET['itemtype2']).
|
492
|
Search::getArrayUrlLink("searchtype2",$_GET['searchtype2']).
|
493
|
Search::getArrayUrlLink("link2",$_GET['link2']);
|
494
|
|
495
|
$parameters = "sort=".$_GET['sort']."&order=".$_GET['order'].$globallinkto;
|
496
|
Html::printPager($_GET['start'], $numrows, $CFG_GLPI['root_doc']."/plugins/monitoring/front/service.php", $parameters);
|
497
|
|
498
|
$limit = $numrows;
|
499
|
if ($_SESSION["glpilist_limit"] < $numrows) {
|
500
|
$limit = $_SESSION["glpilist_limit"];
|
501
|
}
|
502
|
$query .= " LIMIT ".intval($start)."," . intval($_SESSION['glpilist_limit']);
|
503
|
|
504
|
$result = $DB->query($query);
|
505
|
|
506
|
echo '<div id="custom_date" style="display:none"></div>';
|
507
|
echo '<div id="custom_time" style="display:none"></div>';
|
508
|
|
509
|
if ($width == '') {
|
510
|
echo "<table class='tab_cadrehov' style='width:100%;'>";
|
511
|
} else {
|
512
|
echo "<table class='tab_cadrehov' style='width:100%;'>";
|
513
|
}
|
514
|
$num = 0;
|
515
|
|
516
|
echo "<tr class='tab_bg_1'>";
|
517
|
$this->showHeaderItem(__('Status'), 3, $num, $start, $globallinkto);
|
518
|
$this->showHeaderItem(__('Entity'), 6, $num, $start, $globallinkto);
|
519
|
echo Search::showHeaderItem(0, __('Show graphics'), $num);
|
520
|
echo Search::showHeaderItem(0, __('Item type')." - ".__('Name'), $num);
|
521
|
$this->showHeaderItem(__('Components', 'monitoring'), 7, $num, $start,
|
522
|
$globallinkto);
|
523
|
$this->showHeaderItem(__('Status'), 10, $num, $start, $globallinkto);
|
524
|
$this->showHeaderItem(__('Last check', 'monitoring'), 4, $num, $start,
|
525
|
$globallinkto);
|
526
|
$this->showHeaderItem(__('Result details'), 9, $num, $start, $globallinkto);
|
527
|
echo Search::showHeaderItem(0, __('Check period', 'monitoring'), $num);
|
528
|
echo '<th>'.__('Acknowledge', 'monitoring').'</th>';
|
529
|
echo "</tr>";
|
530
|
|
531
|
PluginMonitoringServicegraph::loadLib();
|
532
|
while ($data=$DB->fetch_array($result)) {
|
533
|
echo "<tr class='tab_bg_3'>";
|
534
|
$this->displayLine($data);
|
535
|
echo "</tr>";
|
536
|
}
|
537
|
echo "</table>";
|
538
|
echo "<br/>";
|
539
|
Html::printPager($_GET['start'], $numrows, $CFG_GLPI['root_doc']."/plugins/monitoring/front/service.php", $parameters);
|
540
|
}
|
541
|
|
542
|
|
543
|
|
544
|
|
545
|
|
546
|
|
547
|
function showHeaderItem($title, $numoption, &$num, $start, $globallinkto) {
|
548
|
global $CFG_GLPI;
|
549
|
|
550
|
$linkto = $CFG_GLPI['root_doc']."/plugins/monitoring/front/service.php?".
|
551
|
"itemtype=PluginMonitoringService&sort=".$numoption."&order=".
|
552
|
($_GET['order']=="ASC"?"DESC":"ASC")."&start=".$start.
|
553
|
$globallinkto;
|
554
|
$issort = false;
|
555
|
if ($_GET['sort'] == $numoption) {
|
556
|
$issort = true;
|
557
|
}
|
558
|
echo Search::showHeaderItem(0, $title, $num, $linkto, $issort, $_GET['order']);
|
559
|
}
|
560
|
|
561
|
|
562
|
|
563
|
static function displayLine($data, $displayhost=1) {
|
564
|
global $DB,$CFG_GLPI;
|
565
|
|
566
|
$pMonitoringService = new PluginMonitoringService();
|
567
|
$networkPort = new NetworkPort();
|
568
|
$pMonitoringComponent = new PluginMonitoringComponent();
|
569
|
$pmComponentscatalog_Host = new PluginMonitoringComponentscatalog_Host();
|
570
|
$entity = new Entity();
|
571
|
|
572
|
$pMonitoringService->getFromDB($data['id']);
|
573
|
|
574
|
echo "<td width='32' class='center'>";
|
575
|
$shortstate = self::getState($data['state'],
|
576
|
$data['state_type'],
|
577
|
$data['event'],
|
578
|
$data['is_acknowledged']);
|
579
|
$alt = __('Ok', 'monitoring');
|
580
|
if ($shortstate == 'orange') {
|
581
|
$alt = __('Warning (data)', 'monitoring');
|
582
|
} else if ($shortstate == 'yellow') {
|
583
|
$alt = __('Warning (connection)', 'monitoring');
|
584
|
} else if ($shortstate == 'red') {
|
585
|
$alt = __('Critical', 'monitoring');
|
586
|
} else if ($shortstate == 'redblue') {
|
587
|
$alt = __('Critical / Acknowledge', 'monitoring');
|
588
|
}
|
589
|
echo "<img src='".$CFG_GLPI['root_doc']."/plugins/monitoring/pics/box_".$shortstate."_32.png'
|
590
|
title='".$alt."' alt='".$alt."' />";
|
591
|
echo "</td>";
|
592
|
echo "<td>";
|
593
|
$entity->getFromDB($data['entities_id']);
|
594
|
echo $entity->fields['completename'];
|
595
|
echo "</td>";
|
596
|
|
597
|
|
598
|
$pMonitoringComponent->getFromDB($data['plugin_monitoring_components_id']);
|
599
|
echo "<td class='center'>";
|
600
|
$timezone = '0';
|
601
|
if (isset($_SESSION['plugin_monitoring_timezone'])) {
|
602
|
$timezone = $_SESSION['plugin_monitoring_timezone'];
|
603
|
}
|
604
|
|
605
|
if ($pMonitoringComponent->fields['graph_template'] != '') {
|
606
|
echo "<a href='".$CFG_GLPI['root_doc']."/plugins/monitoring/front/display.form.php?itemtype=PluginMonitoringService&items_id=".$data['id']."'>";
|
607
|
$pmServicegraph = new PluginMonitoringServicegraph();
|
608
|
ob_start();
|
609
|
$pmServicegraph->displayGraph($pMonitoringComponent->fields['graph_template'],
|
610
|
"PluginMonitoringService",
|
611
|
$data['id'],
|
612
|
"0",
|
613
|
'2h',
|
614
|
"div",
|
615
|
"600");
|
616
|
$div = ob_get_contents();
|
617
|
ob_end_clean();
|
618
|
$chart = "<table width='600' class='tab_cadre'><tr><td>".$div."</td></tr></table>";
|
619
|
Html::showToolTip($chart, array('img'=>$CFG_GLPI['root_doc']."/plugins/monitoring/pics/stats_32.png"));
|
620
|
$pmServicegraph->displayGraph($pMonitoringComponent->fields['graph_template'],
|
621
|
"PluginMonitoringService",
|
622
|
$data['id'],
|
623
|
"0",
|
624
|
'2h',
|
625
|
"js");
|
626
|
}
|
627
|
echo "</a>";
|
628
|
echo "</td>";
|
629
|
|
630
|
if ($displayhost == '1') {
|
631
|
$pmComponentscatalog_Host->getFromDB($data["plugin_monitoring_componentscatalogs_hosts_id"]);
|
632
|
if (isset($pmComponentscatalog_Host->fields['itemtype'])
|
633
|
AND $pmComponentscatalog_Host->fields['itemtype'] != '') {
|
634
|
|
635
|
$itemtype = $pmComponentscatalog_Host->fields['itemtype'];
|
636
|
$item = new $itemtype();
|
637
|
$item->getFromDB($pmComponentscatalog_Host->fields['items_id']);
|
638
|
echo "<td>";
|
639
|
echo $item->getTypeName()." : ".$item->getLink();
|
640
|
if (!is_null($pMonitoringService->fields['networkports_id'])
|
641
|
AND $pMonitoringService->fields['networkports_id'] > 0) {
|
642
|
$networkPort->getFromDB($pMonitoringService->fields['networkports_id']);
|
643
|
echo " [".$networkPort->getLink()."]";
|
644
|
}
|
645
|
echo "</td>";
|
646
|
|
647
|
} else {
|
648
|
echo "<td>".__('Resources', 'monitoring')."</td>";
|
649
|
}
|
650
|
}
|
651
|
|
652
|
echo "<td>".$pMonitoringComponent->getLink();
|
653
|
if (!is_null($pMonitoringService->fields['networkports_id'])
|
654
|
AND $pMonitoringService->fields['networkports_id'] > 0) {
|
655
|
$networkPort->getFromDB($pMonitoringService->fields['networkports_id']);
|
656
|
echo " [".$networkPort->getLink()."]";
|
657
|
}
|
658
|
echo "</td>";
|
659
|
|
660
|
|
661
|
|
662
|
|
663
|
|
664
|
|
665
|
|
666
|
|
667
|
|
668
|
|
669
|
|
670
|
|
671
|
|
672
|
|
673
|
echo "<td class='center'>";
|
674
|
|
675
|
|
676
|
echo "<table>";
|
677
|
echo "<tr>";
|
678
|
echo "<td>";
|
679
|
echo $data['state'];
|
680
|
echo "</td>";
|
681
|
echo "<td>";
|
682
|
echo "<a href='".$CFG_GLPI['root_doc']."/plugins/monitoring/front/acknowledge.form.php?id=".$data['id']."'>"
|
683
|
."<img src='".$CFG_GLPI['root_doc']."/plugins/monitoring/pics/acknowledge_checked.png'"
|
684
|
." alt='".__('Define an acknowledge', 'monitoring')."'"
|
685
|
." title='".__('Define an acknowledge', 'monitoring')."'/>"
|
686
|
."</a>";
|
687
|
echo "</td>";
|
688
|
echo "</tr>";
|
689
|
echo "</table>";
|
690
|
|
691
|
|
692
|
|
693
|
echo "</td>";
|
694
|
|
695
|
echo "<td>";
|
696
|
echo Html::convDate($data['last_check']).' '. substr($data['last_check'], 11, 8);
|
697
|
echo "</td>";
|
698
|
|
699
|
echo "<td>";
|
700
|
echo $data['event'];
|
701
|
echo "</td>";
|
702
|
|
703
|
echo "<td align='center'>";
|
704
|
$segments = CalendarSegment::getSegmentsBetween($pMonitoringComponent->fields['calendars_id'],
|
705
|
date('w', date('U')), date('H:i:s'),
|
706
|
date('w', date('U')), date('H:i:s'));
|
707
|
if (count($segments) == '0') {
|
708
|
echo "<img src='".$CFG_GLPI['root_doc']."/plugins/monitoring/pics/service_pause.png' />";
|
709
|
} else {
|
710
|
echo "<img src='".$CFG_GLPI['root_doc']."/plugins/monitoring/pics/service_run.png' />";
|
711
|
}
|
712
|
echo "</td>";
|
713
|
|
714
|
if ($displayhost == '0') {
|
715
|
$pmUnavaibility = new PluginMonitoringUnavaibility();
|
716
|
$pmUnavaibility->displayValues($pMonitoringService->fields['id'], 'currentmonth', 1);
|
717
|
$pmUnavaibility->displayValues($pMonitoringService->fields['id'], 'lastmonth', 1);
|
718
|
$pmUnavaibility->displayValues($pMonitoringService->fields['id'], 'currentyear', 1);
|
719
|
|
720
|
echo "<td class='center'>";
|
721
|
echo "<a href='".$CFG_GLPI['root_doc']."/plugins/monitoring/front/unavaibility.php?".
|
722
|
"field[0]=2&searchtype[0]=equals&contains[0]=".$pMonitoringService->fields['id'].
|
723
|
"&sort=3&order=DESC&itemtype=PluginMonitoringUnavaibility'>
|
724
|
<img src='".$CFG_GLPI['root_doc']."/plugins/monitoring/pics/info.png'/></a>";
|
725
|
echo "</td>";
|
726
|
}
|
727
|
|
728
|
echo "<td>";
|
729
|
if ($shortstate == 'redblue') {
|
730
|
echo "<i>"._n('User', 'Users', 1)." : </i>";
|
731
|
$user = new User();
|
732
|
$user->getFromDB($data['acknowledge_users_id']);
|
733
|
echo $user->getName(1);
|
734
|
echo "<br/>";
|
735
|
echo"<i>". __('Comments')." : </i>".$data['acknowledge_comment'];
|
736
|
}
|
737
|
echo "</td>";
|
738
|
|
739
|
if ($displayhost == '0') {
|
740
|
echo "<td>";
|
741
|
if (PluginMonitoringProfile::haveRight("componentscatalog", 'w')) {
|
742
|
|
743
|
$a_arg = importArrayFromDB($pMonitoringService->fields['arguments']);
|
744
|
$cnt = '';
|
745
|
if (count($a_arg) > 0) {
|
746
|
$cnt = " (".count($a_arg).")";
|
747
|
}
|
748
|
echo "<a href='".$CFG_GLPI['root_doc']."/plugins/monitoring/front/servicearg.form.php?id=".$data['id']."'>".
|
749
|
__('Configure', 'monitoring').$cnt."</a>";
|
750
|
}
|
751
|
echo "</td>";
|
752
|
}
|
753
|
}
|
754
|
|
755
|
|
756
|
|
757
|
static function getState($state, $state_type, $event, $acknowledge=0) {
|
758
|
$shortstate = '';
|
759
|
switch($state) {
|
760
|
|
761
|
case 'UP':
|
762
|
case 'OK':
|
763
|
$shortstate = 'green';
|
764
|
break;
|
765
|
|
766
|
case 'DOWN':
|
767
|
case 'UNREACHABLE':
|
768
|
case 'CRITICAL':
|
769
|
case 'DOWNTIME':
|
770
|
if ($acknowledge) {
|
771
|
$shortstate = 'redblue';
|
772
|
} else {
|
773
|
$shortstate = 'red';
|
774
|
}
|
775
|
break;
|
776
|
|
777
|
case 'WARNING':
|
778
|
case 'RECOVERY':
|
779
|
case 'FLAPPING':
|
780
|
if ($acknowledge) {
|
781
|
$shortstate = 'redblue';
|
782
|
} else {
|
783
|
$shortstate = 'orange';
|
784
|
}
|
785
|
break;
|
786
|
|
787
|
case 'UNKNOWN':
|
788
|
case '':
|
789
|
if ($acknowledge) {
|
790
|
$shortstate = 'redblue';
|
791
|
} else {
|
792
|
$shortstate = 'yellow';
|
793
|
}
|
794
|
break;
|
795
|
|
796
|
}
|
797
|
if ($state == 'WARNING' && $event == '') {
|
798
|
if ($acknowledge) {
|
799
|
$shortstate = 'redblue';
|
800
|
} else {
|
801
|
$shortstate = 'yellow';
|
802
|
}
|
803
|
|
804
|
}
|
805
|
if ($state_type == 'SOFT') {
|
806
|
$shortstate.= '_soft';
|
807
|
}
|
808
|
return $shortstate;
|
809
|
}
|
810
|
|
811
|
|
812
|
|
813
|
function displayGraphs($itemtype, $items_id) {
|
814
|
global $CFG_GLPI;
|
815
|
|
816
|
$pmComponent = new PluginMonitoringComponent();
|
817
|
$pmConfig = new PluginMonitoringConfig();
|
818
|
$pmComponentscatalog_Host = new PluginMonitoringComponentscatalog_Host();
|
819
|
|
820
|
$item = new $itemtype();
|
821
|
$item->getFromDB($items_id);
|
822
|
$pmComponent->getFromDB($item->fields['plugin_monitoring_components_id']);
|
823
|
if(!isset($_SESSION['glpi_plugin_monitoring']['perfname'][$pmComponent->fields['id']])) {
|
824
|
PluginMonitoringServicegraph::loadPreferences($pmComponent->fields['id']);
|
825
|
}
|
826
|
$css_width = '950';
|
827
|
if (isset($_GET['mobile'])) {
|
828
|
$css_width = '300';
|
829
|
}
|
830
|
|
831
|
|
832
|
echo "<table class='tab_cadre' width='".$css_width."'>";
|
833
|
|
834
|
echo "<tr class='tab_bg_1'>";
|
835
|
echo "<th>";
|
836
|
$title = Dropdown::getDropdownName(getTableForItemType('PluginMonitoringComponent'), $item->fields['plugin_monitoring_components_id']);
|
837
|
$title .= ' '.__('on', 'monitoring').' ';
|
838
|
$pmComponentscatalog_Host->getFromDB($item->fields["plugin_monitoring_componentscatalogs_hosts_id"]);
|
839
|
if (isset($pmComponentscatalog_Host->fields['itemtype'])
|
840
|
AND $pmComponentscatalog_Host->fields['itemtype'] != '') {
|
841
|
|
842
|
$itemtype2 = $pmComponentscatalog_Host->fields['itemtype'];
|
843
|
$item2 = new $itemtype2();
|
844
|
$item2->getFromDB($pmComponentscatalog_Host->fields['items_id']);
|
845
|
$title .= str_replace("'", "\"", $item2->getLink()." (".$item2->getTypeName().")");
|
846
|
}
|
847
|
echo $title;
|
848
|
echo "</th>";
|
849
|
echo "<th width='200'>";
|
850
|
if (!isset($_GET['mobile'])) {
|
851
|
echo "<form method='post'>";
|
852
|
$a_timezones = PluginMonitoringConfig::getTimezones();
|
853
|
if (!isset($_SESSION['plugin_monitoring_timezone'])) {
|
854
|
$_SESSION['plugin_monitoring_timezone'] = '0';
|
855
|
}
|
856
|
$a_timezones_allowed = array();
|
857
|
$pmConfig->getFromDB(1);
|
858
|
$a_temp = importArrayFromDB($pmConfig->fields['timezones']);
|
859
|
foreach ($a_temp as $key) {
|
860
|
$a_timezones_allowed[$key] = $a_timezones[$key];
|
861
|
}
|
862
|
if (count($a_timezones_allowed) == '0') {
|
863
|
$a_timezones_allowed['0'] = $a_timezones['0'];
|
864
|
}
|
865
|
|
866
|
Dropdown::showFromArray('plugin_monitoring_timezone',
|
867
|
$a_timezones_allowed,
|
868
|
array('value'=>$_SESSION['plugin_monitoring_timezone']));
|
869
|
echo " <input type='submit' name='update' value=\"".__('Save')."\" class='submit'>";
|
870
|
Html::closeForm();
|
871
|
}
|
872
|
echo "</th>";
|
873
|
echo "</tr>";
|
874
|
|
875
|
$timezone = '0';
|
876
|
if (isset($_SESSION['plugin_monitoring_timezone'])) {
|
877
|
$timezone = $_SESSION['plugin_monitoring_timezone'];
|
878
|
}
|
879
|
|
880
|
if (!isset($_GET['mobile'])) {
|
881
|
echo "<tr class='tab_bg_1'>";
|
882
|
echo "<th colspan='2'>";
|
883
|
echo "<div id='legendlink'><a onClick='Ext.get(\"options\").toggle();'>[ Options ]</a></div>";
|
884
|
echo "</th>";
|
885
|
echo "</tr>";
|
886
|
|
887
|
|
888
|
echo "<tr class='tab_bg_1'>";
|
889
|
echo "<td colspan='2'>";
|
890
|
echo "<div id='options' style='display:none'>";
|
891
|
PluginMonitoringServicegraph::preferences($pmComponent->fields['id'], 0);
|
892
|
echo "</div>";
|
893
|
echo "</td>";
|
894
|
echo "</tr>";
|
895
|
|
896
|
|
897
|
echo "<tr class='tab_bg_1'>";
|
898
|
echo "<th colspan='2'>";
|
899
|
echo __('Select date (only last 2, 12 and 24 hours)', 'monitoring');
|
900
|
echo "</th>";
|
901
|
echo "</tr>";
|
902
|
|
903
|
echo "<tr class='tab_bg_1'>";
|
904
|
echo "<td colspan='2'>";
|
905
|
|
906
|
$end = time();
|
907
|
|
908
|
$oldvalue = current(getAllDatasFromTable('glpi_plugin_monitoring_serviceevents',
|
909
|
"`plugin_monitoring_services_id`='".$items_id."'",
|
910
|
false,
|
911
|
'date ASC LIMIT 1'));
|
912
|
$date = new DateTime($oldvalue['date']);
|
913
|
$start = $date->getTimestamp();
|
914
|
$pmServicegraph = new PluginMonitoringServicegraph();
|
915
|
echo "
|
916
|
<script type=\"text/javascript\">
|
917
|
|
918
|
Ext.onReady(function(){
|
919
|
|
920
|
var tip = new Ext.slider.Tip({
|
921
|
getText: function(thumb){
|
922
|
return String.format('<b> ' + new Date(thumb.value * 1000).format('Y-m-d') + '</b>');
|
923
|
}
|
924
|
});
|
925
|
|
926
|
new Ext.Slider({
|
927
|
renderTo: 'custom-tip-slider',
|
928
|
width: 940,
|
929
|
increment: 86400,
|
930
|
minValue: ".$start.",
|
931
|
maxValue: ".$end.",
|
932
|
value: ".$end.",
|
933
|
plugins: tip,
|
934
|
listeners: {
|
935
|
dragend: function(slider, thumb, value){
|
936
|
document.getElementById('custom_date').textContent = slider.getValue();
|
937
|
mgr".$items_id."2h.stopAutoRefresh();
|
938
|
mgr".$items_id."12h.stopAutoRefresh();
|
939
|
mgr".$items_id."1d.stopAutoRefresh();
|
940
|
";
|
941
|
$a_graphlist = array('2h', '12h', '1d');
|
942
|
foreach ($a_graphlist as $time) {
|
943
|
$pmServicegraph->startAutoRefresh($pmComponent->fields['graph_template'],
|
944
|
$itemtype,
|
945
|
$items_id,
|
946
|
$timezone,
|
947
|
$time,
|
948
|
$pmComponent->fields['id']);
|
949
|
}
|
950
|
echo "
|
951
|
}
|
952
|
}
|
953
|
});
|
954
|
|
955
|
});
|
956
|
</script>";
|
957
|
echo '<center><div id="custom-tip-slider"></div></center>';
|
958
|
echo '<div id="custom_date" style="display:none"></div>';
|
959
|
echo "</td>";
|
960
|
echo "</tr>";
|
961
|
|
962
|
|
963
|
echo "<tr class='tab_bg_1'>";
|
964
|
echo "<th colspan='2'>";
|
965
|
echo __('Select time (only last 2, 12 and 24 hours)', 'monitoring');
|
966
|
echo "</th>";
|
967
|
echo "</tr>";
|
968
|
|
969
|
echo "<tr class='tab_bg_1'>";
|
970
|
echo "<td colspan='2'>";
|
971
|
|
972
|
$start = 0 + 86400 - 3600;
|
973
|
$end = 86400 + 86400 - 3600 - 300;
|
974
|
$current = mktime(date('H'), date('i'), 0, 1, 2, 1970);
|
975
|
|
976
|
echo "
|
977
|
<script type=\"text/javascript\">
|
978
|
|
979
|
Ext.onReady(function(){
|
980
|
|
981
|
var tiptime = new Ext.slider.Tip({
|
982
|
getText: function(thumb){
|
983
|
return String.format('<b> ' + new Date(thumb.value * 1000).format('H:i:s') + '</b>');
|
984
|
}
|
985
|
});
|
986
|
|
987
|
new Ext.Slider({
|
988
|
renderTo: 'custom-tip-slider-time',
|
989
|
width: 940,
|
990
|
increment: 300,
|
991
|
minValue: ".$start.",
|
992
|
maxValue: ".$end.",
|
993
|
value: ".$current.",
|
994
|
plugins: tiptime,
|
995
|
listeners: {
|
996
|
dragend: function(slider, thumb, value){
|
997
|
document.getElementById('custom_time').textContent = slider.getValue();
|
998
|
mgr".$items_id."2h.stopAutoRefresh();
|
999
|
mgr".$items_id."12h.stopAutoRefresh();
|
1000
|
mgr".$items_id."1d.stopAutoRefresh();
|
1001
|
";
|
1002
|
$a_graphlist = array('2h', '12h', '1d');
|
1003
|
foreach ($a_graphlist as $time) {
|
1004
|
$pmServicegraph->startAutoRefresh($pmComponent->fields['graph_template'],
|
1005
|
$itemtype,
|
1006
|
$items_id,
|
1007
|
$timezone,
|
1008
|
$time,
|
1009
|
$pmComponent->fields['id']);
|
1010
|
}
|
1011
|
echo "
|
1012
|
}
|
1013
|
}
|
1014
|
});
|
1015
|
});
|
1016
|
</script>";
|
1017
|
echo '<center><div id="custom-tip-slider-time"></div></center>';
|
1018
|
echo '<div id="custom_time" style="display:none"></div>';
|
1019
|
echo "</td>";
|
1020
|
echo "</tr>";
|
1021
|
}
|
1022
|
|
1023
|
$a_list = array();
|
1024
|
$a_list["2h"] = __("Last 2 hours", "monitoring");
|
1025
|
$a_list["12h"] = __("Last 12 hours", "monitoring");
|
1026
|
$a_list["1d"] = __("Last 24 hours", "monitoring");
|
1027
|
if (!isset($_GET['mobile'])) {
|
1028
|
$a_list["1w"] = __("Last 7 days (average)", "monitoring");
|
1029
|
$a_list["1m"] = __("Last month (average)", "monitoring");
|
1030
|
$a_list["0y6m"] = __("Last 6 months (average)", "monitoring");
|
1031
|
$a_list["1y"] = __("Last year (average)", "monitoring");
|
1032
|
}
|
1033
|
|
1034
|
foreach ($a_list as $time=>$name) {
|
1035
|
|
1036
|
echo "<tr class='tab_bg_1'>";
|
1037
|
echo "<th colspan='2'>";
|
1038
|
echo $name;
|
1039
|
echo "</th>";
|
1040
|
echo "</tr>";
|
1041
|
|
1042
|
echo "<tr class='tab_bg_1'>";
|
1043
|
echo "<td align='center' colspan='2'>";
|
1044
|
|
1045
|
$pmServicegraph = new PluginMonitoringServicegraph();
|
1046
|
$part = '';
|
1047
|
$width='950';
|
1048
|
if (isset($_GET['mobile'])) {
|
1049
|
$width='294';
|
1050
|
}
|
1051
|
$pmServicegraph->displayGraph($pmComponent->fields['graph_template'],
|
1052
|
$itemtype,
|
1053
|
$items_id,
|
1054
|
$timezone,
|
1055
|
$time,
|
1056
|
$part,
|
1057
|
$width);
|
1058
|
|
1059
|
echo "</td>";
|
1060
|
echo "</tr>";
|
1061
|
}
|
1062
|
echo "</table>";
|
1063
|
}
|
1064
|
|
1065
|
|
1066
|
|
1067
|
function displayCounters($type, $display=1) {
|
1068
|
global $DB,$CFG_GLPI;
|
1069
|
|
1070
|
$ok = 0;
|
1071
|
$warningdata = 0;
|
1072
|
$warningconnection = 0;
|
1073
|
$critical = 0;
|
1074
|
$ok_soft = 0;
|
1075
|
$warningdata_soft = 0;
|
1076
|
$warningconnection_soft = 0;
|
1077
|
$critical_soft = 0;
|
1078
|
$acknowledge = 0;
|
1079
|
|
1080
|
$play_sound = 0;
|
1081
|
|
1082
|
if ($type == 'Ressources') {
|
1083
|
|
1084
|
$ok = countElementsInTable("glpi_plugin_monitoring_services",
|
1085
|
"(`state`='OK' OR `state`='UP') AND `state_type`='HARD'
|
1086
|
AND `entities_id` IN (".$_SESSION['glpiactiveentities_string'].")
|
1087
|
AND `is_acknowledged`='0'");
|
1088
|
|
1089
|
$warningdata = countElementsInTable("glpi_plugin_monitoring_services",
|
1090
|
"((`state`='WARNING' AND `event` IS NOT NULL)
|
1091
|
OR `state`='RECOVERY' OR `state`='FLAPPING')
|
1092
|
AND `event` IS NOT NULL
|
1093
|
AND `state_type`='HARD'
|
1094
|
AND `entities_id` IN (".$_SESSION['glpiactiveentities_string'].")
|
1095
|
AND `is_acknowledged`='0'");
|
1096
|
|
1097
|
$warningconnection = countElementsInTable("glpi_plugin_monitoring_services",
|
1098
|
"(`state`='UNKNOWN' OR `state` IS NULL
|
1099
|
OR (`state`='WARNING' AND `event` IS NULL))
|
1100
|
AND `state_type`='HARD'
|
1101
|
AND `entities_id` IN (".$_SESSION['glpiactiveentities_string'].")
|
1102
|
AND `is_acknowledged`='0'");
|
1103
|
|
1104
|
$critical = countElementsInTable("glpi_plugin_monitoring_services",
|
1105
|
"(`state`='DOWN' OR `state`='UNREACHABLE' OR `state`='CRITICAL' OR `state`='DOWNTIME')
|
1106
|
AND `state_type`='HARD'
|
1107
|
AND `entities_id` IN (".$_SESSION['glpiactiveentities_string'].")
|
1108
|
AND `is_acknowledged`='0'");
|
1109
|
|
1110
|
$warningdata_soft = countElementsInTable("glpi_plugin_monitoring_services",
|
1111
|
"((`state`='WARNING' AND `event` IS NOT NULL)
|
1112
|
OR `state`='RECOVERY' OR `state`='FLAPPING')
|
1113
|
AND `state_type`='SOFT'
|
1114
|
AND `entities_id` IN (".$_SESSION['glpiactiveentities_string'].")
|
1115
|
AND `is_acknowledged`='0'");
|
1116
|
|
1117
|
$warningconnection_soft = countElementsInTable("glpi_plugin_monitoring_services",
|
1118
|
"(`state`='UNKNOWN' OR `state` IS NULL
|
1119
|
OR (`state`='WARNING' AND `event` IS NULL))
|
1120
|
AND `state_type`='SOFT'
|
1121
|
AND `entities_id` IN (".$_SESSION['glpiactiveentities_string'].")
|
1122
|
AND `is_acknowledged`='0'");
|
1123
|
|
1124
|
$critical_soft = countElementsInTable("glpi_plugin_monitoring_services",
|
1125
|
"(`state`='DOWN' OR `state`='UNREACHABLE' OR `state`='CRITICAL' OR `state`='DOWNTIME')
|
1126
|
AND `state_type`='SOFT'
|
1127
|
AND `entities_id` IN (".$_SESSION['glpiactiveentities_string'].")
|
1128
|
AND `is_acknowledged`='0'");
|
1129
|
|
1130
|
$ok_soft = countElementsInTable("glpi_plugin_monitoring_services",
|
1131
|
"(`state`='OK' OR `state`='UP') AND `state_type`='SOFT'
|
1132
|
AND `entities_id` IN (".$_SESSION['glpiactiveentities_string'].")
|
1133
|
AND `is_acknowledged`='0'");
|
1134
|
|
1135
|
$acknowledge = countElementsInTable("glpi_plugin_monitoring_services",
|
1136
|
"(`state_type`='HARD' OR `state_type`='WARNING'
|
1137
|
OR `state_type`='UNKNOWN')
|
1138
|
AND `entities_id` IN (".$_SESSION['glpiactiveentities_string'].")
|
1139
|
AND `is_acknowledged`='1'");
|
1140
|
|
1141
|
|
1142
|
if (isset($_SESSION['plugin_monitoring_dashboard_Ressources'])) {
|
1143
|
if ($critical > $_SESSION['plugin_monitoring_dashboard_Ressources']) {
|
1144
|
$play_sound = 1;
|
1145
|
}
|
1146
|
}
|
1147
|
$_SESSION['plugin_monitoring_dashboard_Ressources'] = $critical;
|
1148
|
|
1149
|
} else if ($type == 'Componentscatalog') {
|
1150
|
$pmComponentscatalog_Host = new PluginMonitoringComponentscatalog_Host();
|
1151
|
$queryCat = "SELECT * FROM `glpi_plugin_monitoring_componentscatalogs`";
|
1152
|
$resultCat = $DB->query($queryCat);
|
1153
|
while ($data=$DB->fetch_array($resultCat)) {
|
1154
|
|
1155
|
$query = "SELECT COUNT(*) AS cpt FROM `".$pmComponentscatalog_Host->getTable()."`
|
1156
|
LEFT JOIN `glpi_plugin_monitoring_services`
|
1157
|
ON `plugin_monitoring_componentscatalogs_hosts_id`=`".$pmComponentscatalog_Host->getTable()."`.`id`
|
1158
|
WHERE `plugin_monitoring_componentscalalog_id`='".$data['id']."'
|
1159
|
AND (`state`='DOWN' OR `state`='UNREACHABLE' OR `state`='CRITICAL' OR `state`='DOWNTIME')
|
1160
|
AND `state_type`='HARD'
|
1161
|
AND `entities_id` IN (".$_SESSION['glpiactiveentities_string'].")
|
1162
|
AND `is_acknowledged`='0'";
|
1163
|
$result = $DB->query($query);
|
1164
|
$data2 = $DB->fetch_assoc($result);
|
1165
|
if ($data2['cpt'] > 0) {
|
1166
|
$critical++;
|
1167
|
} else {
|
1168
|
$query = "SELECT COUNT(*) AS cpt, `glpi_plugin_monitoring_services`.`state`
|
1169
|
FROM `".$pmComponentscatalog_Host->getTable()."`
|
1170
|
LEFT JOIN `glpi_plugin_monitoring_services`
|
1171
|
ON `plugin_monitoring_componentscatalogs_hosts_id`=`".$pmComponentscatalog_Host->getTable()."`.`id`
|
1172
|
WHERE `plugin_monitoring_componentscalalog_id`='".$data['id']."'
|
1173
|
AND (`state`='WARNING' OR `state`='UNKNOWN' OR `state`='RECOVERY' OR `state`='FLAPPING' OR `state` IS NULL)
|
1174
|
AND `state_type`='HARD'
|
1175
|
AND `entities_id` IN (".$_SESSION['glpiactiveentities_string'].")
|
1176
|
AND `is_acknowledged`='0'";
|
1177
|
$result = $DB->query($query);
|
1178
|
$data2 = $DB->fetch_assoc($result);
|
1179
|
if ($data2['cpt'] > 0) {
|
1180
|
$warningdata++;
|
1181
|
} else {
|
1182
|
$query = "SELECT COUNT(*) AS cpt FROM `".$pmComponentscatalog_Host->getTable()."`
|
1183
|
LEFT JOIN `glpi_plugin_monitoring_services`
|
1184
|
ON `plugin_monitoring_componentscatalogs_hosts_id`=`".$pmComponentscatalog_Host->getTable()."`.`id`
|
1185
|
WHERE `plugin_monitoring_componentscalalog_id`='".$data['id']."'
|
1186
|
AND (`state`='OK' OR `state`='UP') AND `state_type`='HARD'
|
1187
|
AND `entities_id` IN (".$_SESSION['glpiactiveentities_string'].")
|
1188
|
AND `is_acknowledged`='0'";
|
1189
|
$result = $DB->query($query);
|
1190
|
$data2 = $DB->fetch_assoc($result);
|
1191
|
if ($data2['cpt'] > 0) {
|
1192
|
$ok++;
|
1193
|
}
|
1194
|
}
|
1195
|
}
|
1196
|
|
1197
|
$query = "SELECT COUNT(*) AS cpt FROM `".$pmComponentscatalog_Host->getTable()."`
|
1198
|
LEFT JOIN `glpi_plugin_monitoring_services`
|
1199
|
ON `plugin_monitoring_componentscatalogs_hosts_id`=`".$pmComponentscatalog_Host->getTable()."`.`id`
|
1200
|
WHERE `plugin_monitoring_componentscalalog_id`='".$data['id']."'
|
1201
|
AND (`state`='DOWN' OR `state`='UNREACHABLE' OR `state`='CRITICAL' OR `state`='DOWNTIME')
|
1202
|
AND `state_type`='SOFT'
|
1203
|
AND `entities_id` IN (".$_SESSION['glpiactiveentities_string'].")
|
1204
|
AND `is_acknowledged`='0'";
|
1205
|
$result = $DB->query($query);
|
1206
|
$data2 = $DB->fetch_assoc($result);
|
1207
|
if ($data2['cpt'] > 0) {
|
1208
|
$critical_soft++;
|
1209
|
} else {
|
1210
|
$query = "SELECT COUNT(*) AS cpt FROM `".$pmComponentscatalog_Host->getTable()."`
|
1211
|
LEFT JOIN `glpi_plugin_monitoring_services`
|
1212
|
ON `plugin_monitoring_componentscatalogs_hosts_id`=`".$pmComponentscatalog_Host->getTable()."`.`id`
|
1213
|
WHERE `plugin_monitoring_componentscalalog_id`='".$data['id']."'
|
1214
|
AND (`state`='WARNING' OR `state`='UNKNOWN' OR `state`='RECOVERY' OR `state`='FLAPPING' OR `state` IS NULL)
|
1215
|
AND `state_type`='SOFT'
|
1216
|
AND `entities_id` IN (".$_SESSION['glpiactiveentities_string'].")
|
1217
|
AND `is_acknowledged`='0'";
|
1218
|
$result = $DB->query($query);
|
1219
|
$data2 = $DB->fetch_assoc($result);
|
1220
|
if ($data2['cpt'] > 0) {
|
1221
|
$warningdata_soft++;
|
1222
|
} else {
|
1223
|
$query = "SELECT COUNT(*) AS cpt FROM `".$pmComponentscatalog_Host->getTable()."`
|
1224
|
LEFT JOIN `glpi_plugin_monitoring_services`
|
1225
|
ON `plugin_monitoring_componentscatalogs_hosts_id`=`".$pmComponentscatalog_Host->getTable()."`.`id`
|
1226
|
WHERE `plugin_monitoring_componentscalalog_id`='".$data['id']."'
|
1227
|
AND (`state`='OK' OR `state`='UP') AND `state_type`='SOFT'
|
1228
|
AND `entities_id` IN (".$_SESSION['glpiactiveentities_string'].")
|
1229
|
AND `is_acknowledged`='0'";
|
1230
|
$result = $DB->query($query);
|
1231
|
$data2 = $DB->fetch_assoc($result);
|
1232
|
if ($data2['cpt'] > 0) {
|
1233
|
$ok_soft++;
|
1234
|
}
|
1235
|
}
|
1236
|
}
|
1237
|
}
|
1238
|
|
1239
|
|
1240
|
if (isset($_SESSION['plugin_monitoring_dashboard_Componentscatalog'])) {
|
1241
|
if ($critical > $_SESSION['plugin_monitoring_dashboard_Componentscatalog']) {
|
1242
|
$play_sound = 1;
|
1243
|
}
|
1244
|
}
|
1245
|
$_SESSION['plugin_monitoring_dashboard_Componentscatalog'] = $critical;
|
1246
|
|
1247
|
} else if ($type == 'Businessrules') {
|
1248
|
$ok = countElementsInTable("glpi_plugin_monitoring_servicescatalogs",
|
1249
|
"(`state`='OK' OR `state`='UP') AND `state_type`='HARD'
|
1250
|
AND `entities_id` IN (".$_SESSION['glpiactiveentities_string'].")
|
1251
|
AND `is_acknowledged`='0'");
|
1252
|
|
1253
|
$warningdata = countElementsInTable("glpi_plugin_monitoring_servicescatalogs",
|
1254
|
"(`state`='WARNING' OR `state`='UNKNOWN'
|
1255
|
OR `state`='RECOVERY' OR `state`='FLAPPING')
|
1256
|
AND `state_type`='HARD'
|
1257
|
AND `entities_id` IN (".$_SESSION['glpiactiveentities_string'].")
|
1258
|
AND `is_acknowledged`='0'");
|
1259
|
|
1260
|
$critical = countElementsInTable("glpi_plugin_monitoring_servicescatalogs",
|
1261
|
"(`state`='DOWN' OR `state`='UNREACHABLE' OR `state`='CRITICAL' OR `state`='DOWNTIME')
|
1262
|
AND `state_type`='HARD'
|
1263
|
AND `entities_id` IN (".$_SESSION['glpiactiveentities_string'].")
|
1264
|
AND `is_acknowledged`='0'");
|
1265
|
|
1266
|
$warningdata_soft = countElementsInTable("glpi_plugin_monitoring_servicescatalogs",
|
1267
|
"(`state`='WARNING' OR `state`='UNKNOWN'
|
1268
|
OR `state`='RECOVERY' OR `state`='FLAPPING')
|
1269
|
AND `state_type`='SOFT'
|
1270
|
AND `entities_id` IN (".$_SESSION['glpiactiveentities_string'].")
|
1271
|
AND `is_acknowledged`='0'");
|
1272
|
|
1273
|
$critical_soft = countElementsInTable("glpi_plugin_monitoring_servicescatalogs",
|
1274
|
"(`state`='DOWN' OR `state`='UNREACHABLE' OR `state`='CRITICAL' OR `state`='DOWNTIME')
|
1275
|
AND `state_type`='SOFT'
|
1276
|
AND `entities_id` IN (".$_SESSION['glpiactiveentities_string'].")
|
1277
|
AND `is_acknowledged`='0'");
|
1278
|
|
1279
|
$ok_soft = countElementsInTable("glpi_plugin_monitoring_servicescatalogs",
|
1280
|
"(`state`='OK' OR `state`='UP') AND `state_type`='SOFT'
|
1281
|
AND `entities_id` IN (".$_SESSION['glpiactiveentities_string'].")
|
1282
|
AND `is_acknowledged`='0'");
|
1283
|
|
1284
|
|
1285
|
if (isset($_SESSION['plugin_monitoring_dashboard_Businessrules'])) {
|
1286
|
if ($critical > $_SESSION['plugin_monitoring_dashboard_Businessrules']) {
|
1287
|
$play_sound = 1;
|
1288
|
}
|
1289
|
}
|
1290
|
$_SESSION['plugin_monitoring_dashboard_Businessrules'] = $critical;
|
1291
|
|
1292
|
}
|
1293
|
if ($display == '0') {
|
1294
|
$a_return = array();
|
1295
|
$a_return['ok'] = strval($ok);
|
1296
|
$a_return['ok_soft'] = strval($ok_soft);
|
1297
|
$a_return['warningdata'] = strval($warningdata);
|
1298
|
$a_return['warningconnection'] = strval($warningconnection);
|
1299
|
$a_return['warningdata_soft'] = strval($warningdata_soft);
|
1300
|
$a_return['warningconnection_soft'] = strval($warningconnection_soft);
|
1301
|
$a_return['critical'] = strval($critical);
|
1302
|
$a_return['critical_soft'] = strval($critical_soft);
|
1303
|
$a_return['acknowledge'] = strval($acknowledge);
|
1304
|
return $a_return;
|
1305
|
}
|
1306
|
|
1307
|
$critical_link = $CFG_GLPI['root_doc'].
|
1308
|
"/plugins/monitoring/front/service.php?hidesearch=1&reset=reset".
|
1309
|
"&field[0]=3&searchtype[0]=contains&contains[0]=CRITICAL&link[1]=AND".
|
1310
|
"&field[1]=23&searchtype[1]=equals&contains[1]=0&link[2]=OR".
|
1311
|
"&field[2]=3&searchtype[2]=contains&contains[2]=DOWN&link[3]=AND".
|
1312
|
"&field[3]=23&searchtype[3]=equals&contains[3]=0&link[4]=OR".
|
1313
|
"&field[4]=3&searchtype[4]=contains&contains[4]=UNREACHABLE&link[5]=AND".
|
1314
|
"&field[5]=23&searchtype[5]=equals&contains[5]=0".
|
1315
|
"&itemtype=PluginMonitoringService&start=0&glpi_tab=3'";
|
1316
|
$warning_link = $CFG_GLPI['root_doc'].
|
1317
|
"/plugins/monitoring/front/service.php?hidesearch=1&reset=reset".
|
1318
|
"&field[0]=3&searchtype[0]=contains&contains[0]=FLAPPING&link[1]=AND".
|
1319
|
"&field[1]=23&searchtype[1]=equals&contains[1]=0&link[2]=OR".
|
1320
|
"&field[2]=3&searchtype[2]=contains&contains[2]=RECOVERY&link[3]=AND".
|
1321
|
"&field[3]=23&searchtype[3]=equals&contains[3]=0&link[4]=OR".
|
1322
|
"&field[4]=3&searchtype[4]=contains&contains[4]=WARNING&link[5]=AND".
|
1323
|
"&field[5]=23&searchtype[5]=equals&contains[5]=0".
|
1324
|
"&itemtype=PluginMonitoringService&start=0&glpi_tab=3'";
|
1325
|
$warningdata_link = $CFG_GLPI['root_doc'].
|
1326
|
"/plugins/monitoring/front/service.php?hidesearch=1&reset=reset".
|
1327
|
"&field[0]=3&searchtype[0]=contains&contains[0]=FLAPPING&link[1]=AND".
|
1328
|
"&field[1]=23&searchtype[1]=equals&contains[1]=0&link[2]=OR".
|
1329
|
"&field[2]=3&searchtype[2]=contains&contains[2]=RECOVERY&link[3]=AND".
|
1330
|
"&field[3]=23&searchtype[3]=equals&contains[3]=0&link[4]=OR".
|
1331
|
"&field[4]=3&searchtype[4]=contains&contains[4]=WARNING&link[5]=AND".
|
1332
|
"&field[5]=23&searchtype[5]=equals&contains[5]=0&link[6]=AND".
|
1333
|
"&field[6]=9&searchtype[6]=contains&contains[6]=^".
|
1334
|
"&itemtype=PluginMonitoringService&start=0&glpi_tab=3'";
|
1335
|
$warningconnection_link = $CFG_GLPI['root_doc'].
|
1336
|
"/plugins/monitoring/front/service.php?hidesearch=1&reset=reset".
|
1337
|
"&field[0]=3&searchtype[0]=contains&contains[0]=UNKNOWN&link[1]=AND".
|
1338
|
"&field[1]=23&searchtype[1]=equals&contains[1]=0&link[2]=OR".
|
1339
|
"&field[2]=3&searchtype[2]=contains&contains[2]=NULL&link[3]=AND".
|
1340
|
"&field[3]=23&searchtype[3]=equals&contains[3]=0&&link[4]=AND".
|
1341
|
"&field[4]=9&searchtype[4]=contains&contains[4]=^$".
|
1342
|
"&itemtype=PluginMonitoringService&start=0&glpi_tab=3'";
|
1343
|
$ok_link = $CFG_GLPI['root_doc'].
|
1344
|
"/plugins/monitoring/front/service.php?hidesearch=1&reset=reset&".
|
1345
|
"field[0]=3&searchtype[0]=contains&contains[0]=OK&link[1]=OR".
|
1346
|
"&field[1]=3&searchtype[1]=contains&contains[1]=UP".
|
1347
|
"&itemtype=PluginMonitoringService&start=0&glpi_tab=3'";
|
1348
|
$acknowledge_link = $CFG_GLPI['root_doc'].
|
1349
|
"/plugins/monitoring/front/service.php?hidesearch=1&reset=reset&".
|
1350
|
"field[0]=23&searchtype[0]=equals&contains[0]=1".
|
1351
|
"&itemtype=PluginMonitoringService&start=0&glpi_tab=3'";
|
1352
|
|
1353
|
echo "<table align='center'>";
|
1354
|
echo "<tr>";
|
1355
|
echo "<td>";
|
1356
|
$background = '';
|
1357
|
if ($critical > 0) {
|
1358
|
$background = 'background="'.$CFG_GLPI['root_doc'].'/plugins/monitoring/pics/bg_critical.png"';
|
1359
|
}
|
1360
|
echo "<table class='tab_cadre' width='414' height='130' ".$background." >";
|
1361
|
echo "<tr>";
|
1362
|
echo "<th style='background-color:transparent;'>";
|
1363
|
if ($type == 'Ressources' OR $type == 'Componentscatalog') {
|
1364
|
echo "<a href='".$critical_link.">".
|
1365
|
"<font color='black' style='font-size: 12px;font-weight: bold;'>".__('Critical', 'monitoring')."</font></a>";
|
1366
|
} else {
|
1367
|
echo __('Critical', 'monitoring');
|
1368
|
}
|
1369
|
echo "</td>";
|
1370
|
echo "</tr>";
|
1371
|
echo "<tr>";
|
1372
|
echo "<th style='background-color:transparent;'>";
|
1373
|
if ($type == 'Ressources' OR $type == 'Componentscatalog') {
|
1374
|
echo "<a href='".$critical_link.">".
|
1375
|
"<font color='black' style='font-size: 52px;font-weight: bold;'>".$critical."</font></a>";
|
1376
|
} else {
|
1377
|
echo "<font style='font-size: 52px;'>".$critical."</font>";
|
1378
|
}
|
1379
|
echo "</th>";
|
1380
|
echo "</tr>";
|
1381
|
echo "<tr>";
|
1382
|
echo "<th style='background-color:transparent;'>";
|
1383
|
echo "<font style='font-size: 11px;'>Soft : ".$critical_soft."</font>";
|
1384
|
echo "</th>";
|
1385
|
echo "</tr>";
|
1386
|
echo "</table>";
|
1387
|
echo "</td>";
|
1388
|
|
1389
|
echo "<td>";
|
1390
|
$background = '';
|
1391
|
if ($warningdata > 0) {
|
1392
|
$background = 'background="'.$CFG_GLPI['root_doc'].'/plugins/monitoring/pics/bg_warning.png"';
|
1393
|
}
|
1394
|
if ($type == 'Ressources') {
|
1395
|
echo "<table class='tab_cadre' width='188' height='130' ".$background." >";
|
1396
|
} else {
|
1397
|
echo "<table class='tab_cadre' width='316' height='130' ".$background." >";
|
1398
|
}
|
1399
|
echo "<tr>";
|
1400
|
echo "<th style='background-color:transparent;'>";
|
1401
|
if ($type == 'Ressources') {
|
1402
|
echo "<a href='".$warningdata_link.">".
|
1403
|
"<font color='black' style='font-size: 12px;font-weight: bold;'>".__('Warning', 'monitoring')."</font></a>";
|
1404
|
} else {
|
1405
|
if ($type == 'Componentscatalog') {
|
1406
|
echo "<a href='".$warning_link.">".
|
1407
|
"<font color='black' style='font-size: 12px;font-weight: bold;'>".__('Warning', 'monitoring')."</font></a>";
|
1408
|
} else {
|
1409
|
echo __('Warning', 'monitoring');
|
1410
|
}
|
1411
|
}
|
1412
|
echo "</td>";
|
1413
|
echo "</tr>";
|
1414
|
echo "<tr>";
|
1415
|
echo "<th style='background-color:transparent;'>";
|
1416
|
if ($type == 'Ressources') {
|
1417
|
echo "<a href='".$warningdata_link.">".
|
1418
|
"<font color='black' style='font-size: 52px;'>".$warningdata."</font></a>";
|
1419
|
} else if ($type == 'Componentscatalog') {
|
1420
|
echo "<a href='".$warning_link.">".
|
1421
|
"<font color='black' style='font-size: 52px;'>".$warningdata."</font></a>";
|
1422
|
} else {
|
1423
|
echo "<font style='font-size: 52px;'>".$warningdata."</font>";
|
1424
|
}
|
1425
|
echo "</th>";
|
1426
|
echo "</tr>";
|
1427
|
echo "<tr>";
|
1428
|
echo "<th style='background-color:transparent;'>";
|
1429
|
echo "<font style='font-size: 11px;'>Soft : ".$warningdata_soft."</font>";
|
1430
|
echo "</th>";
|
1431
|
echo "</tr>";
|
1432
|
echo "</table>";
|
1433
|
echo "</td>";
|
1434
|
|
1435
|
if ($type == 'Ressources') {
|
1436
|
echo "<td>";
|
1437
|
$background = '';
|
1438
|
if ($warningconnection > 0) {
|
1439
|
$background = 'background="'.$CFG_GLPI['root_doc'].'/plugins/monitoring/pics/bg_warning_yellow.png"';
|
1440
|
}
|
1441
|
echo "<table class='tab_cadre' width='188' height='130' ".$background." >";
|
1442
|
echo "<tr>";
|
1443
|
echo "<th style='background-color:transparent;'>";
|
1444
|
if ($type == 'Ressources' OR $type == 'Componentscatalog') {
|
1445
|
echo "<a href='".$warningconnection_link.">".
|
1446
|
"<font color='black' style='font-size: 12px;font-weight: bold;'>".__('Warning (connection)', 'monitoring')."</font></a>";
|
1447
|
} else {
|
1448
|
echo __('Warning (connection)', 'monitoring');
|
1449
|
}
|
1450
|
echo "</td>";
|
1451
|
echo "</tr>";
|
1452
|
echo "<tr>";
|
1453
|
echo "<th style='background-color:transparent;'>";
|
1454
|
if ($type == 'Ressources' OR $type == 'Componentscatalog') {
|
1455
|
echo "<a href='".$warningconnection_link.">".
|
1456
|
"<font color='black' style='font-size: 52px;'>".$warningconnection."</font></a>";
|
1457
|
} else {
|
1458
|
echo "<font style='font-size: 52px;'>".$warningconnection."</font>";
|
1459
|
}
|
1460
|
echo "</th>";
|
1461
|
echo "</tr>";
|
1462
|
echo "<tr>";
|
1463
|
echo "<th style='background-color:transparent;'>";
|
1464
|
echo "<font style='font-size: 11px;'>Soft : ".$warningconnection_soft."</font>";
|
1465
|
echo "</th>";
|
1466
|
echo "</tr>";
|
1467
|
echo "</table>";
|
1468
|
echo "</td>";
|
1469
|
}
|
1470
|
|
1471
|
echo "<td>";
|
1472
|
$background = '';
|
1473
|
if ($ok > 0) {
|
1474
|
$background = 'background="'.$CFG_GLPI['root_doc'].'/plugins/monitoring/pics/bg_ok.png"';
|
1475
|
}
|
1476
|
echo "<table class='tab_cadre' width='158' height='130' ".$background." >";
|
1477
|
echo "<tr>";
|
1478
|
echo "<th style='background-color:transparent;'>";
|
1479
|
if ($type == 'Ressources' OR $type == 'Componentscatalog') {
|
1480
|
echo "<a href='".$ok_link.">".
|
1481
|
"<font color='black' style='font-size: 12px;font-weight: bold;'>".__('OK', 'monitoring')."</font></a>";
|
1482
|
} else {
|
1483
|
echo __('OK', 'monitoring');
|
1484
|
}
|
1485
|
echo "</td>";
|
1486
|
echo "</tr>";
|
1487
|
echo "<tr>";
|
1488
|
echo "<th style='background-color:transparent;'>";
|
1489
|
if ($type == 'Ressources' OR $type == 'Componentscatalog') {
|
1490
|
echo "<a href='".$ok_link.">".
|
1491
|
"<font color='black' style='font-size: 52px;font-weight: bold;'>".$ok."</font></a>";
|
1492
|
} else {
|
1493
|
echo "<font style='font-size: 52px;'>".$ok."</font>";
|
1494
|
}
|
1495
|
echo "</th>";
|
1496
|
echo "</tr>";
|
1497
|
echo "<tr>";
|
1498
|
echo "<th style='background-color:transparent;'>";
|
1499
|
echo "<font style='font-size: 11px;'>Soft : ".$ok_soft."</font>";
|
1500
|
echo "</th>";
|
1501
|
echo "</tr>";
|
1502
|
echo "</table>";
|
1503
|
echo "</td>";
|
1504
|
|
1505
|
echo "<td>";
|
1506
|
$background = '';
|
1507
|
if ($acknowledge > 0) {
|
1508
|
$background = 'background="'.$CFG_GLPI['root_doc'].'/plugins/monitoring/pics/bg_acknowledge.png"';
|
1509
|
}
|
1510
|
echo "<table class='tab_cadre' width='120' height='130' ".$background." >";
|
1511
|
echo "<tr>";
|
1512
|
echo "<th style='background-color:transparent;'>";
|
1513
|
if ($type == 'Ressources' OR $type == 'Componentscatalog') {
|
1514
|
echo "<a href='".$acknowledge_link."'>".
|
1515
|
"<font color='black' style='font-size: 12px;font-weight: bold;'>".__('Acknowledge', 'monitoring')."</font></a>";
|
1516
|
} else {
|
1517
|
echo __('Acknowledge', 'monitoring');
|
1518
|
}
|
1519
|
echo "</td>";
|
1520
|
echo "</tr>";
|
1521
|
echo "<tr>";
|
1522
|
echo "<th style='background-color:transparent;'>";
|
1523
|
if ($type == 'Ressources' OR $type == 'Componentscatalog') {
|
1524
|
echo "<a href='".$acknowledge_link."'>".
|
1525
|
"<font color='black' style='font-size: 52px;font-weight: bold;'>".$acknowledge."</font></a>";
|
1526
|
} else {
|
1527
|
echo "<font style='font-size: 52px;'>".$acknowledge."</font>";
|
1528
|
}
|
1529
|
echo "</th>";
|
1530
|
echo "</tr>";
|
1531
|
echo "<tr>";
|
1532
|
echo "<th style='background-color:transparent;'> ";
|
1533
|
echo "</th>";
|
1534
|
echo "</tr>";
|
1535
|
echo "</table>";
|
1536
|
echo "</td>";
|
1537
|
|
1538
|
echo "</tr>";
|
1539
|
echo "</table><br/>";
|
1540
|
|
1541
|
|
1542
|
if ($play_sound == '1') {
|
1543
|
echo '<audio autoplay="autoplay">
|
1544
|
<source src="../audio/star-trek.ogg" type="audio/ogg" />
|
1545
|
Your browser does not support the audio element.
|
1546
|
</audio>';
|
1547
|
}
|
1548
|
}
|
1549
|
|
1550
|
|
1551
|
|
1552
|
function showCounters($type, $display=1, $ajax=1) {
|
1553
|
global $CFG_GLPI;
|
1554
|
|
1555
|
if ($display == 0) {
|
1556
|
return $this->displayCounters($type, $display);
|
1557
|
}
|
1558
|
|
1559
|
if ($ajax == 1) {
|
1560
|
echo "<div id=\"updatecounter".$type."\"></div>";
|
1561
|
echo "<script type=\"text/javascript\">
|
1562
|
|
1563
|
var elcc".$type." = Ext.get(\"updatecounter".$type."\");
|
1564
|
var mgrcc".$type." = elcc".$type.".getUpdateManager();
|
1565
|
mgrcc".$type.".loadScripts=true;
|
1566
|
mgrcc".$type.".showLoadIndicator=false;
|
1567
|
mgrcc".$type.".startAutoRefresh(50, \"".$CFG_GLPI["root_doc"]."/plugins/monitoring/ajax/updateCounter.php\", \"type=".$type."\", \"\", true);
|
1568
|
</script>";
|
1569
|
} else {
|
1570
|
$this->displayCounters($type);
|
1571
|
}
|
1572
|
}
|
1573
|
|
1574
|
|
1575
|
|
1576
|
function refreshPage() {
|
1577
|
|
1578
|
if (isset($_POST['_refresh'])) {
|
1579
|
$_SESSION['glpi_plugin_monitoring']['_refresh'] = $_POST['_refresh'];
|
1580
|
}
|
1581
|
|
1582
|
echo '<meta http-equiv ="refresh" content="'.$_SESSION['glpi_plugin_monitoring']['_refresh'].'">';
|
1583
|
|
1584
|
echo "<form name='form' method='post' action='".$_SERVER["PHP_SELF"]."' >";
|
1585
|
echo "<table width='100%'>";
|
1586
|
echo "<tr>";
|
1587
|
echo "<td align='right'>";
|
1588
|
echo __('Page refresh (in seconds)', 'monitoring')." : ";
|
1589
|
echo " ";
|
1590
|
Dropdown::showNumber("_refresh", array(
|
1591
|
'value' => $_SESSION['glpi_plugin_monitoring']['_refresh'],
|
1592
|
'min' => 30,
|
1593
|
'max' => 1000,
|
1594
|
'step' => 10)
|
1595
|
);
|
1596
|
echo " ";
|
1597
|
echo "<input type='submit' name='sessionupdate' class='submit' value=\"".__('Post')."\">";
|
1598
|
echo "</td>";
|
1599
|
echo "</tr>";
|
1600
|
echo "</table>";
|
1601
|
Html::closeForm();
|
1602
|
}
|
1603
|
|
1604
|
|
1605
|
|
1606
|
function displayPuce($scriptname, $items_id='') {
|
1607
|
global $CFG_GLPI;
|
1608
|
|
1609
|
$split = explode("/", $_SERVER['PHP_SELF']);
|
1610
|
if ($split[(count($split) -1)] == $scriptname.".php") {
|
1611
|
$display = 0;
|
1612
|
if ($items_id != '') {
|
1613
|
if (isset($_GET['id'])
|
1614
|
&& $_GET['id'] == $items_id) {
|
1615
|
$display = 1;
|
1616
|
}
|
1617
|
} else {
|
1618
|
$display = 1;
|
1619
|
}
|
1620
|
if ($display == 1) {
|
1621
|
echo "<img src='".$CFG_GLPI['root_doc']."/pics/right.png' /> ";
|
1622
|
}
|
1623
|
}
|
1624
|
}
|
1625
|
}
|
1626
|
|
1627
|
?>
|