From 20b75310b798187460679e183ad9566f20066fc9 Mon Sep 17 00:00:00 2001
From: Digimer <digimer@alteeve.ca>
Date: Tue, 1 Dec 2020 23:59:54 -0500
Subject: [PATCH] * Created DRBD->resource_uuid() which reads (or adds) the
 'scan_drbd_uuid' to the resource configuration file, which will allow us to
 track resources when they're renamed. * Got scan-drbd's read_last_scan() and
 process_drbd() functions done (but untested so far).

Signed-off-by: Digimer <digimer@alteeve.ca>
---
 Anvil/Tools/DRBD.pm                     | 133 +++++++
 notes                                   |  24 ++
 scancore-agents/scan-drbd/scan-drbd     | 472 +++++++++++++++++++++++-
 scancore-agents/scan-drbd/scan-drbd.xml |  41 ++
 share/words.xml                         |   6 +
 5 files changed, 672 insertions(+), 4 deletions(-)

diff --git a/Anvil/Tools/DRBD.pm b/Anvil/Tools/DRBD.pm
index 0674cfdb..cfcb8019 100755
--- a/Anvil/Tools/DRBD.pm
+++ b/Anvil/Tools/DRBD.pm
@@ -19,6 +19,7 @@ my $THIS_FILE = "DRBD.pm";
 # get_status
 # manage_resource
 # reload_defaults
+# resource_uuid
 # update_global_common
 # 
 
@@ -971,6 +972,138 @@ sub reload_defaults
 	return($return_code);
 }
 
+
+=head2 resource_uuid
+
+This method reads the C<< scan_drbd_resource_uuid >> from a DRBD resource file. If no UUID is found (and C<< new_resource_uuid >> isn't set), an empty string is returned. If there is a problem, C<< !!error!! >> is returned.
+
+Parameters;
+
+=head3 new_resource_uuid (optional)
+
+If this is set to a UUID, and no existing UUID is found, this UUID will be added to the resource config file.
+
+=head3 resource_ (required)
+
+This is the name of resource whose UUID we're looking for.
+
+=head3 resource_file (required)
+
+This is the full path to the resource configuration file that the UUID will be read from, if possible.
+
+=cut
+sub resource_uuid
+{
+	my $self      = shift;
+	my $parameter = shift;
+	my $anvil     = $self->parent;
+	my $debug     = defined $parameter->{debug} ? $parameter->{debug} : 3;
+	$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "DRBD->resource_uuid()" }});
+	
+	my $new_resource_uuid = defined $parameter->{new_resource_uuid} ? $parameter->{new_resource_uuid} : 0;
+	my $resource          = defined $parameter->{resource}          ? $parameter->{resource}          : "";
+	my $resource_file     = defined $parameter->{resource_file}     ? $parameter->{resource_file}     : "";
+	$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { 
+		new_resource_uuid => $new_resource_uuid, 
+		resource_file     => $resource_file,
+	}});
+	
+	if (not $resource)
+	{
+		$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0020", variables => { method => "DRBD->resource_uuid()", parameter => "resource" }});
+		return('!!error!!');
+	}
+	if (not $resource_file)
+	{
+		$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0020", variables => { method => "DRBD->resource_uuid()", parameter => "resource_file" }});
+		return('!!error!!');
+	}
+	
+	my $scan_drbd_resource_uuid = "";
+	my $in_resource             = 0;
+	my $resource_config         = $anvil->Storage->read_file({file => $resource_file});
+	if ($resource_config eq "!!error!!")
+	{
+		# Something went wrong.
+		return('!!error!!');
+	}
+	foreach my $line (split/\n/, $resource_config)
+	{
+		$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { line => $line }});
+		if ($line =~ /^resource (.*?) /)
+		{
+			my $this_resource = $1;
+			$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { this_resource => $this_resource }});
+			if ($this_resource eq $resource)
+			{
+				$in_resource = 1;
+				$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { in_resource => $in_resource }});
+			}
+			else
+			{
+				$in_resource = 0;
+				$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { in_resource => $in_resource }});
+			}
+		}
+		
+		if (($in_resource) && ($line =~ /# scan_drbd_resource_uuid = (.*)$/))
+		{
+			$scan_drbd_resource_uuid =  $1;
+			$scan_drbd_resource_uuid =~ s/^\s+//;
+			$scan_drbd_resource_uuid =~ s/\s.*$//;
+			$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { scan_drbd_resource_uuid => $scan_drbd_resource_uuid }});
+			
+			if (not $anvil->Validate->uuid({uuid => $scan_drbd_resource_uuid}))
+			{
+				# Found, but not valid.
+				$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "error_0166", variables => { 
+					resource => $resource, 
+					file     => $resource_file, 
+					uuid     => $scan_drbd_resource_uuid,
+				}});
+				return('!!error!!');
+			}
+		}
+	}
+	
+	if ((not $scan_drbd_resource_uuid) && ($anvil->Validate->uuid({uuid => $new_resource_uuid})))
+	{
+		# Didn't find the resource UUID and we've been asked to add it.
+		my $injected            = 0;
+		my $new_resource_config = "";
+		foreach my $line (split/\n/, $resource_config)
+		{
+			$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { line => $line }});
+			if ($line =~ /^resource $resource /)
+			{
+				$injected                =  1;
+				$scan_drbd_resource_uuid =  $new_resource_uuid;
+				$new_resource_config     .= $line."\n";
+				$new_resource_config     .= $anvil->Words->string({key => "message_0189", variables => { uuid => $scan_drbd_resource_uuid }})."\n";
+				next;
+			}
+			$new_resource_config .= $line."\n";
+		}
+		
+		if ($injected)
+		{
+			my $error = $anvil->Storage->write_file({
+				debug     => $debug,
+				body      => $new_resource_config,
+				file      => $resource_file,
+				user      => "root",
+				group     => "root", 
+				mode      => "0644",
+				overwrite => 1,
+			});
+			$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { error => $error }});
+		}
+	}
+	
+	return($scan_drbd_resource_uuid);
+}
+
+
 =head2 update_global_common
 
 This configures C<< global_common.conf >> on the local host. Returns C<< !!error!! >> if there is a problem, C<< 0 >> if no update was needed and C<< 1 >> if a change was made.
diff --git a/notes b/notes
index 61adc6d9..ff8e3171 100644
--- a/notes
+++ b/notes
@@ -1102,3 +1102,27 @@ yum install kernel-2.6.32-754.27.1.el6.x86_64 kernel-devel-2.6.32-754.27.1.el6.x
 DRBD Notes;
 * c-max-rate is default 100M. Detect when the SN is 10Gbps and up to 750M
 * drbdsetup show <resource> --show-defaults <- shows defaults
