forked from bmelim/zabdash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhosts_groups.php
148 lines (117 loc) · 4.17 KB
/
hosts_groups.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
144
145
146
147
148
<?php
//Access control
if(!$_COOKIE["zabdash_session"]) {
header("location:index.php");
}
require_once '../include/config.inc.php';
require_once '../include/hosts.inc.php';
require_once '../include/actions.inc.php';
include('config.php');
?>
<!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='600'>-->
<title>Zabbix - Groups</title>
<link rel="icon" href="img/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>
<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 rel="stylesheet" type="text/css" href="css/styles.css" />
</head>
<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>
<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: 0px; float:none; margin-right:auto; margin-left:auto; text-align:center;">
</div>
<?php
$md = 10;
$dbgroupsCount = DBselect( 'SELECT COUNT(groupid) AS hc FROM hstgrp');
$groupsCount = DBFetch($dbgroupsCount);
//check version
if(ZABBIX_EXPORT_VERSION >= '4.0'){
$grps = 'hstgrp';
}
else {
$grps = 'groups';
}
$dbGroups = DBselect( 'SELECT * FROM '.$grps.' WHERE groupid <> 1 ORDER BY name ASC');
$dbHostsCount = DBselect( 'SELECT COUNT(h.hostid) AS hc FROM hosts h WHERE h.status <> 3 AND h.flags = 0');
$hostsCount = DBFetch($dbHostsCount);
echo "
<div class='align col-md-".$md." col-sm-".$md."' style='margin-bottom:20px;' >
<table id='hosts' class='box table table-striped table-hover' border='0' width='100%'>
<thead>
<tr>
<th width='8px'></th>
<th style='text-align:center;'>". _('Groups')." (".$groupsCount['hc'].")</th>
<th style='text-align:center;'>". _('Hosts')." (" .$hostsCount['hc'].")</th>
</tr>
</thead>
<tbody>\n ";
echo "
<tr>
<td style='background-color:".$cor.";' title='".$conn."'>
</td>
<td class='link2' style='vertical-align:middle; text-align:left; padding:5px;'>
<a href='hosts_view.php?groupid=0' target='_self' >". _('All')."</a>
</td>
<td style='text-align:center;'>
" .$hostsCount['hc']."
</td>
</tr>";
while ($groups = DBFetch($dbGroups)) {
$dbHosts = DBSelect('SELECT COUNT(hostid) AS hosts FROM hosts_groups WHERE groupid ='.$groups['groupid']);
$hosts = DBFetch($dbHosts);
echo "
<tr>
<td style='background-color:".$cor.";' title='".$conn."'>
</td>
<td class='link2' style='vertical-align:middle; text-align:left; padding:5px;'>
<a href='hosts_view.php?groupid=".$groups['groupid']."' target='_self' >".$groups['name']."</a>
</td>
<td style='text-align:center;'>
".$hosts['hosts']."
</td>
</tr>";
}
echo " </tbody>
</table>
</div>\n";
?>
</div>
<script type="text/javascript">
$(document).ready(function() {
$('#hosts').DataTable({
"select": false,
"filter": true,
"paging": true,
"ordering": true,
"info": false,
"order": [[ 0, "asc" ]],
pagingType: "full_numbers",
displayLength: 25,
lengthMenu: [[25, 50, 100, -1], [25, 50, 100, "All"]],
});
});
</script>
</body>
</html>