forked from bmelim/zabdash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtriggers.php
139 lines (111 loc) · 5.4 KB
/
triggers.php
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
<?php
//Access control
if(!$_COOKIE["zabdash_session"]) {
header("location:index.php");
}
require_once '../include/config.inc.php';
require_once('config.php');
require_once 'inc/functions.inc.php';
require_once 'lib/ZabbixApi.class.php';
use ZabbixApi\ZabbixApi;
$api = new ZabbixApi($zabURL.'api_jsonrpc.php', ''. $zabUser .'', ''. $zabPass .'');
$triggerAll = $api->triggerGet(array(
'output' => 'extend',
'sortfield' => 'lastchange',
'sortorder' => 'DESC',
'only_true' => '1', //recents
'active' => '1',
'withUnacknowledgedEvents' => '1',
'expandDescription' => '1',
'selectHosts' => 1
));
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Language" content="pt-br">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- <meta http-equiv='refresh' content='300'>-->
<title>ZabDash - Triggers</title>
<link rel="icon" href="favicon.ico" type="image/x-icon" />
<link href="css/bootstrap.css" rel="stylesheet">
<link href="css/font-awesome.css" rel="stylesheet">
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.10.2.custom.min.js"></script>
<link rel="stylesheet" type="text/css" href="css/styles.css" />
<!-- Datatables -->
<script src="js/media/js/jquery.dataTables.min.js"></script>
<link href="js/media/css/dataTables.bootstrap.css" type="text/css" rel="stylesheet" />
<script src="js/media/js/dataTables.bootstrap.js"></script>
<!-- <script src="js/extensions/Buttons/js/dataTables.buttons.min.js"></script>-->
<link href="js/extensions/Select/css/select.bootstrap.css" type="text/css" rel="stylesheet" />
<script src="js/extensions/Select/js/dataTables.select.min.js"></script>
<link rel="stylesheet" type="text/css" href="css/skin-material.css">
<link rel="stylesheet" type="text/css" href="css/style-material.css">
<link href="css/loader.css" type="text/css" rel="stylesheet" />
<script type="text/javascript">
jQuery(window).load(function () {
$(".loader").fadeOut("slow"); //retire o delay quando for copiar! delay(1500).
$("#container-fluid").toggle("fast");
});
</script>
</head>
<body>
<div id="loader" class="loader"></div>
<div class='container-fluid'>
<div class="row col-md-12 col-sm-12" style="margin-top:40px; margin-bottom: 70px; float:none; margin-right:auto; margin-left:auto; text-align:center;">
<?php
echo "
<div id='triggers_all' class='align col-md-12 col-sm-12' style='margin-bottom: 30px;'>
<table id='triggers' class='box table table-striped table-hover table-condensed' border='0' style='height:250px;'>
<thead>
<tr>
<th style='text-align:center; width:15%;'>". _('Last change')."</th>
<th style='text-align:center;'>". _('Severity')."</th>
<th style='text-align:center;'>". _('Host')."</th>
<th style='text-align:center;'>". _('Status')."</th>
<th style='text-align:center;'>". _('Description')."</th>
</tr>\n
</thead>\n
<tbody>\n ";
foreach($triggerAll as $tu) {
if($tu->value == 0) { $priority = 9; $statColor = '#fff';}
else { $priority = $tu->priority; $statColor = '#fff'; }
echo "<tr>";
echo "<td style='text-align:center; vertical-align: middle !important;' data-order=".$tu->lastchange.">".from_epoch($tu->lastchange)."</td>\n";
echo "<td style='vertical-align: middle !important;'>
<div class='hostdiv nok". $priority ." hostevent trig_radius' style='height:21px !important; margin-top:5px; !important;' onclick=\"window.open('".$zabURL."zabbix.php?action=problem.view&page=1&filter_hostids[]=". $tu->hosts[0]->hostid. "&filter_show=1&filter_application=&filter_name=&filter_severity=0&filter_inventory[0][field]=type&filter_inventory[0][value]=&filter_evaltype=0&filter_tags[0][tag]=&filter_tags[0][operator]=0&filter_tags[0][value]=&filter_show_tags=3&filter_tag_name_format=0&filter_tag_priority=&filter_set=1')\">
<p class='severity'>". _(get_severity($tu->priority)) ."</p>
</div>
</td>";
echo "<td style='text-align:left; vertical-align: middle !important;'><a href='../zabdash/host_detail.php?hostid=".$tu->hosts[0]->hostid."' target='_blank'>". get_hostname($tu->hosts[0]->hostid)."</a></td>";
echo "<td style='text-align:center; vertical-align: middle !important; color:".$statColor." !important;'>"._(set_status($tu->value))."</td>";
echo "<td style='text-align:left; vertical-align: middle !important; padding-left:12px;'>".$tu->description."</td>";
echo "</tr>\n";
}
echo "</tbody> </table></div>\n";
?>
</div>
</div>
<script type="text/javascript">
$(document).ready(function() {
$('#triggers').DataTable({
"select": true,
"paging": true,
"info": true,
"filter": true,
"lengthChange": true,
"ordering": true,
"order": [[ 0, "desc" ]],
pagingType: "full_numbers",
displayLength: 25,
lengthMenu: [[25, 50, 100, -1], [25, 50, 100, "All"]],
});
});
</script>
</body>
</html>