+
+When a node comes online, and the peer and DR Host are both UpToDate, manually run the commands so that the 
+restarting node connects to the DR first, so that it will sync from DR and minimize IO load on the peer node.
+The sequence of commands needed to up a resource are exposed by 'drbdadm up -d <res>'. Ie:
+
+[root@el8-a01n02 ~]# drbdadm -d up srv02-hi
+drbdsetup new-resource srv02-hi 1 --auto-promote=yes
+drbdsetup new-minor srv02-hi 2 0
+drbdsetup new-peer srv02-hi 0 --_name=el8-a01n01 --allow-two-primaries=no --after-sb-0pri=discard-zero-changes --after-sb-1pri=discard-secondary --after-sb-2pri=disconnect --timeout=100 --protocol=C --fencing=resource-and-stonith
+drbdsetup new-peer srv02-hi 2 --_name=el8-a01dr01 --allow-two-primaries=no --after-sb-0pri=discard-zero-changes --after-sb-1pri=discard-secondary --after-sb-2pri=disconnect --timeout=100 --protocol=A --fencing=dont-care
+drbdsetup new-path srv02-hi 0 ipv4:10.101.10.2:7791 ipv4:10.101.10.1:7791
+drbdsetup new-path srv02-hi 2 ipv4:10.101.10.2:7793 ipv4:10.101.10.3:7793
+drbdmeta 2 v09 /dev/node_8da3d2fe/srv02-hi_0 internal apply-al
+drbdsetup attach 2 /dev/node_8da3d2fe/srv02-hi_0 /dev/node_8da3d2fe/srv02-hi_0 internal --disk-flushes=no --md-flushes=no
+drbdsetup connect srv02-hi 0
+drbdsetup connect srv02-hi 2
+
+Manual split brain recovery;
+# Both nodes;
+drbdadm disconnect <res>
+# Node to discard;
+drbdadm connect --discard-my-data <res>
+# Node to save data on;
+drbdadm connect <res>
diff --git a/scancore-agents/scan-drbd/scan-drbd b/scancore-agents/scan-drbd/scan-drbd
index a6abac53..cfa31827 100755
--- a/scancore-agents/scan-drbd/scan-drbd
+++ b/scancore-agents/scan-drbd/scan-drbd
@@ -19,6 +19,7 @@ use strict;
 use warnings;
 use Anvil::Tools;
 use Data::Dumper;
+use Text::Diff;
 
 # Disable buffering
 $| = 1;
@@ -41,6 +42,8 @@ $anvil->Log->secure({set => 1});
 $anvil->data->{'scan-drbd'} = {
 	resource_status		=>	"/sys/kernel/debug/drbd/resources",
 	config_directory	=>	"/etc/drbd.d",
+	alert_sort		=>	2,
+	queries                 =>	[],
 };
 
 # Make sure we're running as 'root'
@@ -94,6 +97,8 @@ if (not gather_data($anvil))
 	$anvil->nice_exit({exit_code => 2});
 }
 
+read_last_scan($anvil);
+
 find_changes($anvil);
 
 
@@ -108,6 +113,448 @@ $anvil->nice_exit({exit_code => 0});
 # Functions                                                                                                 #
 #############################################################################################################
 
