This repository has been archived by the owner on May 8, 2019. It is now read-only.
forked from mattiasgeniar/MoZBX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhosts.php
executable file
·58 lines (49 loc) · 1.57 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
<?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 = (int) $_GET['hostgroupid'];
if ($zabbixHostgroupId > 0) {
$hostgroup = $zabbix->getHostgroupById($zabbixHostgroupId);
$hosts = $zabbix->getHostsByGroupId ($zabbixHostgroupId);
$hosts = $zabbix->filterActiveHosts($hosts);
$hosts = $zabbix->sortHostsByName($hosts);
?>
<div id="hosts_general_<?php echo $zabbixHostgroupId?>" class="current">
<div class="toolbar">
<h1><?php echo $hostgroup->name?></h1>
<a class="back" href="#">Back</a>
</div>
<ul class="rounded">
<?php
foreach ($hosts as $host) {
echo "<li><a href=\"host.php?hostid=". $host["hostid"] ."\"><img src=\"images/host.png\" class=\"icon_list\">". $host["host"] ."</a></li>";
}
?>
</li>
</div>
<?php
} else {
echo "Invalid hostgroup.";
}
?>