mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
enhance poller group management (#11073)
This commit is contained in:
committed by
Kevin Krumm
parent
198e29c831
commit
2bd19c655b
@ -52,6 +52,7 @@ class DeviceController extends TableController
|
||||
'ignore' => 'nullable|in:0,1',
|
||||
'disable_notify' => 'nullable|in:0,1',
|
||||
'group' => 'nullable|int',
|
||||
'poller_group' => 'nullable|int',
|
||||
];
|
||||
}
|
||||
|
||||
@ -88,6 +89,10 @@ class DeviceController extends TableController
|
||||
});
|
||||
}
|
||||
|
||||
if ($request->get('poller_group') !== null) {
|
||||
$query->where('poller_group', $request->get('poller_group'));
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
|
@ -186,6 +186,10 @@ if ($format == "graph") {
|
||||
if (!empty($vars['location'])) {
|
||||
$location_filter = $vars['location'];
|
||||
}
|
||||
if (isset($vars['poller_group'])) {
|
||||
$where .= " AND `poller_group`= ?";
|
||||
$sql_param[] = $vars['poller_group'];
|
||||
}
|
||||
if (!empty($vars['group'])) {
|
||||
$where .= " AND ( ";
|
||||
foreach (DB::table('device_group_device')->where('device_group_id', $vars['group'])->pluck('device_id') as $dev) {
|
||||
@ -350,6 +354,7 @@ if ($format == "graph") {
|
||||
ignore: '<?php echo mres($vars['ignore']); ?>',
|
||||
disable_notify: '<?php echo mres($vars['disable_notify']); ?>',
|
||||
group: '<?php echo mres($vars['group']); ?>',
|
||||
poller_group: '<?php echo mres($vars['poller_group']); ?>',
|
||||
};
|
||||
},
|
||||
url: "<?php echo url('/ajax/table/device') ?>"
|
||||
|
@ -25,20 +25,32 @@ require_once 'includes/html/modal/poller_groups.inc.php';
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Group Name</th>
|
||||
<th>Devices</th>
|
||||
<th>Description</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
$query = 'SELECT * FROM `poller_groups`';
|
||||
|
||||
foreach (dbFetchRows($query) as $group) {
|
||||
$default_group = ['id' => 0,
|
||||
'group_name' =>'(default poller group)',
|
||||
'descr' => 'Devices which are not assigned to a poller group will be handled by this poller'];
|
||||
|
||||
$group_list = dbFetchRows('SELECT * FROM `poller_groups`');
|
||||
array_unshift($group_list, $default_group);
|
||||
|
||||
foreach ($group_list as $group) {
|
||||
$group_device_count = dbFetchCell('SELECT COUNT(*) FROM devices WHERE `poller_group`=?', $group['id']);
|
||||
echo '
|
||||
<tr id="'.$group['id'].'">
|
||||
<td>'.$group['id'].'</td>
|
||||
<td>'.$group['group_name'].'</td>
|
||||
<td>'.$group['descr'].'</td>
|
||||
<td><button type="button" class="btn btn-success btn-xs" id="'.$group['id'].'" data-group_id="'.$group['id'].'" data-toggle="modal" data-target="#poller-groups">Edit</button> <button type="button" class="btn btn-danger btn-xs" id="'.$group['id'].'" data-group_id="'.$group['id'].'" data-toggle="modal" data-target="#confirm-delete">Delete</button></td>
|
||||
<td><a href="/devices/poller_group='.$group['id'].'")">'.$group_device_count.'</a></td>
|
||||
<td>'.$group['descr'].'</td>';
|
||||
echo '<td>';
|
||||
if ($group['id']) {
|
||||
echo '<button type="button" class="btn btn-success btn-xs" id="'.$group['id'].'" data-group_id="'.$group['id'].'" data-toggle="modal" data-target="#poller-groups">Edit</button> <button type="button" class="btn btn-danger btn-xs" id="'.$group['id'].'" data-group_id="'.$group['id'].'" data-toggle="modal" data-target="#confirm-delete">Delete</button>';
|
||||
}
|
||||
echo '</td>
|
||||
</tr>
|
||||
';
|
||||
}
|
||||
|
Reference in New Issue
Block a user