+# This reads in the last scan's data.
+sub read_last_scan
+{
+	my ($anvil) = @_;
+	
+	# This is used to determine if there's an entry in scan_drbd directly.
+	$anvil->data->{old}{scan_drbd_uuid} = "";
+	
+	# This calls up the entry for this host. There will only be one.
+	my $query = "
+SELECT 
+    scan_drbd_uuid, 
+    scan_drbd_common_xml, 
+    scan_drbd_flush_disk, 
+    scan_drbd_flush_md, 
+    scan_drbd_timeout, 
+    scan_drbd_total_sync_speed 
+FROM 
+    scan_drbd 
+WHERE 
+    scan_drbd_host_uuid = ".$anvil->Database->quote($anvil->Get->host_uuid)." 
+;";
+	$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }});
+	
+	my $results = $anvil->Database->query({query => $query, source => $THIS_FILE, line => __LINE__});
+	my $count   = @{$results};
+	$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { 
+		results => $results, 
+		count   => $count, 
+	}});
+	foreach my $row (@{$results})
+	{
+		# We've got an entry in the 'scan_drbd' table, so now we'll look for data in the node and 
+		# services tables.
+		my $scan_drbd_uuid = $row->[0]; 
+		$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { scan_drbd_uuid => $scan_drbd_uuid }});
+		
+		# Store the old data now.
+		$anvil->data->{old}{scan_drbd}{scan_drbd_uuid}{$scan_drbd_uuid}{scan_drbd_common_xml}       = $row->[1];
+		$anvil->data->{old}{scan_drbd}{scan_drbd_uuid}{$scan_drbd_uuid}{scan_drbd_flush_disk}       = $row->[2];
+		$anvil->data->{old}{scan_drbd}{scan_drbd_uuid}{$scan_drbd_uuid}{scan_drbd_flush_md}         = $row->[3];
+		$anvil->data->{old}{scan_drbd}{scan_drbd_uuid}{$scan_drbd_uuid}{scan_drbd_timeout}          = $row->[4];
+		$anvil->data->{old}{scan_drbd}{scan_drbd_uuid}{$scan_drbd_uuid}{scan_drbd_total_sync_speed} = $row->[5];
+		$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { 
+			"old::scan_drbd::scan_drbd_uuid::${scan_drbd_uuid}::scan_drbd_common_xml"       => $anvil->data->{old}{scan_drbd}{scan_drbd_uuid}{$scan_drbd_uuid}{scan_drbd_common_xml},
+			"old::scan_drbd::scan_drbd_uuid::${scan_drbd_uuid}::scan_drbd_flush_disk"       => $anvil->data->{old}{scan_drbd}{scan_drbd_uuid}{$scan_drbd_uuid}{scan_drbd_flush_disk},
+			"old::scan_drbd::scan_drbd_uuid::${scan_drbd_uuid}::scan_drbd_flush_md"         => $anvil->data->{old}{scan_drbd}{scan_drbd_uuid}{$scan_drbd_uuid}{scan_drbd_flush_md},
+			"old::scan_drbd::scan_drbd_uuid::${scan_drbd_uuid}::scan_drbd_timeout"          => $anvil->data->{old}{scan_drbd}{scan_drbd_uuid}{$scan_drbd_uuid}{scan_drbd_timeout},
+			"old::scan_drbd::scan_drbd_uuid::${scan_drbd_uuid}::scan_drbd_total_sync_speed" => $anvil->data->{old}{scan_drbd}{scan_drbd_uuid}{$scan_drbd_uuid}{scan_drbd_total_sync_speed},
+		}});
+		
+		# Record the drbd_uuid in an easy to find place for later when looking for changes.
+		$anvil->data->{old}{scan_drbd_uuid} = $scan_drbd_uuid;
+		$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "old::scan_drbd_uuid" => $anvil->data->{old}{scan_drbd_uuid} }});
+	}
+	undef $count;
+	undef $results;
+	
+	# Read in the RAM module data.
+	$query = "
+SELECT 
+    scan_drbd_resource_uuid, 
+    scan_drbd_resource_name, 
+    scan_drbd_resource_up, 
+    scan_drbd_resource_xml
+FROM 
+    scan_drbd_resources 
+WHERE 
+    scan_drbd_resource_host_uuid = ".$anvil->Database->quote($anvil->Get->host_uuid)." 
+;";
+	$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }});
+	
+	$results = $anvil->Database->query({query => $query, source => $THIS_FILE, line => __LINE__});
+	$count   = @{$results};
+	$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { 
+		results => $results, 
+		count   => $count, 
+	}});
+	foreach my $row (@{$results})
+	{
+		# We've got an entry in the 'scan_drbd_resources' table, so now we'll look for data in the node and 
+		# services tables.
+		my $scan_drbd_resource_uuid = $row->[0]; 
+		my $scan_drbd_resource_name = $row->[1]; 
+		$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { 
+			scan_drbd_resource_uuid => $scan_drbd_resource_uuid,
+			scan_drbd_resource_name => $scan_drbd_resource_name,
+		}});
+		
+		# Store the old data now.
+		$anvil->data->{old}{scan_drbd_resource}{scan_drbd_resource_uuid}{$scan_drbd_resource_uuid}{scan_drbd_resource_name} = $scan_drbd_resource_name;
+		$anvil->data->{old}{scan_drbd_resource}{scan_drbd_resource_uuid}{$scan_drbd_resource_uuid}{scan_drbd_resource_up}   = $row->[2];
+		$anvil->data->{old}{scan_drbd_resource}{scan_drbd_resource_uuid}{$scan_drbd_resource_uuid}{scan_drbd_resource_xml}  = $row->[3];
+		$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { 
+			"old::scan_drbd_resource::scan_drbd_resource_uuid::${scan_drbd_resource_uuid}::scan_drbd_resource_name" => $anvil->data->{old}{scan_drbd_resource}{scan_drbd_resource_uuid}{$scan_drbd_resource_uuid}{scan_drbd_resource_name},
+			"old::scan_drbd_resource::scan_drbd_resource_uuid::${scan_drbd_resource_uuid}::scan_drbd_resource_up"   => $anvil->data->{old}{scan_drbd_resource}{scan_drbd_resource_uuid}{$scan_drbd_resource_uuid}{scan_drbd_resource_up},
+			"old::scan_drbd_resource::scan_drbd_resource_uuid::${scan_drbd_resource_uuid}::scan_drbd_resource_xml"  => $anvil->data->{old}{scan_drbd_resource}{scan_drbd_resource_uuid}{$scan_drbd_resource_uuid}{scan_drbd_resource_xml},
+		}});
+		
+		# Record the scan_drbd_resource_uuid in an easy to find place for later when looking for changes.
+		$anvil->data->{old}{resource_to_uuid}{$scan_drbd_resource_name}{uuid} = $scan_drbd_resource_uuid;
+		$anvil->data->{old}{uuid_to_resource}{$scan_drbd_resource_uuid}{name} = $scan_drbd_resource_name;
+		$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { 
+			"old::resource_to_uuid::${scan_drbd_resource_name}::uuid" => $anvil->data->{old}{resource_to_uuid}{$scan_drbd_resource_name}{uuid}, 
+			"old::uuid_to_resource::${scan_drbd_resource_uuid}::name" => $anvil->data->{old}{uuid_to_resource}{$scan_drbd_resource_uuid}{name}, 
+		}});
+	}
+	undef $count;
+	undef $results;
+	
+	# Read in the RAM module data.
+	$query = "
+SELECT 
+    scan_drbd_volume_uuid, 
+    scan_drbd_volume_scan_drbd_resource_uuid, 
+    scan_drbd_volume_number, 
+    scan_drbd_volume_device_path, 
+    scan_drbd_volume_device_minor, 
+    scan_drbd_volume_size
+FROM 
+    scan_drbd_volumes 
+WHERE 
+    scan_drbd_volume_host_uuid = ".$anvil->Database->quote($anvil->Get->host_uuid)." 
+;";
+	$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }});
+	
+	$results = $anvil->Database->query({query => $query, source => $THIS_FILE, line => __LINE__});
+	$count   = @{$results};
+	$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { 
+		results => $results, 
+		count   => $count, 
+	}});
+	foreach my $row (@{$results})
+	{
+		# We've got an entry in the 'scan_drbd_volumes' table, so now we'll look for data in the node and 
+		# services tables.
+		my $scan_drbd_volume_uuid                    = $row->[0]; 
+		my $scan_drbd_volume_scan_drbd_resource_uuid = $row->[1]; 
+		my $scan_drbd_volume_number                  = $row->[2];
+		$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { 
+			scan_drbd_volume_uuid                    => $scan_drbd_volume_uuid,
+			scan_drbd_volume_scan_drbd_resource_uuid => $scan_drbd_volume_scan_drbd_resource_uuid,
+			scan_drbd_volume_number                  => $scan_drbd_volume_number, 
+		}});
+		
+		# Store the old data now.
+		$anvil->data->{old}{scan_drbd_volume}{scan_drbd_volume_uuid}{$scan_drbd_volume_uuid}{scan_drbd_volume_device_path}  = $row->[3];
+		$anvil->data->{old}{scan_drbd_volume}{scan_drbd_volume_uuid}{$scan_drbd_volume_uuid}{scan_drbd_volume_device_minor} = $row->[4];
+		$anvil->data->{old}{scan_drbd_volume}{scan_drbd_volume_uuid}{$scan_drbd_volume_uuid}{scan_drbd_volume_size}         = $row->[5];
+		$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { 
+			"old::scan_drbd_volume::scan_drbd_volume_uuid::${scan_drbd_volume_uuid}::scan_drbd_volume_device_path"  => $anvil->data->{old}{scan_drbd_volume}{scan_drbd_volume_uuid}{$scan_drbd_volume_uuid}{scan_drbd_volume_device_path},
+			"old::scan_drbd_volume::scan_drbd_volume_uuid::${scan_drbd_volume_uuid}::scan_drbd_volume_device_minor" => $anvil->data->{old}{scan_drbd_volume}{scan_drbd_volume_uuid}{$scan_drbd_volume_uuid}{scan_drbd_volume_device_minor},
+			"old::scan_drbd_volume::scan_drbd_volume_uuid::${scan_drbd_volume_uuid}::scan_drbd_volume_xml"          => $anvil->data->{old}{scan_drbd_volume}{scan_drbd_volume_uuid}{$scan_drbd_volume_uuid}{scan_drbd_volume_size}." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $anvil->data->{old}{scan_drbd_volume}{scan_drbd_volume_uuid}{$scan_drbd_volume_uuid}{scan_drbd_volume_size}}).")",
+		}});
+		
+		# Record the scan_drbd_volume_uuid in an easy to find place for later when looking for changes.
+		$anvil->data->{old}{resource_to_uuid}{$scan_drbd_resource_name}{volume}{$scan_drbd_volume_number}{uuid}                = $scan_drbd_volume_uuid;
+		$anvil->data->{old}{uuid_to_volume}{$scan_drbd_volume_scan_drbd_resource_uuid}{volume}{$scan_drbd_volume_uuid}{number} = $scan_drbd_volume_number;
+		$anvil->data->{old}{volume_to_uuid}{$scan_drbd_volume_uuid}{number}                                                    = $scan_drbd_volume_number;
+		$anvil->data->{old}{volume_to_uuid}{$scan_drbd_volume_uuid}{on_resource}                                               = $scan_drbd_volume_scan_drbd_resource_uuid;
+		$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { 
+			"old::resource_to_uuid::${scan_drbd_resource_name}::volume::${scan_drbd_volume_number}::uuid"                => $anvil->data->{old}{resource_to_uuid}{$scan_drbd_resource_name}{volume}{$scan_drbd_volume_number}{uuid}, 
+			"old::uuid_to_volume::${scan_drbd_volume_scan_drbd_resource_uuid}::volume::${scan_drbd_volume_uuid}::number" => $anvil->data->{old}{uuid_to_volume}{$scan_drbd_volume_scan_drbd_resource_uuid}{volume}{$scan_drbd_volume_uuid}{number}, 
+			"old::volume_to_uuid::${scan_drbd_volume_uuid}::number"                                                      => $anvil->data->{old}{volume_to_uuid}{$scan_drbd_volume_uuid}{number}, 
+			"old::volume_to_uuid::${scan_drbd_volume_uuid}::on_resource"                                                 => $anvil->data->{old}{volume_to_uuid}{$scan_drbd_volume_uuid}{on_resource}, 
+		}});
+	}
+	undef $count;
+	undef $results;
+	
+	# Read in the RAM module data.
+	$query = "
+SELECT 
+    scan_drbd_peer_uuid, 
+    scan_drbd_peer_scan_drbd_volume_uuid, 
+    scan_drbd_peer_host_name, 
+    scan_drbd_peer_connection_state, 
+    scan_drbd_peer_local_disk_state, 
+    scan_drbd_peer_disk_state, 
+    scan_drbd_peer_local_role, 
+    scan_drbd_peer_role, 
+    scan_drbd_peer_out_of_sync_size, 
+    scan_drbd_peer_replication_speed, 
+    scan_drbd_peer_estimated_time_to_sync, 
+    scan_drbd_peer_ip_address, 
+    scan_drbd_peer_tcp_port, 
+    scan_drbd_peer_protocol, 
+    scan_drbd_peer_fencing 
+FROM 
+    scan_drbd_peers 
+WHERE 
+    scan_drbd_peer_host_uuid = ".$anvil->Database->quote($anvil->Get->host_uuid)." 
+;";
+	$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }});
+	
+	$results = $anvil->Database->query({query => $query, source => $THIS_FILE, line => __LINE__});
+	$count   = @{$results};
+	$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { 
+		results => $results, 
+		count   => $count, 
+	}});
+	foreach my $row (@{$results})
+	{
+		# We've got an entry in the 'scan_drbd_peers' table, so now we'll look for data in the node and 
+		# services tables.
+		my $scan_drbd_peer_uuid                  = $row->[0]; 
+		my $scan_drbd_peer_scan_drbd_volume_uuid = $row->[1]; 
+		my $scan_drbd_peer_host_name             = $row->[2];
+		$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { 
+			scan_drbd_peer_uuid                  => $scan_drbd_peer_uuid,
+			scan_drbd_peer_scan_drbd_volume_uuid => $scan_drbd_peer_scan_drbd_volume_uuid,
+			scan_drbd_peer_host_name             => $scan_drbd_peer_host_name, 
+		}});
+		
+		# Store the old data now.
+		$anvil->data->{old}{scan_drbd_peer}{scan_drbd_peer_uuid}{$scan_drbd_peer_uuid}{scan_drbd_peer_scan_drbd_volume_uuid}  = $scan_drbd_peer_scan_drbd_volume_uuid;
+		$anvil->data->{old}{scan_drbd_peer}{scan_drbd_peer_uuid}{$scan_drbd_peer_uuid}{scan_drbd_peer_host_name}              = $scan_drbd_peer_host_name;
+		$anvil->data->{old}{scan_drbd_peer}{scan_drbd_peer_uuid}{$scan_drbd_peer_uuid}{scan_drbd_peer_connection_state}       = $row->[3];
+		$anvil->data->{old}{scan_drbd_peer}{scan_drbd_peer_uuid}{$scan_drbd_peer_uuid}{scan_drbd_peer_local_disk_state}       = $row->[4];
+		$anvil->data->{old}{scan_drbd_peer}{scan_drbd_peer_uuid}{$scan_drbd_peer_uuid}{scan_drbd_peer_disk_state}             = $row->[5];
+		$anvil->data->{old}{scan_drbd_peer}{scan_drbd_peer_uuid}{$scan_drbd_peer_uuid}{scan_drbd_peer_local_role}             = $row->[6];
+		$anvil->data->{old}{scan_drbd_peer}{scan_drbd_peer_uuid}{$scan_drbd_peer_uuid}{scan_drbd_peer_role}                   = $row->[7];
+		$anvil->data->{old}{scan_drbd_peer}{scan_drbd_peer_uuid}{$scan_drbd_peer_uuid}{scan_drbd_peer_out_of_sync_size}       = $row->[8];
+		$anvil->data->{old}{scan_drbd_peer}{scan_drbd_peer_uuid}{$scan_drbd_peer_uuid}{scan_drbd_peer_replication_speed}      = $row->[9];
+		$anvil->data->{old}{scan_drbd_peer}{scan_drbd_peer_uuid}{$scan_drbd_peer_uuid}{scan_drbd_peer_estimated_time_to_sync} = $row->[10];
+		$anvil->data->{old}{scan_drbd_peer}{scan_drbd_peer_uuid}{$scan_drbd_peer_uuid}{scan_drbd_peer_ip_address}             = $row->[11];
+		$anvil->data->{old}{scan_drbd_peer}{scan_drbd_peer_uuid}{$scan_drbd_peer_uuid}{scan_drbd_peer_tcp_port}               = $row->[12];
+		$anvil->data->{old}{scan_drbd_peer}{scan_drbd_peer_uuid}{$scan_drbd_peer_uuid}{scan_drbd_peer_protocol}               = $row->[13];
+		$anvil->data->{old}{scan_drbd_peer}{scan_drbd_peer_uuid}{$scan_drbd_peer_uuid}{scan_drbd_peer_fencing}                = $row->[14];
+		$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { 
+			"old::scan_drbd_peer::scan_drbd_peer_uuid::${scan_drbd_peer_uuid}::scan_drbd_peer_scan_drbd_volume_uuid"  => $anvil->data->{old}{scan_drbd_peer}{scan_drbd_peer_uuid}{$scan_drbd_peer_uuid}{scan_drbd_peer_scan_drbd_volume_uuid},
+			"old::scan_drbd_peer::scan_drbd_peer_uuid::${scan_drbd_peer_uuid}::scan_drbd_peer_host_name"              => $anvil->data->{old}{scan_drbd_peer}{scan_drbd_peer_uuid}{$scan_drbd_peer_uuid}{scan_drbd_peer_host_name},
+			"old::scan_drbd_peer::scan_drbd_peer_uuid::${scan_drbd_peer_uuid}::scan_drbd_peer_connection_state"       => $anvil->data->{old}{scan_drbd_peer}{scan_drbd_peer_uuid}{$scan_drbd_peer_uuid}{scan_drbd_peer_connection_state},
+			"old::scan_drbd_peer::scan_drbd_peer_uuid::${scan_drbd_peer_uuid}::scan_drbd_peer_local_disk_state"       => $anvil->data->{old}{scan_drbd_peer}{scan_drbd_peer_uuid}{$scan_drbd_peer_uuid}{scan_drbd_peer_local_disk_state},
+			"old::scan_drbd_peer::scan_drbd_peer_uuid::${scan_drbd_peer_uuid}::scan_drbd_peer_role"                   => $anvil->data->{old}{scan_drbd_peer}{scan_drbd_peer_uuid}{$scan_drbd_peer_uuid}{scan_drbd_peer_role},
+			"old::scan_drbd_peer::scan_drbd_peer_uuid::${scan_drbd_peer_uuid}::scan_drbd_peer_disk_state"             => $anvil->data->{old}{scan_drbd_peer}{scan_drbd_peer_uuid}{$scan_drbd_peer_uuid}{scan_drbd_peer_disk_state},
+			"old::scan_drbd_peer::scan_drbd_peer_uuid::${scan_drbd_peer_uuid}::scan_drbd_peer_local_role"             => $anvil->data->{old}{scan_drbd_peer}{scan_drbd_peer_uuid}{$scan_drbd_peer_uuid}{scan_drbd_peer_local_role},
+			"old::scan_drbd_peer::scan_drbd_peer_uuid::${scan_drbd_peer_uuid}::scan_drbd_peer_role"                   => $anvil->data->{old}{scan_drbd_peer}{scan_drbd_peer_uuid}{$scan_drbd_peer_uuid}{scan_drbd_peer_role},
+			"old::scan_drbd_peer::scan_drbd_peer_uuid::${scan_drbd_peer_uuid}::scan_drbd_peer_out_of_sync_size"       => $anvil->data->{old}{scan_drbd_peer}{scan_drbd_peer_uuid}{$scan_drbd_peer_uuid}{scan_drbd_peer_out_of_sync_size}." ("..")",
+			"old::scan_drbd_peer::scan_drbd_peer_uuid::${scan_drbd_peer_uuid}::scan_drbd_peer_replication_speed"      => $anvil->data->{old}{scan_drbd_peer}{scan_drbd_peer_uuid}{$scan_drbd_peer_uuid}{scan_drbd_peer_replication_speed}." ("..")",
+			"old::scan_drbd_peer::scan_drbd_peer_uuid::${scan_drbd_peer_uuid}::scan_drbd_peer_estimated_time_to_sync" => $anvil->data->{old}{scan_drbd_peer}{scan_drbd_peer_uuid}{$scan_drbd_peer_uuid}{scan_drbd_peer_estimated_time_to_sync}." ("..")",
+			"old::scan_drbd_peer::scan_drbd_peer_uuid::${scan_drbd_peer_uuid}::scan_drbd_peer_ip_address"             => $anvil->data->{old}{scan_drbd_peer}{scan_drbd_peer_uuid}{$scan_drbd_peer_uuid}{scan_drbd_peer_ip_address},
+			"old::scan_drbd_peer::scan_drbd_peer_uuid::${scan_drbd_peer_uuid}::scan_drbd_peer_tcp_port"               => $anvil->data->{old}{scan_drbd_peer}{scan_drbd_peer_uuid}{$scan_drbd_peer_uuid}{scan_drbd_peer_tcp_port},
+			"old::scan_drbd_peer::scan_drbd_peer_uuid::${scan_drbd_peer_uuid}::scan_drbd_peer_protocol"               => $anvil->data->{old}{scan_drbd_peer}{scan_drbd_peer_uuid}{$scan_drbd_peer_uuid}{scan_drbd_peer_protocol},
+			"old::scan_drbd_peer::scan_drbd_peer_uuid::${scan_drbd_peer_uuid}::scan_drbd_peer_fencing"                => $anvil->data->{old}{scan_drbd_peer}{scan_drbd_peer_uuid}{$scan_drbd_peer_uuid}{scan_drbd_peer_fencing},
+		}});
+		
+		# Record the scan_drbd_peer_uuid in an easy to find place for later when looking for changes.
+		my $volume_number    = $anvil->data->{old}{volume_to_uuid}{$scan_drbd_peer_scan_drbd_volume_uuid}{number};
+		my $on_resource_uuid = $anvil->data->{old}{volume_to_uuid}{$scan_drbd_peer_scan_drbd_volume_uuid}{on_resource};
+		my $on_resource_name = $anvil->data->{old}{uuid_to_resource}{$scan_drbd_resource_uuid}{name};
+		$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { 
+			volume_number    => $volume_number,
+			on_resource_uuid => $on_resource_uuid, 
+			on_resource_name => $on_resource_name, 
+		}});
+		
+		$anvil->data->{old}{resource_to_uuid}{$on_resource_name}{volume}{$volume_number}{peer}{$scan_drbd_peer_host_name}{uuid} = $scan_drbd_peer_uuid;
+		$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { 
+			"old::resource_to_uuid::${scan_drbd_resource_name}::volume::${volume_number}::peer::${scan_drbd_peer_host_name}::uuid" => $anvil->data->{old}{resource_to_uuid}{$scan_drbd_resource_name}{volume}{$volume_number}{peer}{$scan_drbd_peer_host_name}{uuid}, 
+		}});
+	}
+	
+	return(0);
+}
+
+sub process_drbd
+{
+	my ($anvil) = @_;
+	
+	if ($anvil->data->{old}{scan_drbd_uuid})
+	{
+		# Existing, any changes?
+		my $scan_drbd_uuid                 = $anvil->data->{old}{scan_drbd_uuid};
+		my $new_scan_drbd_common_xml       = $anvil->data->{new}{scan_drbd}{scan_drbd_common_xml};
+		my $old_scan_drbd_common_xml       = $anvil->data->{old}{scan_drbd}{scan_drbd_uuid}{$scan_drbd_uuid}{scan_drbd_common_xml};
+		my $scan_drbd_common_xml_diff      = diff \$old_scan_drbd_common_xml, \$new_scan_drbd_common_xml, { STYLE => 'Unified' },
+		my $new_scan_drbd_flush_disk       = $anvil->data->{new}{scan_drbd}{scan_drbd_flush_disk};
+		my $old_scan_drbd_flush_disk       = $anvil->data->{old}{scan_drbd}{scan_drbd_uuid}{$scan_drbd_uuid}{scan_drbd_flush_disk};
+		my $new_scan_drbd_flush_md         = $anvil->data->{new}{scan_drbd}{scan_drbd_flush_md};
+		my $old_scan_drbd_flush_md         = $anvil->data->{old}{scan_drbd}{scan_drbd_uuid}{$scan_drbd_uuid}{scan_drbd_flush_md};
+		my $new_scan_drbd_timeout          = $anvil->data->{new}{scan_drbd}{scan_drbd_timeout};
+		my $old_scan_drbd_timeout          = $anvil->data->{old}{scan_drbd}{scan_drbd_uuid}{$scan_drbd_uuid}{scan_drbd_timeout};
+		my $new_scan_drbd_total_sync_speed = $anvil->data->{new}{scan_drbd}{scan_drbd_total_sync_speed};
+		my $old_scan_drbd_total_sync_speed = $anvil->data->{old}{scan_drbd}{scan_drbd_uuid}{$scan_drbd_uuid}{scan_drbd_total_sync_speed};
+		$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
+			"s1:new_scan_drbd_common_xml" => $new_scan_drbd_common_xml, 
+			"s2:old_scan_drbd_common_xml" => $old_scan_drbd_common_xml, 
+		}});
+		$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
+			"s01:scan_drbd_uuid"                 => $new_scan_drbd_flush_disk, 
+			"s02:scan_drbd_common_xml_diff"      => $new_scan_drbd_flush_md, 
+			"s03:new_scan_drbd_flush_disk"       => $new_scan_drbd_flush_disk, 
+			"s04:old_scan_drbd_flush_disk"       => $old_scan_drbd_flush_disk, 
+			"s05:new_scan_drbd_flush_md"         => $new_scan_drbd_flush_md, 
+			"s06:old_scan_drbd_flush_md"         => $old_scan_drbd_flush_md, 
+			"s07:new_scan_drbd_timeout"          => $new_scan_drbd_timeout, 
+			"s08:old_scan_drbd_timeout"          => $old_scan_drbd_timeout, 
+			"s09:new_scan_drbd_total_sync_speed" => $new_scan_drbd_total_sync_speed." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $new_scan_drbd_total_sync_speed})."/s)", 
+			"s10:old_scan_drbd_total_sync_speed" => $old_scan_drbd_total_sync_speed." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $old_scan_drbd_total_sync_speed})."/s)", 
+		}});
+		
+		my $update = 0;
+		if ($new_scan_drbd_flush_disk ne $old_scan_drbd_flush_disk)
+		{
+			   $update    = 1;
+			my $variables = {
+				old_value => $new_scan_drbd_flush_disk ? "#!string!scan_drbd_unit_0001!#" : "#!string!scan_drbd_unit_0002!#", 
+				new_value => $old_scan_drbd_flush_disk ? "#!string!scan_drbd_unit_0001!#" : "#!string!scan_drbd_unit_0002!#", 
+			};
+			$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "scan_drbd_message_0002", variables => $variables});
+			$anvil->Alert->register({alert_level => "notice", message => "scan_drbd_message_0002", variables => $variables, set_by => $THIS_FILE, sort_position => $anvil->data->{'scan-drbd'}{alert_sort}++});
+			
+		}
+		if ($new_scan_drbd_flush_md ne $old_scan_drbd_flush_md)
+		{
+			   $update    = 1;
+			my $variables = {
+				old_value => $new_scan_drbd_flush_md ? "#!string!scan_drbd_unit_0001!#" : "#!string!scan_drbd_unit_0002!#", 
+				new_value => $old_scan_drbd_flush_md ? "#!string!scan_drbd_unit_0001!#" : "#!string!scan_drbd_unit_0002!#", 
+			};
+			$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "scan_drbd_message_0003", variables => $variables});
+			$anvil->Alert->register({alert_level => "notice", message => "scan_drbd_message_0003", variables => $variables, set_by => $THIS_FILE, sort_position => $anvil->data->{'scan-drbd'}{alert_sort}++});
+			
+		}
+		if ($new_scan_drbd_timeout ne $old_scan_drbd_timeout)
+		{
+			   $update    = 1;
+			my $variables = {
+				old_value => $new_scan_drbd_timeout, 
+				new_value => $old_scan_drbd_timeout, 
+			};
+			$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "scan_drbd_message_0004", variables => $variables});
+			$anvil->Alert->register({alert_level => "notice", message => "scan_drbd_message_0004", variables => $variables, set_by => $THIS_FILE, sort_position => $anvil->data->{'scan-drbd'}{alert_sort}++});
+			
+		}
+		if ($new_scan_drbd_total_sync_speed ne $old_scan_drbd_total_sync_speed)
+		{
+			# This changes _constantly_ during a resync, so it's info-level.
+			   $update    = 1;
+			my $variables = {
+				old_value => $anvil->Convert->bytes_to_human_readable({'bytes' => $new_scan_drbd_total_sync_speed}), 
+				new_value => $anvil->Convert->bytes_to_human_readable({'bytes' => $old_scan_drbd_total_sync_speed}), 
+			};
+			$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "scan_drbd_message_0005", variables => $variables});
+			$anvil->Alert->register({alert_level => "info", message => "scan_drbd_message_0005", variables => $variables, set_by => $THIS_FILE, sort_position => $anvil->data->{'scan-drbd'}{alert_sort}++});
+			
+		}
+		if ($scan_drbd_common_xml_diff)
+		{
+			   $update    = 1;
+			my $variables = {
+				difference => $scan_drbd_common_xml_diff, 
+				new_config => $new_scan_drbd_common_xml, 
+			};
+			$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "scan_drbd_message_0006", variables => $variables});
+			$anvil->Alert->register({alert_level => "notice", message => "scan_drbd_message_0006", variables => $variables, set_by => $THIS_FILE, sort_position => $anvil->data->{'scan-drbd'}{alert_sort}++});
+		}
+		
+		if ($update)
+		{
+			# UPDATE!
+			my $query = "
+UPDATE 
+    scan_drbd 
+SET
+    scan_drbd_common_xml       = ".$anvil->Database->quote($new_scan_drbd_common_xml).", 
+    scan_drbd_flush_disk       = ".$anvil->Database->quote($new_scan_drbd_flush_disk).", 
+    scan_drbd_flush_md         = ".$anvil->Database->quote($new_scan_drbd_flush_md).", 
+    scan_drbd_timeout          = ".$anvil->Database->quote($new_scan_drbd_timeout).", 
+    scan_drbd_total_sync_speed = ".$anvil->Database->quote($new_scan_drbd_total_sync_speed).", 
+    modified_date              = ".$anvil->Database->quote($anvil->data->{sys}{database}{timestamp})." 
+WHERE 
+    scan_drbd_uuid             = ".$anvil->Database->quote($scan_drbd_uuid)."
+;
+";
+			$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }});
+			$anvil->Database->write({query => $query, source => $THIS_FILE, line => __LINE__});
+		}
+	}
+	else
+	{
+		# New, INSERT.
+		my $scan_drbd_uuid                 = $anvil->Get->uuid();
+		my $new_scan_drbd_common_xml       = $anvil->data->{new}{scan_drbd}{scan_drbd_common_xml};
+		my $new_scan_drbd_flush_disk       = $anvil->data->{new}{scan_drbd}{scan_drbd_flush_disk};
+		my $new_scan_drbd_flush_md         = $anvil->data->{new}{scan_drbd}{scan_drbd_flush_md};
+		my $new_scan_drbd_timeout          = $anvil->data->{new}{scan_drbd}{scan_drbd_timeout};
+		my $new_scan_drbd_total_sync_speed = $anvil->data->{new}{scan_drbd}{scan_drbd_total_sync_speed};
+		my $say_scan_drbd_total_sync_speed = $anvil->Convert->bytes_to_human_readable({'bytes' => $anvil->data->{new}{scan_drbd}{scan_drbd_total_sync_speed}})."/#!string!scan_drbd_unit_0003!#";
+		$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
+			"s1:scan_drbd_uuid"                 => $scan_drbd_uuid, 
+			"s2:new_scan_drbd_flush_disk"       => $new_scan_drbd_flush_disk, 
+			"s3:new_scan_drbd_flush_md"         => $new_scan_drbd_flush_md, 
+			"s4:new_scan_drbd_timeout"          => $new_scan_drbd_timeout, 
+			"s5:new_scan_drbd_total_sync_speed" => $new_scan_drbd_total_sync_speed, 
+			"s6:say_scan_drbd_total_sync_speed" => $say_scan_drbd_total_sync_speed, 
+			"s7:new_scan_drbd_common_xml"       => $new_scan_drbd_common_xml, 
+		}});
+		
+		$anvil->data->{old}{scan_drbd_uuid} = $scan_drbd_uuid;
+		
+		my $variables = {
+			new_scan_drbd_flush_disk       => $new_scan_drbd_flush_disk ? "#!string!scan_drbd_unit_0001!#" : "#!string!scan_drbd_unit_0002!#", 
+			new_scan_drbd_flush_md         => $new_scan_drbd_flush_md   ? "#!string!scan_drbd_unit_0001!#" : "#!string!scan_drbd_unit_0002!#", 
+			new_scan_drbd_timeout          => $new_scan_drbd_timeout, 
+			say_scan_drbd_total_sync_speed => $say_scan_drbd_total_sync_speed, 
+			new_scan_drbd_common_xml       => $new_scan_drbd_common_xml, 
+		};
+		$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_drbd_message_0001", variables => $variables});
+		$anvil->Alert->register({alert_level => "warning", message => "scan_drbd_message_0001", variables => $variables, set_by => $THIS_FILE, sort_position => $anvil->data->{'scan-drbd'}{alert_sort}++});
+		
+		my $query = "
+INSERT INTO 
+    scan_drbd
+(
+    scan_drbd_uuid, 
+    scan_drbd_host_uuid, 
+    scan_drbd_common_xml, 
+    scan_drbd_flush_disk, 
+    scan_drbd_flush_md, 
+    scan_drbd_timeout, 
+    scan_drbd_total_sync_speed, 
+    modified_date
+) VALUES (
+    ".$anvil->Database->quote($scan_drbd_uuid).", 
+    ".$anvil->Database->quote($anvil->Get->host_uuid).", 
+    ".$anvil->Database->quote($new_scan_drbd_common_xml).", 
+    ".$anvil->Database->quote($new_scan_drbd_flush_disk).", 
+    ".$anvil->Database->quote($new_scan_drbd_flush_md).", 
+    ".$anvil->Database->quote($new_scan_drbd_timeout).", 
+    ".$anvil->Database->quote($new_scan_drbd_total_sync_speed).", 
+    ".$anvil->Database->quote($anvil->data->{sys}{database}{timestamp})."
+);";
+		# Now record the query in the array
+		$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }});
+		$anvil->Database->write({query => $query, source => $THIS_FILE, line => __LINE__});
+	}
+	
+	return(0);
+}
+
 sub find_changes
 {
 	my ($anvil) = @_;
@@ -126,15 +573,19 @@ sub find_changes
 		"s5:new_scan_drbd_common_xml"       => $new_scan_drbd_common_xml, 
 	}});
 	
