diff --git a/scancore-agents/scan-drbd/scan-drbd b/scancore-agents/scan-drbd/scan-drbd index 53d4961b..a6abac53 100755 --- a/scancore-agents/scan-drbd/scan-drbd +++ b/scancore-agents/scan-drbd/scan-drbd @@ -113,70 +113,88 @@ sub find_changes my ($anvil) = @_; #print Dumper $anvil->data->{new}; - print __LINE__."; new::scan_drbd:\n"; - foreach my $option (sort {$a cmp $b} keys %{$anvil->data->{new}{scan_drbd}}) - { - next if $option eq "scan_drbd_common_xml"; - print __LINE__."; - ".$option.": [".$anvil->data->{new}{scan_drbd}{$option}."]\n"; - } + 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}; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { + "s1:new_scan_drbd_flush_disk" => $new_scan_drbd_flush_disk, + "s2:new_scan_drbd_flush_md" => $new_scan_drbd_flush_md, + "s3:new_scan_drbd_timeout" => $new_scan_drbd_timeout, + "s4: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)", + "s5:new_scan_drbd_common_xml" => $new_scan_drbd_common_xml, + }}); - print __LINE__."; Resources:\n"; foreach my $resource (sort {$a cmp $b} keys %{$anvil->data->{new}{resource}}) { - print __LINE__."; - ".$resource."\n"; - foreach my $option (sort {$a cmp $b} keys %{$anvil->data->{new}{resource}{$resource}}) + 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, + }}); + + foreach my $volume (sort {$a cmp $b} keys %{$anvil->data->{new}{resource}{$resource}{volume}}) { - next if $option eq "volume"; - next if $option eq "peer"; - next if $option eq "xml"; - print __LINE__."; |- ".$option.": [".$anvil->data->{new}{resource}{$resource}{$option}."]\n"; + my $scan_drbd_volume_number = $volume; + my $new_scan_drbd_volume_device_path = $anvil->data->{new}{resource}{$resource}{volume}{$volume}{device_path}; + my $new_scan_drbd_volume_device_minor = $anvil->data->{new}{resource}{$resource}{volume}{$volume}{device_minor}; + my $new_scan_drbd_volume_size = $anvil->data->{new}{resource}{$resource}{volume}{$volume}{size}; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { + "s1:scan_drbd_volume_number" => $scan_drbd_volume_number, + "s2:new_scan_drbd_volume_device_path" => $new_scan_drbd_volume_device_path, + "s3:new_scan_drbd_volume_device_minor" => $new_scan_drbd_volume_device_minor, + "s4:new_scan_drbd_volume_size" => $new_scan_drbd_volume_size." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $new_scan_drbd_volume_size}).")", + }}); } + foreach my $peer (sort {$a cmp $b} keys %{$anvil->data->{new}{resource}{$resource}{peer}}) { - print __LINE__."; |- peer: [".$peer."]\n"; - foreach my $option (sort {$a cmp $b} keys %{$anvil->data->{new}{resource}{$resource}{peer}{$peer}}) - { - print __LINE__."; | |- ".$option.": [".$anvil->data->{new}{resource}{$resource}{peer}{$peer}{$option}."]\n"; - } - } - foreach my $volume (sort {$a cmp $b} keys %{$anvil->data->{new}{resource}{$resource}{volume}}) - { - print __LINE__."; |- volume: [".$volume."]\n"; - foreach my $option (sort {$a cmp $b} keys %{$anvil->data->{new}{resource}{$resource}{volume}{$volume}}) + # These are common across all volumes + my $scan_drbd_peer_host_name = $peer; + my $new_scan_drbd_peer_ip_address = $anvil->data->{new}{resource}{$resource}{peer}{$peer}{peer_ip_address}; + my $new_scan_drbd_peer_tcp_port = $anvil->data->{new}{resource}{$resource}{peer}{$peer}{tcp_port}; + my $new_scan_drbd_peer_protocol = $anvil->data->{new}{resource}{$resource}{peer}{$peer}{protocol}; + my $new_scan_drbd_peer_fencing = $anvil->data->{new}{resource}{$resource}{peer}{$peer}{fencing}; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { + "s1:scan_drbd_peer_host_name" => $scan_drbd_peer_host_name, + "s2:new_scan_drbd_peer_ip_address" => $new_scan_drbd_peer_ip_address, + "s3:new_scan_drbd_peer_tcp_port" => $new_scan_drbd_peer_tcp_port, + "s4:new_scan_drbd_peer_protocol" => $new_scan_drbd_peer_protocol, + "s5:new_scan_drbd_peer_fencing" => $new_scan_drbd_peer_fencing, + }}); + + foreach my $volume (sort {$a cmp $b} keys %{$anvil->data->{new}{resource}{$resource}{volume}}) { - next if $option eq "peer"; - print __LINE__."; | |- ".$option.": [".$anvil->data->{new}{resource}{$resource}{volume}{$volume}{$option}."]\n"; - foreach my $peer (sort {$a cmp $b} keys %{$anvil->data->{new}{resource}{$resource}{volume}{$volume}{peer}}) - { - print __LINE__."; | | |- ".$peer.";\n"; - foreach my $peer_option (sort {$a cmp $b} keys %{$anvil->data->{new}{resource}{$resource}{volume}{$volume}{peer}{$peer}}) - { - print __LINE__."; | | | |- ".$peer_option.": [".$anvil->data->{new}{resource}{$resource}{volume}{$volume}{peer}{$peer}{$peer_option}."]\n"; - if (($peer_option eq "out_of_sync_size") && - ($anvil->data->{new}{resource}{$resource}{volume}{$volume}{peer}{$peer}{$peer_option}) && - ($anvil->data->{new}{resource}{$resource}{volume}{$volume}{peer}{$peer}{connection_state} =~ /sync/)) - { - my $resource_size = $anvil->data->{new}{resource}{$resource}{volume}{$volume}{size}; - my $say_res_size = $anvil->Convert->bytes_to_human_readable({'bytes' => $resource_size}); - my $bytes_to_sync = $anvil->data->{new}{resource}{$resource}{volume}{$volume}{peer}{$peer}{$peer_option}; - my $say_to_sync = $anvil->Convert->bytes_to_human_readable({'bytes' => $bytes_to_sync}); - my $bytes_in_sync = $resource_size - $bytes_to_sync; - my $say_in_sync = $anvil->Convert->bytes_to_human_readable({'bytes' => $bytes_in_sync}); - my $percent_complete = $anvil->Convert->round({ - number => (($bytes_in_sync / $resource_size) * 100), - places => 2, - }); - - ### NOTE: So, if we're a node and the peer is Sync'ing from DR, we'll see the OOS drop and can calculate the % sync change, but we don't see the ETA. - ### Also, it appears to be random which peer a node decides to sync from. - ### So what we'll need to do when generating the JSON for the UI is to see which peers are SyncSource and SyncTarget and pull the ETA from them. -# print __LINE__."; Resource size: [".$say_res_size." (".$resource_size.")]\n"; -# print __LINE__."; Bytes in Sync: [".$say_in_sync." (".$bytes_in_sync.")]\n"; -# print __LINE__."; Bytes to Sync: [".$say_to_sync." (".$bytes_to_sync.")]\n"; - print __LINE__."; | | | | \\- Sync'ed: [".$percent_complete."%] (".$say_in_sync." of ".$say_res_size." sync'ed, ".$say_to_sync." remaining)\n"; - } - } - } + ### NOTE: Volume needs to be volume_uuid by this point + ### NOTE: So, if we're a node and the peer is Sync'ing from DR, we'll see the + ### OOS drop and can calculate the % sync change, but we don't see the + ### ETA. Also, it appears to be random which peer a node decides to + ### sync from. So what we'll need to do when generating the JSON for + ### the UI is to see which peers are SyncSource and SyncTarget and pull + ### the ETA from them. + my $new_scan_drbd_peer_connection_state = $anvil->data->{new}{resource}{$resource}{volume}{$volume}{peer}{$peer}{connection_state}; + my $new_scan_drbd_peer_local_disk_state = $anvil->data->{new}{resource}{$resource}{volume}{$volume}{peer}{$peer}{local_disk_state}; + my $new_scan_drbd_peer_disk_state = $anvil->data->{new}{resource}{$resource}{volume}{$volume}{peer}{$peer}{peer_disk_state}; + my $new_scan_drbd_peer_local_role = $anvil->data->{new}{resource}{$resource}{volume}{$volume}{peer}{$peer}{local_role}; + my $new_scan_drbd_peer_role = $anvil->data->{new}{resource}{$resource}{volume}{$volume}{peer}{$peer}{peer_role}; + my $new_scan_drbd_peer_out_of_sync_size = $anvil->data->{new}{resource}{$resource}{volume}{$volume}{peer}{$peer}{out_of_sync_size}; + my $new_scan_drbd_peer_replication_speed = $anvil->data->{new}{resource}{$resource}{volume}{$volume}{peer}{$peer}{replication_speed}; + my $new_scan_drbd_peer_estimated_time_to_sync = $anvil->data->{new}{resource}{$resource}{volume}{$volume}{peer}{$peer}{estimated_time_to_sync}; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { + "s1:volume" => $volume, + "s2:new_scan_drbd_peer_connection_state" => $new_scan_drbd_peer_connection_state, + "s3:new_scan_drbd_peer_local_disk_state" => $new_scan_drbd_peer_local_disk_state, + "s4:new_scan_drbd_peer_disk_state" => $new_scan_drbd_peer_disk_state, + "s5:new_scan_drbd_peer_local_role" => $new_scan_drbd_peer_local_role, + "s6:new_scan_drbd_peer_role" => $new_scan_drbd_peer_role, + "s7:new_scan_drbd_peer_out_of_sync_size" => $new_scan_drbd_peer_out_of_sync_size." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $new_scan_drbd_peer_out_of_sync_size}).")", + "s8:new_scan_drbd_peer_replication_speed" => $new_scan_drbd_peer_replication_speed." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $new_scan_drbd_peer_replication_speed})."/s)", + "s9:new_scan_drbd_peer_estimated_time_to_sync" => $new_scan_drbd_peer_estimated_time_to_sync." (".$anvil->Convert->time({'time' => $new_scan_drbd_peer_estimated_time_to_sync, long => 1, translate => 1}).")", + }}); } } } @@ -220,7 +238,6 @@ sub gather_data # Successful parse! ### TODO: Might be best to config these default values by calling/parsing ### 'drbdsetup show --show-defaults'. - $anvil->data->{new}{scan_drbd}{scan_drbd_host_uuid} = $anvil->Get->host_uuid; $anvil->data->{new}{scan_drbd}{scan_drbd_common_xml} = $drbd_xml; $anvil->data->{new}{scan_drbd}{scan_drbd_flush_disk} = 1; $anvil->data->{new}{scan_drbd}{scan_drbd_flush_md} = 1; diff --git a/scancore-agents/scan-drbd/scan-drbd.sql b/scancore-agents/scan-drbd/scan-drbd.sql index b4e0878d..913c5d1a 100644 --- a/scancore-agents/scan-drbd/scan-drbd.sql +++ b/scancore-agents/scan-drbd/scan-drbd.sql @@ -266,16 +266,16 @@ CREATE TABLE scan_drbd_peers ( scan_drbd_peer_uuid uuid not null primary key, scan_drbd_peer_host_uuid uuid not null, scan_drbd_peer_scan_drbd_volume_uuid uuid not null, - scan_drbd_peer_peer_host_name text not null, -- The host name for this peer, as recorded in the config + scan_drbd_peer_host_name text not null, -- The host name for this peer, as recorded in the config scan_drbd_peer_connection_state text not null, -- The connection state to the peer. See "Connection States" and "Replication States" above. scan_drbd_peer_local_disk_state text not null, -- The local disk state of the peer, see "Disk States" above. - scan_drbd_peer_peer_disk_state text not null, -- The local disk state of the peer, see "Disk States" above. + scan_drbd_peer_disk_state text not null, -- The local disk state of the peer, see "Disk States" above. scan_drbd_peer_local_role text not null, -- The current local role of the peer. - scan_drbd_peer_peer_role text not null, -- The current peer role of the peer. + scan_drbd_peer_role text not null, -- The current peer role of the peer. scan_drbd_peer_out_of_sync_size numeric not null, -- This is the number of "out of sync" bytes. Set to '0' when both sides are UpToDate. scan_drbd_peer_replication_speed numeric not null, -- This is how many bytes per second are being copied. Set to '0' when not synchronizing. scan_drbd_peer_estimated_time_to_sync numeric not null, -- This is the number of second that is *estimated* remaining in the resync. Set to '0' when both sides are UpToDate. - scan_drbd_peer_peer_ip_address text not null, -- The (SN) IP address used for this peer. + scan_drbd_peer_ip_address text not null, -- The (SN) IP address used for this peer. scan_drbd_peer_tcp_port numeric not null, -- This is the port number used for this peer. scan_drbd_peer_protocol text not null, -- This is 'A' for async peers (to DR, usually) or 'C' to sync peers (node peer and sometimes DR) scan_drbd_peer_fencing text not null, -- Set to 'resource-and-stonith' for node peers and 'dont-care' for DR hosts. @@ -291,16 +291,16 @@ CREATE TABLE history.scan_drbd_peers ( scan_drbd_peer_uuid uuid, scan_drbd_peer_host_uuid uuid, scan_drbd_peer_scan_drbd_volume_uuid uuid, - scan_drbd_peer_peer_host_name text, + scan_drbd_peer_host_name text, scan_drbd_peer_connection_state text, scan_drbd_peer_local_disk_state text, - scan_drbd_peer_peer_disk_state text, + scan_drbd_peer_disk_state text, scan_drbd_peer_local_role text, - scan_drbd_peer_peer_role text, + scan_drbd_peer_role text, scan_drbd_peer_out_of_sync_size numeric, scan_drbd_peer_replication_speed numeric, scan_drbd_peer_estimated_time_to_sync numeric, - scan_drbd_peer_peer_ip_address text, + scan_drbd_peer_ip_address text, scan_drbd_peer_tcp_port numeric, scan_drbd_peer_protocol text, scan_drbd_peer_fencing text, @@ -318,16 +318,16 @@ BEGIN (scan_drbd_peer_uuid, scan_drbd_peer_host_uuid, scan_drbd_peer_scan_drbd_volume_uuid, - scan_drbd_peer_peer_host_name, + scan_drbd_peer_host_name, scan_drbd_peer_connection_state, scan_drbd_peer_local_disk_state, - scan_drbd_peer_peer_disk_state, + scan_drbd_peer_disk_state, scan_drbd_peer_local_role, - scan_drbd_peer_peer_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_peer_ip_address, + scan_drbd_peer_ip_address, scan_drbd_peer_tcp_port, scan_drbd_peer_protocol, scan_drbd_peer_fencing, @@ -336,16 +336,16 @@ BEGIN (history_scan_drbd_peers.scan_drbd_peer_uuid, history_scan_drbd_peers.scan_drbd_peer_host_uuid, history_scan_drbd_peers.scan_drbd_peer_scan_drbd_volume_uuid, - history_scan_drbd_peers.scan_drbd_peer_peer_host_name, + history_scan_drbd_peers.scan_drbd_peer_host_name, history_scan_drbd_peers.scan_drbd_peer_connection_state, history_scan_drbd_peers.scan_drbd_peer_local_disk_state, - history_scan_drbd_peers.scan_drbd_peer_peer_disk_state, + history_scan_drbd_peers.scan_drbd_peer_disk_state, history_scan_drbd_peers.scan_drbd_peer_local_role, - history_scan_drbd_peers.scan_drbd_peer_peer_role, + history_scan_drbd_peers.scan_drbd_peer_role, history_scan_drbd_peers.scan_drbd_peer_out_of_sync_size, history_scan_drbd_peers.scan_drbd_peer_replication_speed, history_scan_drbd_peers.scan_drbd_peer_estimated_time_to_sync, - history_scan_drbd_peers.scan_drbd_peer_peer_ip_address, + history_scan_drbd_peers.scan_drbd_peer_ip_address, history_scan_drbd_peers.scan_drbd_peer_tcp_port, history_scan_drbd_peers.scan_drbd_peer_protocol, history_scan_drbd_peers.scan_drbd_peer_fencing,