* Cleaned up the parsing of collected data in preperation for insertion/updating of the DB.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 4 years ago
parent 4e843baa17
commit 7bf4c25f9b
  1. 129
      scancore-agents/scan-drbd/scan-drbd
  2. 32
      scancore-agents/scan-drbd/scan-drbd.sql

@ -113,70 +113,88 @@ sub find_changes
my ($anvil) = @_; my ($anvil) = @_;
#print Dumper $anvil->data->{new}; #print Dumper $anvil->data->{new};
print __LINE__."; new::scan_drbd:\n"; my $new_scan_drbd_common_xml = $anvil->data->{new}{scan_drbd}{scan_drbd_common_xml};
foreach my $option (sort {$a cmp $b} keys %{$anvil->data->{new}{scan_drbd}}) 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};
next if $option eq "scan_drbd_common_xml"; my $new_scan_drbd_timeout = $anvil->data->{new}{scan_drbd}{scan_drbd_timeout};
print __LINE__."; - ".$option.": [".$anvil->data->{new}{scan_drbd}{$option}."]\n"; 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}}) foreach my $resource (sort {$a cmp $b} keys %{$anvil->data->{new}{resource}})
{ {
print __LINE__."; - ".$resource."\n"; my $scan_drbd_resource_name = $resource;
foreach my $option (sort {$a cmp $b} keys %{$anvil->data->{new}{resource}{$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"; my $scan_drbd_volume_number = $volume;
next if $option eq "peer"; my $new_scan_drbd_volume_device_path = $anvil->data->{new}{resource}{$resource}{volume}{$volume}{device_path};
next if $option eq "xml"; my $new_scan_drbd_volume_device_minor = $anvil->data->{new}{resource}{$resource}{volume}{$volume}{device_minor};
print __LINE__."; |- ".$option.": [".$anvil->data->{new}{resource}{$resource}{$option}."]\n"; 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}}) foreach my $peer (sort {$a cmp $b} keys %{$anvil->data->{new}{resource}{$resource}{peer}})
{ {
print __LINE__."; |- peer: [".$peer."]\n"; # These are common across all volumes
foreach my $option (sort {$a cmp $b} keys %{$anvil->data->{new}{resource}{$resource}{peer}{$peer}}) my $scan_drbd_peer_host_name = $peer;
{ my $new_scan_drbd_peer_ip_address = $anvil->data->{new}{resource}{$resource}{peer}{$peer}{peer_ip_address};
print __LINE__."; | |- ".$option.": [".$anvil->data->{new}{resource}{$resource}{peer}{$peer}{$option}."]\n"; 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}}) foreach my $volume (sort {$a cmp $b} keys %{$anvil->data->{new}{resource}{$resource}{volume}})
{ {
print __LINE__."; |- volume: [".$volume."]\n"; ### NOTE: Volume needs to be volume_uuid by this point
foreach my $option (sort {$a cmp $b} keys %{$anvil->data->{new}{resource}{$resource}{volume}{$volume}}) ### 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
next if $option eq "peer"; ### ETA. Also, it appears to be random which peer a node decides to
print __LINE__."; | |- ".$option.": [".$anvil->data->{new}{resource}{$resource}{volume}{$volume}{$option}."]\n"; ### sync from. So what we'll need to do when generating the JSON for
foreach my $peer (sort {$a cmp $b} keys %{$anvil->data->{new}{resource}{$resource}{volume}{$volume}{peer}}) ### the UI is to see which peers are SyncSource and SyncTarget and pull
{ ### the ETA from them.
print __LINE__."; | | |- ".$peer.";\n"; my $new_scan_drbd_peer_connection_state = $anvil->data->{new}{resource}{$resource}{volume}{$volume}{peer}{$peer}{connection_state};
foreach my $peer_option (sort {$a cmp $b} keys %{$anvil->data->{new}{resource}{$resource}{volume}{$volume}{peer}{$peer}}) 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};
print __LINE__."; | | | |- ".$peer_option.": [".$anvil->data->{new}{resource}{$resource}{volume}{$volume}{peer}{$peer}{$peer_option}."]\n"; my $new_scan_drbd_peer_local_role = $anvil->data->{new}{resource}{$resource}{volume}{$volume}{peer}{$peer}{local_role};
if (($peer_option eq "out_of_sync_size") && my $new_scan_drbd_peer_role = $anvil->data->{new}{resource}{$resource}{volume}{$volume}{peer}{$peer}{peer_role};
($anvil->data->{new}{resource}{$resource}{volume}{$volume}{peer}{$peer}{$peer_option}) && my $new_scan_drbd_peer_out_of_sync_size = $anvil->data->{new}{resource}{$resource}{volume}{$volume}{peer}{$peer}{out_of_sync_size};
($anvil->data->{new}{resource}{$resource}{volume}{$volume}{peer}{$peer}{connection_state} =~ /sync/)) 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};
my $resource_size = $anvil->data->{new}{resource}{$resource}{volume}{$volume}{size}; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
my $say_res_size = $anvil->Convert->bytes_to_human_readable({'bytes' => $resource_size}); "s1:volume" => $volume,
my $bytes_to_sync = $anvil->data->{new}{resource}{$resource}{volume}{$volume}{peer}{$peer}{$peer_option}; "s2:new_scan_drbd_peer_connection_state" => $new_scan_drbd_peer_connection_state,
my $say_to_sync = $anvil->Convert->bytes_to_human_readable({'bytes' => $bytes_to_sync}); "s3:new_scan_drbd_peer_local_disk_state" => $new_scan_drbd_peer_local_disk_state,
my $bytes_in_sync = $resource_size - $bytes_to_sync; "s4:new_scan_drbd_peer_disk_state" => $new_scan_drbd_peer_disk_state,
my $say_in_sync = $anvil->Convert->bytes_to_human_readable({'bytes' => $bytes_in_sync}); "s5:new_scan_drbd_peer_local_role" => $new_scan_drbd_peer_local_role,
my $percent_complete = $anvil->Convert->round({ "s6:new_scan_drbd_peer_role" => $new_scan_drbd_peer_role,
number => (($bytes_in_sync / $resource_size) * 100), "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}).")",
places => 2, "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}).")",
}});
### 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";
}
}
}
} }
} }
} }
@ -220,7 +238,6 @@ sub gather_data
# Successful parse! # Successful parse!
### TODO: Might be best to config these default values by calling/parsing ### TODO: Might be best to config these default values by calling/parsing
### 'drbdsetup show <resource> --show-defaults'. ### 'drbdsetup show <resource> --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_common_xml} = $drbd_xml;
$anvil->data->{new}{scan_drbd}{scan_drbd_flush_disk} = 1; $anvil->data->{new}{scan_drbd}{scan_drbd_flush_disk} = 1;
$anvil->data->{new}{scan_drbd}{scan_drbd_flush_md} = 1; $anvil->data->{new}{scan_drbd}{scan_drbd_flush_md} = 1;

