mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
[apps] Docker only show current containers (#14152)
* [apps] enable RRD filename filtering * count/exists * Switch to Applications table * rework similar to zfs * Update docker.inc.php Co-authored-by: Tony Murray <[email protected]>
This commit is contained in:
co-authored by
Tony Murray
parent
478d800384
commit
1be8de0b24
@@ -14,7 +14,7 @@ $smalldescrlen = 25;
|
||||
if (isset($vars['container'])) {
|
||||
$containers = [$vars['container']];
|
||||
} else {
|
||||
$containers = Rrd::getRrdApplicationArrays($device, $app->app_id, 'docker');
|
||||
$containers = $app->data['containers'] ?? [];
|
||||
}
|
||||
|
||||
$int = 0;
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
<?php
|
||||
|
||||
$domain_list = Rrd::getRrdApplicationArrays($device, $app['app_id'], 'docker');
|
||||
|
||||
print_optionbar_start();
|
||||
|
||||
$link_array = [
|
||||
'page' => 'device',
|
||||
'device' => $device['device_id'],
|
||||
@@ -11,20 +7,25 @@ $link_array = [
|
||||
'app' => 'docker',
|
||||
];
|
||||
|
||||
$containers_list = [];
|
||||
print_optionbar_start();
|
||||
|
||||
foreach ($domain_list as $label) {
|
||||
$container = $label;
|
||||
echo generate_link('All Containers', $link_array);
|
||||
echo ' | Containers:';
|
||||
|
||||
if ($vars['container'] == $container) {
|
||||
$label = '<span class="pagemenu-selected">' . $label . '</span>';
|
||||
$containers = $app->data['containers'] ?? [];
|
||||
sort($containers);
|
||||
foreach ($containers as $index => $container) {
|
||||
$label = $vars['container'] == $container
|
||||
? '<span class="pagemenu-selected">' . $container . '</span>'
|
||||
: $container;
|
||||
|
||||
echo generate_link($label, $link_array, ['container' => $container]);
|
||||
|
||||
if ($index < (count($containers) - 1)) {
|
||||
echo ', ';
|
||||
}
|
||||
|
||||
array_push($containers_list, generate_link($label, $link_array, ['container' => $container]));
|
||||
}
|
||||
|
||||
printf('%s | containers: %s', generate_link('All Containers', $link_array), implode(', ', $containers_list));
|
||||
|
||||
print_optionbar_end();
|
||||
|
||||
$graphs = [
|
||||
|
||||
@@ -46,8 +46,9 @@ $rrd_def = RrdDefinition::make()
|
||||
->addDataset('mem_limit', 'GAUGE', 0);
|
||||
|
||||
$metrics = [];
|
||||
$containerNames = [];
|
||||
foreach ($docker_data as $data) {
|
||||
$container = $data['container'];
|
||||
$containerNames[] = $container = $data['container'];
|
||||
|
||||
$rrd_name = ['app', $name, $app->app_id, $container];
|
||||
|
||||
@@ -63,5 +64,6 @@ foreach ($docker_data as $data) {
|
||||
$tags = ['name' => $container, 'app_id' => $app->app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name];
|
||||
data_update($device, 'app', $tags, $fields);
|
||||
}
|
||||
$app->data = ['containers' => $containerNames];
|
||||
|
||||
update_application($app, $output, $metrics);
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
"app_state_prev": "UNKNOWN",
|
||||
"app_status": "",
|
||||
"app_instance": "",
|
||||
"data": null
|
||||
"data": "{\"containers\":[\"foobar_laravel.test_1\",\"foobar_dashboard_1\",\"foobar_meilisearch_1\",\"foobar_mysql_1\",\"foobar_redis_1\"]}"
|
||||
}
|
||||
],
|
||||
"application_metrics": [
|
||||
|
||||
Reference in New Issue
Block a user