mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
two minor fixes for sagan (#16082)
* two minor fixes for sagan * more tweaks * change how instance handling is done
This commit is contained in:
committed by
GitHub
parent
05f29ae76c
commit
fb7bc5dd5a
@@ -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);
|
||||
|
@@ -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
|
||||
//
|
||||
|
Reference in New Issue
Block a user