|
|
|
@ -88,12 +88,12 @@ collect_data($anvil); |
|
|
|
|
# Look for migration times written out by ocf:alteeve:server. |
|
|
|
|
record_migration_times($anvil); |
|
|
|
|
|
|
|
|
|
# Check if we need to update the websocket stuff. |
|
|
|
|
check_vnc($anvil); |
|
|
|
|
|
|
|
|
|
# Check that there's a DRBD fence rule for each server. |
|
|
|
|
check_drbd_fence_rules($anvil); |
|
|
|
|
|
|
|
|
|
# Get screenshot from every server that is alive. |
|
|
|
|
get_screenshots($anvil); |
|
|
|
|
|
|
|
|
|
# Shut down. |
|
|
|
|
$anvil->ScanCore->agent_shutdown({agent => $THIS_FILE}); |
|
|
|
|
|
|
|
|
@ -169,72 +169,66 @@ sub check_drbd_fence_rules |
|
|
|
|
return(0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
# |
|
|
|
|
sub check_vnc |
|
|
|
|
# Gets a screenshot for each server that is alive. |
|
|
|
|
sub get_screenshots |
|
|
|
|
{ |
|
|
|
|
my ($anvil) = @_; |
|
|
|
|
|
|
|
|
|
### NOTE: In the interest of time, this table is not yet in the core schema. Later, when it is, this |
|
|
|
|
### check can be removed. |
|
|
|
|
# See if the 'vnc_pipes' table exists. |
|
|
|
|
my $query = "SELECT COUNT(*) FROM information_schema.tables WHERE table_name = 'vnc_pipes' AND table_schema = 'public';"; |
|
|
|
|
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0124", variables => { query => $query }}); |
|
|
|
|
my $anvil = shift; |
|
|
|
|
my $parameters = shift; |
|
|
|
|
my $debug = $parameters->{debug} // 3; |
|
|
|
|
|
|
|
|
|
my $count = $anvil->Database->query({query => $query, source => $THIS_FILE, line => __LINE__})->[0]->[0]; |
|
|
|
|
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { count => $count }}); |
|
|
|
|
|
|
|
|
|
if ($count) |
|
|
|
|
my $anvil_uuid = $anvil->Cluster->get_anvil_uuid(); |
|
|
|
|
my $local_host_uuid = $anvil->Get->host_uuid(); |
|
|
|
|
|
|
|
|
|
my $query = "SELECT host_name FROM hosts WHERE host_type = 'striker';"; |
|
|
|
|
my $results = $anvil->Database->query({ query => $query, source => $THIS_FILE, line => __LINE__ }); |
|
|
|
|
my $count = @{$results}; |
|
|
|
|
|
|
|
|
|
$anvil->Log->variables({ source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query, count => $count } }); |
|
|
|
|
|
|
|
|
|
return (1) if ($count == 0); |
|
|
|
|
|
|
|
|
|
# Start the CSV with the first element, then append. |
|
|
|
|
my $striker_name_csv = $results->[0]->[0]; |
|
|
|
|
|
|
|
|
|
foreach my $row ( @{$results}[1 .. $#{$results}] ) |
|
|
|
|
{ |
|
|
|
|
# For each server running here, get the VNC port and record it. |
|
|
|
|
my $anvil_uuid = $anvil->Cluster->get_anvil_uuid; |
|
|
|
|
foreach my $server_name (sort {$a cmp $b} keys %{$anvil->data->{servers}{anvil_uuid}{$anvil_uuid}{server_name}}) |
|
|
|
|
{ |
|
|
|
|
my $server_uuid = $anvil->data->{servers}{anvil_uuid}{$anvil_uuid}{server_name}{$server_name}{server_uuid}; |
|
|
|
|
my $server_state = $anvil->data->{servers}{server_uuid}{$server_uuid}{server_state}; |
|
|
|
|
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { |
|
|
|
|
server_name => $server_name, |
|
|
|
|
server_uuid => $server_uuid, |
|
|
|
|
server_state => $server_state, |
|
|
|
|
}}); |
|
|
|
|
|
|
|
|
|
next if $server_state eq "paused"; |
|
|
|
|
next if $server_state eq "shut off"; |
|
|
|
|
next if $server_state eq "crashed"; |
|
|
|
|
|
|
|
|
|
# Get the VNC port. Ignore the IP and the port number is +5900. |
|
|
|
|
my $shell_call = $anvil->data->{path}{exe}{setsid}." --wait ".$anvil->data->{path}{exe}{virsh}." vncdisplay --domain ".$server_name; |
|
|
|
|
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { shell_call => $shell_call }}); |
|
|
|
|
|
|
|
|
|
my ($output, $return_code) = $anvil->System->call({shell_call => $shell_call, source => $THIS_FILE, line => __LINE__}); |
|
|
|
|
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { |
|
|
|
|
output => $output, |
|
|
|
|
return_code => $return_code, |
|
|
|
|
}}); |
|
|
|
|
foreach my $line (split/\n/, $output) |
|
|
|
|
{ |
|
|
|
|
if ($line =~ /\d.*?:(\d+)$/) |
|
|
|
|
{ |
|
|
|
|
my $port = 5900 + $1; |
|
|
|
|
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { port => $port }}); |
|
|
|
|
|
|
|
|
|
my ($variable_uuid) = $anvil->Database->insert_or_update_variables({ |
|
|
|
|
file => $THIS_FILE, |
|
|
|
|
line => __LINE__, |
|
|
|
|
variable_name => "server::vnc_port", |
|
|
|
|
variable_value => $port, |
|
|
|
|
variable_default => "", |
|
|
|
|
variable_description => "message_0255", |
|
|
|
|
variable_section => "servers", |
|
|
|
|
variable_source_uuid => $server_uuid, |
|
|
|
|
variable_source_table => "servers", |
|
|
|
|
}); |
|
|
|
|
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { variable_uuid => $variable_uuid }}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
my $host_name = $row->[0]; |
|
|
|
|
|
|
|
|
|
$striker_name_csv = "$striker_name_csv,$host_name"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return(0); |
|
|
|
|
|
|
|
|
|
$anvil->Log->variables({ source => $THIS_FILE, line => __LINE__, level => $debug, list => { striker_name_csv => $striker_name_csv } }); |
|
|
|
|
|
|
|
|
|
foreach my $server_name (sort {$a cmp $b} keys %{$anvil->data->{servers}{anvil_uuid}{$anvil_uuid}{server_name}}) |
|
|
|
|
{ |
|
|
|
|
my $server_uuid = $anvil->data->{servers}{anvil_uuid}{$anvil_uuid}{server_name}{$server_name}{server_uuid}; |
|
|
|
|
|
|
|
|
|
my $server_host_uuid = $anvil->data->{servers}{server_uuid}{$server_uuid}{server_host_uuid}; |
|
|
|
|
my $server_state = $anvil->data->{servers}{server_uuid}{$server_uuid}{server_state}; |
|
|
|
|
|
|
|
|
|
$anvil->Log->variables({ source => $THIS_FILE, line => __LINE__, level => $debug, list => { |
|
|
|
|
server_host_uuid => $server_host_uuid, |
|
|
|
|
server_name => $server_name, |
|
|
|
|
server_state => $server_state, |
|
|
|
|
server_uuid => $server_uuid, |
|
|
|
|
} }); |
|
|
|
|
|
|
|
|
|
next if ( ($server_host_uuid ne $local_host_uuid) || (not $server_state eq "running") ); |
|
|
|
|
|
|
|
|
|
my ($syscall_output, $syscall_rcode) = $anvil->System->call({ |
|
|
|
|
debug => $debug, |
|
|
|
|
line => __LINE__, |
|
|
|
|
shell_call => $anvil->data->{path}{exe}{'anvil-get-server-screenshot'}." --server-uuid '$server_uuid' --request-host-name '$striker_name_csv' &", |
|
|
|
|
source => $THIS_FILE, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
$anvil->Log->variables({ source => $THIS_FILE, line => __LINE__, level => $debug, list => { |
|
|
|
|
syscall_output => $syscall_output, |
|
|
|
|
syscall_rcode => $syscall_rcode, |
|
|
|
|
}}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return (0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
# Look for migration times written out by ocf:alteeve:server. |
|
|
|
|