forked from mattiasgeniar/MoZBX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hosts.php
85 lines (73 loc) · 2.25 KB
/
hosts.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
<?php
require_once("config.inc.php");
require_once("functions.php");
require_once("class_zabbix.php");
$zabbix = new Zabbix($arrSettings);
// Get values from cookies, if any
require_once("cookies.php");
// 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) {
// Or try it with our info from the cookies
$zabbix->login();
}
if (!$zabbix->isLoggedIn()) {
header("Location: index.php");
exit();
}
require_once("template/header.php");
$zabbixHostgroupId = (string) $_GET['hostgroupid'];
if ($zabbixHostgroupId > 0) {
$hostgroup = $zabbix->getHostgroupById($zabbixHostgroupId);
$hosts = $zabbix->getHostsByGroupId ($zabbixHostgroupId);
$hosts = $zabbix->filterActiveHosts($hosts);
$hosts = $zabbix->sortHostsByName($hosts);
?>
<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="hostgroups.php">Hostgroups</a> <span class="divider">/</span>
</li>
<li class="active">
<?php echo $hostgroup->name; ?>
</li>
</ul>
</div>
</div>
<div class="container">
<ul class="nav nav-pills nav-stacked">
<?php
foreach ($hosts as $host) {
?>
<li>
<a href="host.php?hostid=<?php echo $host["hostid"]; ?>&groupid=<?php echo $zabbixHostgroupId; ?>&groupname=<?php echo urlencode($hostgroup->name); ?>">
<i class="icon-inbox"></i> <?php echo $host["host"]; ?>
</a>
</li>
<?php
}
?>
</ul>
<?php
} else {
?>
<div class="alert alert-error">
Invalid hostgroup, aborting request.
</div>
<?php
}
?>
</div>
<?php
require_once("template/footer.php");
?>