forked from bmelim/zabdash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsomegroups.php
141 lines (116 loc) · 5.28 KB
/
somegroups.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
<?php
foreach( $groupID as $g ) {
$dbHosts = DBselect( 'SELECT h.hostid, h.name, h.status, h.snmp_available AS sa, h.snmp_disable_until AS sd, h.flags FROM hosts h, hosts_groups hg WHERE hg.groupid = '.$g.' AND h.hostid = hg.hostid ORDER BY h.name ASC' );
$dbHostsOk = DBselect( 'SELECT h.hostid, h.name, h.status, h.snmp_available AS sa, h.snmp_disable_until AS sd, h.flags FROM hosts h, hosts_groups hg WHERE hg.groupid = '.$g.' AND h.hostid = hg.hostid ORDER BY h.name ASC' );
//get group name
$group = get_hostgroup_by_groupid($g);
$groupName = $group['name'];
echo '
<div class="col-md-12 col-sm-12">
<h3 style="color:#fff !important; margin-top:-2 px;"> ' .$groupName.'</h3>
</div> ';
$md = 2;
while ($hosts = DBFetch($dbHosts)) {
if($hosts['status'] == 0 && $hosts['flags'] == 0) {
if($hosts['sd'] != 0) {
//hosts offline
$cor = "#E3573F";
$icon = "fa fa-exclamation-triangle";
$dbIP = DBSelect('SELECT DISTINCT ip FROM interface WHERE hostid ='.$hosts['hostid']);
$IP = DBFetch($dbIP);
echo "
<div class='hostdiv col-md-".$md." col-sm-".$md."' style='background-color:".$cor.";'>
<table border='0' width='100%' height='100%' style='color:#fff;'>
<tr>
<td rowspan='2' style='font-size:20px;' width='22px' height='50%'>
<i class='".$icon."'></i>
</td>
<td class='link'>
<a href='".$zabURL."zabbix.php?action=problem.view&page=1&filter_hostids[]=".$hosts['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' target='_blank' >".$hosts['name']."</a>
</td>
<td rowspan='2' style='font-size:20px;' width='22px' height='50%'>
<img src='img/os/".getOS($hosts['hostid']).".png' alt=''/>
</td>
</tr>
<tr>
<td>
".$IP['ip']."
</td>
</tr>
</table>
</div>\n";
}
}
}
//hosts online
while ($hosts = DBFetch($dbHostsOk)) {
if($hosts['status'] == 0 && $hosts['flags'] == 0) {
if($hosts['sd'] == 0) {
$icon = "fa fa-thumbs-up";
$dbIP = DBSelect('SELECT DISTINCT ip FROM interface WHERE hostid ='.$hosts['hostid']);
$IP = DBFetch($dbIP);
$trigger = $api->triggerGet(array(
'output' => 'extend',
'hostids' => $hosts['hostid'],
'sortfield' => 'priority',
'sortorder' => 'DESC',
'only_true' => '1',
'active' => '1', // include trigger state active not active
'withUnacknowledgedEvents' => '1' // show only unacknowledgeevents
));
if ($trigger) {
// Highest Priority error
if($trigger[0]->value == 0) { $hostdivprio = 9;}
else { $hostdivprio = $trigger[0]->priority;}
// View
$icon = "fa fa-exclamation-circle";
echo "
<div class='hostdiv nok". $hostdivprio ." col-md-".$md." col-sm-".$md."'>
<table border='0' width='100%' height='100%' style='color:#fff;' class='link". $hostdivprio ."'>
<tr>
<td rowspan='2' style='font-size:20px;' width='22px' height='50%'>
<i class='".$icon."'></i>
</td>
<td class='link". $hostdivprio ."'>
<a href='".$zabURL."zabbix.php?action=problem.view&page=1&filter_hostids[]=".$hosts['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' target='_blank' >".$hosts['name']."</a>
</td>
<td rowspan='2' style='font-size:20px;' width='22px' height='50%'>
<img src='img/os/".getOS($hosts['hostid']).".png' alt=''/>
</td>
</tr>
<tr>
<td>
".$IP['ip']."
</td>
</tr>
</table>
</div>\n";
}
else {
echo "
<div class='hostdiv ok col-md-".$md." col-sm-".$md."'>
<table border='0' width='100%' height='100%' style='color:#fff;'>
<tr>
<td rowspan='2' style='color:#fff; font-size:20px;' width='22px' height='50%'>
<i class='".$icon."'></i>
</td>
<td class='link'>
<a href='".$zabURL."zabbix.php?action=problem.view&page=1&filter_hostids[]=".$hosts['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' target='_blank' >".$hosts['name']."</a>
</td>
<td rowspan='2' style='font-size:20px;' width='22px' height='50%'>
<img src='img/os/".getOS($hosts['hostid']).".png' alt=''/>
</td>
</tr>
<tr>
<td>
".$IP['ip']."
</td>
</tr>
</table>
</div>\n";
}
}
}
}
}
?>