From fb7bc5dd5a0452882f8f40c10f306509dbae13a3 Mon Sep 17 00:00:00 2001 From: "Zane C. Bowers-Hadley" Date: Tue, 4 Jun 2024 04:08:20 -0500 Subject: [PATCH] two minor fixes for sagan (#16082) * two minor fixes for sagan * more tweaks * change how instance handling is done --- includes/html/pages/device/apps/sagan.inc.php | 2 +- includes/polling/applications/sagan.inc.php | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/includes/html/pages/device/apps/sagan.inc.php b/includes/html/pages/device/apps/sagan.inc.php index 19a72e13fb..0814dfe6a9 100644 --- a/includes/html/pages/device/apps/sagan.inc.php +++ b/includes/html/pages/device/apps/sagan.inc.php @@ -9,7 +9,7 @@ $link_array = [ print_optionbar_start(); -echo generate_link('Totals', $link_array); +echo generate_link('Totals', $link_array) . ' | Instances: '; $sagan_instances = $app->data['instances'] ?? []; sort($sagan_instances); diff --git a/includes/polling/applications/sagan.inc.php b/includes/polling/applications/sagan.inc.php index 285dfab530..20528704c5 100644 --- a/includes/polling/applications/sagan.inc.php +++ b/includes/polling/applications/sagan.inc.php @@ -78,7 +78,8 @@ foreach ($sagan['data'] as $instance => $stats) { $tags = ['name' => $name, 'app_id' => $app->app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); } -$old_instances = $app->app['instances']; + +$old_instances = $app->app['instances'] ?? []; //check for added instances $added_instances = array_values(array_diff($instances, $old_instances)); @@ -88,13 +89,14 @@ $removed_instances = array_values(array_diff($old_instances, $instances)); // if we have any instance changes, log it if (sizeof($added_instances) > 0 or sizeof($removed_instances) > 0) { - $app->data = ['instances' => $instances]; $log_message = 'Sagan Instance Change:'; $log_message .= count($added_instances) > 0 ? ' Added ' . json_encode($added_instances) : ''; $log_message .= count($removed_instances) > 0 ? ' Removed ' . json_encode($added_instances) : ''; log_event($log_message, $device, 'application'); } +$app->data = ['instances' => $instances]; + // // all done so update the app metrics //