forked from mattiasgeniar/MoZBX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
trigger_info.php
143 lines (125 loc) · 4.77 KB
/
trigger_info.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
136
137
138
139
140
141
142
143
<?php
require_once("config.inc.php");
require_once("functions.php");
require_once("class_zabbix.php");
require_once("cookies.php");
$zabbix = new Zabbix($arrSettings);
// Populate our class
$zabbix->setUsername($zabbixUser);
$zabbix->setPassword($zabbixPass);
$zabbix->setZabbixApiUrl($zabbixApi);
// Login
if (isset($zabbixAuthHash) && strlen($zabbixAuthHash) > 0) {
// Try it with the authentication hash we have
$zabbix->setAuthToken($zabbixAuthHash);
} elseif (strlen($zabbix->getUsername()) > 0 && strlen($zabbix->getPassword()) > 0 && strlen($zabbix->getZabbixApiUrl()) > 0) {
$zabbix->login();
}
if (!$zabbix->isLoggedIn()) {
header("Location: index.php");
exit();
}
require_once("template/header.php");
$zabbixTriggerId = (string) $_GET['triggerid'];
$zabbixHostId = (string) $_GET['hostid'];
if ($zabbixTriggerId > 0 && $zabbixHostId > 0) {
// Retrieve the trigger information
$trigger = $zabbix->getTriggerByTriggerAndHostId($zabbixTriggerId, $zabbixHostId);
$host = $zabbix->getHostById($zabbixHostId);
$events = $zabbix->getEventsByTriggerAndHostId($zabbixTriggerId, $zabbixHostId);
?>
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<ul class="breadcrumb">
<li>
<a href="index.php">Home</a> <span class="divider">/</span>
</li>
<li>
<a href="activetriggers.php">Active Triggers</a> <span class="divider">/</span>
</li>
<li class="active">
<?php echo cleanTriggerDescription($trigger["description"]); ?>
</li>
</ul>
</div>
</div>
<div class="container">
<h2><?php echo $host->host?>: <?php echo cleanTriggerDescription($trigger["description"])?></h2>
<h3>Host details</h3>
<p>
Host: <?php echo $host->host?> <br />
DNS: <?php echo $host->dns?> <br />
IP: <?php echo $host->ip?> <br />
</p>
<h3>Trigger details</h3>
<p>
Description: <?php echo cleanTriggerDescription($trigger["description"]) ?> <br />
Comment: <?php echo cleanTriggerDescription($trigger["comments"]) ?> <br />
</p>
<?php
if (is_array($events) && count($events) > 0) {
$first_event = $events[0];
$acknowledge_event = "";
if ($first_event->value == 1 && $first_event->acknowledged != 1) {
// This event is in the "problem" state, and it's the last event: meaning the trigger is still in problem
// We can acknowledge that
?>
<h3>Acknowledge event</h3>
<form action="trigger_ack.php" method="post" class="well">
<input type="hidden" name="eventid" value="<?php echo $first_event->eventid; ?>" />
<input type="hidden" name="triggerid" value="<?php echo $zabbixTriggerId; ?>" />
<input type="hidden" name="type" value="acknowledge" />
<label>Acknowledge</label>
<textarea name="comment" id="comment" value="" placeholder="Comment"></textarea>
<span class="help-block">Please describe why you're acknowledging this event.</span>
<button type="submit" name="mZabbixTriggerAck" class="btn btn-primary">Acknowledge</button>
</form>
<?php
}
}
?>
<h3>Events</h3>
<?php
$prev_clock = null;
if (is_array($events) && count($events) > 0) {
?>
<ul class="nav nav-list">
<?php
foreach ($events as $event) {
$problem_time = "";
if ($event->value == 1) {
// This event is in the "problem" state
if ($prev_clock != null) {
$problem_time = "<i>(lasted ". ($prev_clock - $event->clock) ." seconds)</i>";
}
}
if ($event->acknowledged == 1) {
$event->value = 2;
}
?>
<li<?php echo (convertEventValue($event->value) == 'Acknowledged') ? ' style="background-color: #dff0d8;"' : ''; ?>>
<i class="icon-map-marker"></i>
<?php echo convertEventClock($event->clock)?>: <?php echo convertEventValue($event->value)?>
<?php echo $problem_time?>
</li>
<?php
$prev_clock = $event->clock;
}
} else {
?>
<div class="alert alert-info">
<p>No events were found for this trigger.</p>
</div>
<?php
}
?>
</div>
<?php
} else {
?>
<div class="alert alert-error">
<p>Invalid triggerID specified.</p>
</div>
<?php
}
?>