From a74be604695750b04c6d183b6d6931c631291bd8 Mon Sep 17 00:00:00 2001 From: Digimer Date: Sun, 2 May 2021 23:35:37 -0400 Subject: [PATCH] * Fixed a bug where the log message for a changed CIB wasn't useful. Signed-off-by: Digimer --- scancore-agents/scan-cluster/scan-cluster | 14 +++++++++----- scancore-agents/scan-cluster/scan-cluster.xml | 5 +++++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/scancore-agents/scan-cluster/scan-cluster b/scancore-agents/scan-cluster/scan-cluster index c28eb9cc..98ab2a01 100755 --- a/scancore-agents/scan-cluster/scan-cluster +++ b/scancore-agents/scan-cluster/scan-cluster @@ -19,6 +19,7 @@ use strict; use warnings; use Anvil::Tools; use Data::Dumper; +use Text::Diff; # Disable buffering $| = 1; @@ -193,7 +194,7 @@ WHERE UPDATE scan_cluster SET - scan_cluster_cib = ".$anvil->Database->quote($cluster_name).", + scan_cluster_cib = ".$anvil->Database->quote($cluster_cib).", modified_date = ".$anvil->Database->quote($anvil->data->{sys}{database}{timestamp})." WHERE scan_cluster_uuid = ".$anvil->Database->quote($scan_cluster_uuid)." @@ -201,12 +202,15 @@ WHERE $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }}); $anvil->Database->write({query => $query, source => $THIS_FILE, line => __LINE__}); + my $difference = diff \$old_cluster_cib, \$cluster_cib, { STYLE => 'Unified' }; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { difference => $difference }}); + my $variables = { - new_cluster_name => $cluster_name, - old_cluster_name => $old_cluster_name, + cluster_name => $cluster_name, + difference => $difference, }; - $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_cluster_alert_0002", variables => $variables}); - $anvil->Alert->register({debug => 2, alert_level => "notice", message => "scan_cluster_alert_0002", variables => $variables, set_by => $THIS_FILE}); + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_cluster_alert_0012", variables => $variables}); + $anvil->Alert->register({debug => 2, alert_level => "notice", message => "scan_cluster_alert_0012", variables => $variables, set_by => $THIS_FILE}); } } else diff --git a/scancore-agents/scan-cluster/scan-cluster.xml b/scancore-agents/scan-cluster/scan-cluster.xml index 1d875138..49c2b3e6 100644 --- a/scancore-agents/scan-cluster/scan-cluster.xml +++ b/scancore-agents/scan-cluster/scan-cluster.xml @@ -32,6 +32,11 @@ In Maintenance Mode: ..... [#!variable!maintenance_mode!#] The node: [#!variable!old_node_name!#] has been renamed to: [#!variable!new_node_name!#] The node: [#!variable!host_name!#] is no longer in the cluster. The node: [#!variable!host_name!#] is returning back into the cluster. + The Cluster CIB for the cluster: [#!variable!cluster_name!#] has changed. The difference is: +==== +#!variable!difference!# +==== + Starting: [#!variable!program!#].