1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Icinga\Module\Trapdirector\Tables; |
4
|
|
|
|
5
|
|
|
use Icinga\Web\Url; |
6
|
|
|
|
7
|
|
|
class HandlerTable extends TrapDirectorTable |
8
|
|
|
{ |
9
|
|
|
|
10
|
|
|
protected $status_display=array( |
11
|
|
|
-2 =>'ignore', |
12
|
|
|
-1 => '-', |
13
|
|
|
0 => 'OK', |
14
|
|
|
1 => 'warning', |
15
|
|
|
2 => 'critical', |
16
|
|
|
3 => 'unknown',); |
17
|
|
|
|
18
|
|
|
// translate |
19
|
|
|
protected $doTranslate=false; |
20
|
|
|
protected $MIB; |
21
|
|
|
|
22
|
|
|
public function setMibloader($mibloader) |
23
|
|
|
{ |
24
|
|
|
$this->MIB=$mibloader; |
25
|
|
|
$this->doTranslate=true; |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
|
29
|
|
|
public function getCurrentURL() |
30
|
|
|
{ |
31
|
|
|
return Url::fromPath($this->urlPath . '/handler'); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
public function renderLine($row) |
35
|
|
|
{ |
36
|
|
|
$html = ''; |
37
|
|
|
$firstCol = true; |
38
|
|
|
|
39
|
|
|
$titleNames = array_keys($this->titles); |
40
|
|
|
foreach ($titleNames as $rowkey ) |
41
|
|
|
{ |
42
|
|
|
// Check missing value |
43
|
|
|
if (property_exists($row, $rowkey)) |
44
|
|
|
{ |
45
|
|
|
switch ($rowkey) |
46
|
|
|
{ |
47
|
|
|
case 'action_match': // display text levels |
48
|
|
|
case 'action_nomatch': |
49
|
|
|
$val=$this->status_display[$row->$rowkey]; |
50
|
|
|
break; |
51
|
|
|
case 'trap_oid': // try to traslate oids. |
52
|
|
|
|
53
|
|
|
if ($this->doTranslate === true) |
54
|
|
|
{ |
55
|
|
|
$oidName = $this->MIB->translateOID($row->$rowkey); |
56
|
|
|
if (isset($oidName['name'])) |
57
|
|
|
{ |
58
|
|
|
$val=$oidName['name']; |
59
|
|
|
} |
60
|
|
|
else |
61
|
|
|
{ |
62
|
|
|
$val = $row->$rowkey; |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
else |
66
|
|
|
{ |
67
|
|
|
$val = $row->$rowkey; |
68
|
|
|
} |
69
|
|
|
break; |
70
|
|
|
case 'host_name': // switch to hostgroup if name is null |
71
|
|
|
if ($row->$rowkey == null) |
72
|
|
|
{ |
73
|
|
|
$val = $row->host_group_name; |
74
|
|
|
} |
75
|
|
|
else |
76
|
|
|
{ |
77
|
|
|
$val = $row->$rowkey; |
78
|
|
|
} |
79
|
|
|
break; |
80
|
|
|
default: |
81
|
|
|
$val = $row->$rowkey; |
82
|
|
|
} |
83
|
|
|
if ($rowkey == 'trap_oid' && $this->doTranslate===true) |
84
|
|
|
{ |
85
|
|
|
|
86
|
|
|
} |
87
|
|
|
} else { |
88
|
|
|
$val = '-'; |
89
|
|
|
} |
90
|
|
|
if ($firstCol === true) { // Put link in first column for trap detail. |
91
|
|
|
$html .= '<td>' |
92
|
|
|
. $this->view->qlink( |
93
|
|
|
$this->view->escape($val), |
94
|
|
|
Url::fromPath( |
95
|
|
|
$this->urlPath . '/handler/add', |
96
|
|
|
array('ruleid' => $row->id) |
97
|
|
|
) |
98
|
|
|
) |
99
|
|
|
. '</td>'; |
100
|
|
|
} else { |
101
|
|
|
$html .= '<td>' . $this->view->escape($val) . '</td>'; |
102
|
|
|
} |
103
|
|
|
$firstCol=false; |
104
|
|
|
|
105
|
|
|
} |
106
|
|
|
return $html; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
} |