Added the poller group name to the table - general if no poller groups created

This commit is contained in:
laf
2015-08-06 18:36:26 +00:00
parent 2537767f2d
commit c6e3be2277
2 changed files with 14 additions and 3 deletions

View File

@@ -1,9 +1,15 @@
<?php <?php
$sql = ' FROM `devices` AS D'; $sql = ' FROM `devices` AS D ';
if (is_admin() === false) { if (is_admin() === false) {
$sql .= ", devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '".$_SESSION['user_id']."' AND D.ignore = '0'"; $sql .= ", devices_perms AS P ";
}
$sql .= " LEFT JOIN `poller_groups` ON `D`.`poller_group`=`poller_groups`.`id`";
if (is_admin() === false) {
$sql .= " WHERE D.device_id = P.device_id AND P.user_id = '".$_SESSION['user_id']."' AND D.ignore = '0'";
} }
else { else {
$sql .= ' WHERE 1'; $sql .= ' WHERE 1';
@@ -34,12 +40,16 @@ if ($rowCount != -1) {
$sql .= " LIMIT $limit_low,$limit_high"; $sql .= " LIMIT $limit_low,$limit_high";
} }
$sql = "SELECT D.device_id,D.hostname AS `hostname`, D.last_polled AS `last_polled`, D.last_polled_timetaken AS `last_polled_timetaken` $sql"; $sql = "SELECT D.device_id,D.hostname AS `hostname`, D.last_polled AS `last_polled`, `group_name`, D.last_polled_timetaken AS `last_polled_timetaken` $sql";
foreach (dbFetchRows($sql) as $device) { foreach (dbFetchRows($sql) as $device) {
if (empty($device['group_name'])) {
$device['group_name'] = 'General';
}
$response[] = array( $response[] = array(
'hostname' => "<a class='list-device' href='".generate_device_url($device, array('tab' => 'graphs', 'group' => 'poller'))."'>".$device['hostname'].'</a>', 'hostname' => "<a class='list-device' href='".generate_device_url($device, array('tab' => 'graphs', 'group' => 'poller'))."'>".$device['hostname'].'</a>',
'last_polled' => $device['last_polled'], 'last_polled' => $device['last_polled'],
'poller_group' => $device['group_name'],
'last_polled_timetaken' => $device['last_polled_timetaken'], 'last_polled_timetaken' => $device['last_polled_timetaken'],
); );
} }

View File

@@ -6,6 +6,7 @@ $no_refresh = true;
<tr> <tr>
<th data-column-id="hostname">Hostname</th> <th data-column-id="hostname">Hostname</th>
<th data-column-id="last_polled">Last Polled</th> <th data-column-id="last_polled">Last Polled</th>
<th data-column-id="poller_group">Poller Group</th>
<th data-column-id="last_polled_timetaken" data-order="desc">Polling Duration (Seconds)</th> <th data-column-id="last_polled_timetaken" data-order="desc">Polling Duration (Seconds)</th>
</tr> </tr>
</thead> </thead>