@ -266,16 +266,16 @@ CREATE TABLE scan_drbd_peers (
scan_drbd_peer_uuid uuid not null primary key, scan_drbd_peer_uuid uuid not null primary key,
scan_drbd_peer_host_uuid uuid not null, scan_drbd_peer_host_uuid uuid not null,
scan_drbd_peer_scan_drbd_volume_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_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_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_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_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_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_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_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_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. 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_uuid uuid,
scan_drbd_peer_host_uuid uuid, scan_drbd_peer_host_uuid uuid,
scan_drbd_peer_scan_drbd_volume_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_connection_state text,
scan_drbd_peer_local_disk_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_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_out_of_sync_size numeric,
scan_drbd_peer_replication_speed numeric, scan_drbd_peer_replication_speed numeric,
scan_drbd_peer_estimated_time_to_sync 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_tcp_port numeric,
scan_drbd_peer_protocol text, scan_drbd_peer_protocol text,
scan_drbd_peer_fencing text, scan_drbd_peer_fencing text,
@ -318,16 +318,16 @@ BEGIN
(scan_drbd_peer_uuid, (scan_drbd_peer_uuid,
scan_drbd_peer_host_uuid, scan_drbd_peer_host_uuid,
scan_drbd_peer_scan_drbd_volume_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_connection_state,
scan_drbd_peer_local_disk_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_local_role,
scan_drbd_peer_peer_role, scan_drbd_peer_role,
scan_drbd_peer_out_of_sync_size, scan_drbd_peer_out_of_sync_size,
scan_drbd_peer_replication_speed, scan_drbd_peer_replication_speed,
scan_drbd_peer_estimated_time_to_sync, 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_tcp_port,
scan_drbd_peer_protocol, scan_drbd_peer_protocol,
scan_drbd_peer_fencing, scan_drbd_peer_fencing,
@ -336,16 +336,16 @@ BEGIN
(history_scan_drbd_peers.scan_drbd_peer_uuid, (history_scan_drbd_peers.scan_drbd_peer_uuid,
history_scan_drbd_peers.scan_drbd_peer_host_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_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_connection_state,
history_scan_drbd_peers.scan_drbd_peer_local_disk_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_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_out_of_sync_size,
history_scan_drbd_peers.scan_drbd_peer_replication_speed, 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_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_tcp_port,
history_scan_drbd_peers.scan_drbd_peer_protocol, history_scan_drbd_peers.scan_drbd_peer_protocol,
history_scan_drbd_peers.scan_drbd_peer_fencing, history_scan_drbd_peers.scan_drbd_peer_fencing,

Loading…
Cancel
Save