+	process_scan_drbd($anvil);
+	
 	foreach my $resource (sort {$a cmp $b} keys %{$anvil->data->{new}{resource}})
 	{
+		my $scan_drbd_resource_uuid    = $anvil->data->{new}{resource}{$resource}{scan_drbd_resource_uuid};
 		my $scan_drbd_resource_name    = $resource; 
 		my $new_scan_drbd_resource_up  = $anvil->data->{new}{resource}{$resource}{up};
 		my $new_scan_drbd_resource_xml = $anvil->data->{new}{resource}{$resource}{xml};
 		$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
-			"s1:scan_drbd_resource_name"    => $new_scan_drbd_flush_disk, 
-			"s2:new_scan_drbd_resource_up"  => $new_scan_drbd_flush_md, 
-			"s3:new_scan_drbd_resource_xml" => $new_scan_drbd_resource_xml, 
+			"s1:scan_drbd_resource_uuid"    => $scan_drbd_resource_uuid, 
+			"s2:scan_drbd_resource_name"    => $new_scan_drbd_flush_disk, 
+			"s3:new_scan_drbd_resource_up"  => $new_scan_drbd_flush_md, 
+			"s4:new_scan_drbd_resource_xml" => $new_scan_drbd_resource_xml, 
 		}});
 
 		foreach my $volume (sort {$a cmp $b} keys %{$anvil->data->{new}{resource}{$resource}{volume}})
@@ -298,12 +749,25 @@ sub gather_data
 					's2:conf_file' => $conf_file,
 				}});
 				
-				$anvil->data->{new}{resource}{$resource}{xml} = $name->toString;
 				$anvil->data->{new}{resource}{$resource}{up}  = 0;
+				$anvil->data->{new}{resource}{$resource}{xml} = $name->toString;
 				$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { 
 					"new::resource::${resource}::xml" => $anvil->data->{new}{resource}{$resource}{xml},
 				}});
 				
+				# See if there's a scan_drbd_resource_uuid in the config file.
+				my $scan_drbd_resource_uuid = $anvil->DRBD->resource_uuid({
+					debug         => 2,
+					resource      => $resource,
+					resource_file => $conf_file, 
+				});
+				$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { scan_drbd_resource_uuid => $scan_drbd_resource_uuid }});
+				
+				$anvil->data->{new}{resource}{$resource}{scan_drbd_resource_uuid} = $scan_drbd_resource_uuid eq "!!error!!" ? "" : $scan_drbd_resource_uuid;
+				$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { 
+					"new::resource::${resource}::scan_drbd_resource_uuid" => $anvil->data->{new}{resource}{$resource}{scan_drbd_resource_uuid},
+				}});
+				
 				foreach my $host ($name->findnodes('./host'))
 				{
 					my $this_host_name = $host->{name};
diff --git a/scancore-agents/scan-drbd/scan-drbd.xml b/scancore-agents/scan-drbd/scan-drbd.xml
index 3bc62fa5..061295e3 100644
--- a/scancore-agents/scan-drbd/scan-drbd.xml
+++ b/scancore-agents/scan-drbd/scan-drbd.xml
@@ -34,6 +34,47 @@ The error was:
 		<!-- Error entries -->
 		<key name="scan_drbd_log_0001">Starting The: [#!variable!program!#] DRBD resource agent.</key>
 		
+		<!-- Messages -->
+		<key name="scan_drbd_message_0001">
+DRBD has been found to be configured on this host.
+- Disk flushes: ....... [#!variable!new_scan_drbd_flush_disk!#]
+- Meta-data flushes: .. [#!variable!new_scan_drbd_flush_md!#]
+- Network Timeout: .... [#!variable!new_scan_drbd_timeout!# seconds]
+- Current Resync Speed: [#!variable!say_scan_drbd_total_sync_speed!#]
+
+Note: Disk and metadata flushes should be enabled _unless_ you're using nodes with RAID controllers with flash-backed write cache.
+
+Raw 'drbdadm dump-xml' output:
+========
+#!variable!new_scan_drbd_common_xml!#
+========
+		</key>
+		<key name="scan_drbd_message_0002">
+The disk flush configuration has changed from: [#!variable!old_value!#] to: [#!variable!new_value!#].
+NOTE: Disk flushes show _only_ be disabled when a RAID controller with flash-backed write-caching is used!
+		</key>
+		<key name="scan_drbd_message_0003">
+The metadata flush configuration has changed from: [#!variable!old_value!#] to: [#!variable!new_value!#].
+NOTE: Metadata (MD) flushes show _only_ be disabled when a RAID controller with flash-backed write-caching is used!
+		</key>
+		<key name="scan_drbd_message_0004">The network timeout has changed from: [#!variable!old_value!# seconds] to: [#!variable!new_value!# seconds].</key>
+		<key name="scan_drbd_message_0005">The current resync speed across all syncing resources changed from: [#!variable!old_value!#/sec] to: [#!variable!new_value!#/sec].</key>
+		<key name="scan_drbd_message_0006">
+The base configuration (as reported by 'drbdadm dump-xml' has changed. The change is:
+========
+#!variable!difference!#
+========
+
+The full new config is:
+========
+#!variable!new_config!#
+========
+		</key>
+		
+		<!-- Units -->
+		<key name="scan_drbd_unit_0001">Enabled</key>
+		<key name="scan_drbd_unit_0002">Disabled</key>
+		<key name="scan_drbd_unit_0003">s</key>		<!-- Used in XiB/second -->
 		
 	</language>
 </words>
diff --git a/share/words.xml b/share/words.xml
index cdbaa140..e2bd4367 100644
--- a/share/words.xml
+++ b/share/words.xml
@@ -238,6 +238,7 @@ The error was:
 		<key name="error_0163">The MIB file: [#!variable!mib!#] doesn't exist or can't be read.</key>
 		<key name="error_0164">The date: [#!variable!date!#] is not in either the 'mm/dd/yy' or 'mm/dd/yyyy' formats. Can't convert to 'yyyy/mm/dd'.</key>
 		<key name="error_0165">The temperature: [#!variable!temperature!#] does not appear to be valid..</key>
+		<key name="error_0166">The resource: [#!variable!resource!#] in the config file: [#!variable!file!#] was found, but does not appear to be a valid UUID: [#!variable!uuid!#].</key>
 		
 		<!-- Table headers -->
 		<key name="header_0001">Current Network Interfaces and States</key>
@@ -1348,6 +1349,11 @@ About to try to download aproximately: [#!variable!packages!#] packages needed t
 		<key name="message_0186">No RHEL-based nodes are available. Unable to check for updated packages under the High Availability entitlement.</key>
 		<key name="message_0187">Downloaded and copied HA packages that started with the letter: [#!variable!letter!#].</key>
 		<key name="message_0188">Finished downloading HA packages!</key>
+		<key name="message_0189">
+	# The following line was added to track this resource UUID in the Anvil! database.
+	# Please do edit or remove it.
+	# scan_drbd_resource_uuid = #!variable!uuid!#
+		</key>
 		
 		<!-- Success messages shown to the user --> 
 		<key name="ok_0001">Saved the mail server information successfully!</key>
