From 014136ddd0802747a1a579950af4f3422cbc40ed Mon Sep 17 00:00:00 2001 From: digimer Date: Tue, 9 Apr 2024 23:48:57 -0400 Subject: [PATCH] Added manual parsing of crm_mon XML when parsing resource states. Signed-off-by: digimer --- Anvil/Tools/Cluster.pm | 79 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 75 insertions(+), 4 deletions(-) diff --git a/Anvil/Tools/Cluster.pm b/Anvil/Tools/Cluster.pm index d17c03fc..6a3a639d 100644 --- a/Anvil/Tools/Cluster.pm +++ b/Anvil/Tools/Cluster.pm @@ -4192,7 +4192,80 @@ sub parse_crm_mon $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { problem => $problem }}); foreach my $resource ($dom->findnodes('/pacemaker-result/resources/resource')) { - if ($resource->{resource_agent} eq "ocf::alteeve:server") + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { resource => $resource }}); + if ($resource =~ /Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { line => $line }}); + if (($line !~ /Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { id => $id }}); + } + if ($line =~ /resource_agent="(.*?)"/) + { + $resource_agent = $1; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { resource_agent => $resource_agent }}); + + if ($resource_agent eq "ocf:alteeve:server") + { + $resource_key = "resource"; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { resource_key => $resource_key }}); + } + elsif ($resource_agent =~ /stonith:(.*)$/) + { + $stonith_name = $1; + $resource_key = "stonith"; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { + stonith_name => $stonith_name, + resource_key => $resource_key, + }}); + } + } + if (($id) && ($resource_agent)) + { + if ($line =~ /data->{crm_mon}{parsed}{'pacemaker-result'}{resources}{$resource_key}{$id}{host}{node_name} = ($line =~ /name="(.*?)"/)[0]; + $anvil->data->{crm_mon}{parsed}{'pacemaker-result'}{resources}{$resource_key}{$id}{host}{node_id} = ($line =~ /id="(.*?)"/)[0]; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { + "crm_mon::parsed::pacemaker-result::resources::${resource_key}::${id}::host::node_name" => $anvil->data->{crm_mon}{parsed}{'pacemaker-result'}{resources}{$resource_key}{$id}{host}{node_name}, + "crm_mon::parsed::pacemaker-result::resources::${resource_key}::${id}::host::node_id" => $anvil->data->{crm_mon}{parsed}{'pacemaker-result'}{resources}{$resource_key}{$id}{host}{node_id}, + }}); + } + else + { + foreach my $pair (split/ /, $line) + { + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { pair => $pair }}); + if ($pair =~ /^(.*?)="(.*)"$/) + { + my $variable = $1; + my $value = $2; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { + 's1:variable' => $variable, + 's2:value' => $value, + }}); + next if $variable eq "id"; + next if $variable eq "resource_agent"; + + $anvil->data->{crm_mon}{parsed}{'pacemaker-result'}{resources}{$resource_key}{$id}{variables}{$variable} = $value; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { + "crm_mon::parsed::pacemaker-result::resources::${resource_key}::${id}::variables::${variable}" => $anvil->data->{crm_mon}{parsed}{'pacemaker-result'}{resources}{$resource_key}{$id}{variables}{$variable}, + }}); + } + } + } + } + } + } + elsif ($resource->{resource_agent} eq "ocf::alteeve:server") { my $id = $resource->{id}; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { id => $id }}); @@ -4208,7 +4281,6 @@ sub parse_crm_mon { my $node_id = $node->{id}; my $node_name = $node->{name}; - my $cached = $node->{cached}; $anvil->data->{crm_mon}{parsed}{'pacemaker-result'}{resources}{resource}{$id}{host}{node_name} = $node->{name}; $anvil->data->{crm_mon}{parsed}{'pacemaker-result'}{resources}{resource}{$id}{host}{node_id} = $node->{id}; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { @@ -4217,7 +4289,7 @@ sub parse_crm_mon }}); } } - if ($resource->{resource_agent} =~ /stonith:(.*)$/) + elsif ($resource->{resource_agent} =~ /stonith:(.*)$/) { my $fence_agent = $1; my $id = $resource->{id}; @@ -4237,7 +4309,6 @@ sub parse_crm_mon { my $node_id = $node->{id}; my $node_name = $node->{name}; - my $cached = $node->{cached}; $anvil->data->{crm_mon}{parsed}{'pacemaker-result'}{resources}{stonith}{$id}{host}{node_name} = $node->{name}; $anvil->data->{crm_mon}{parsed}{'pacemaker-result'}{resources}{stonith}{$id}{host}{node_id} = $node->{id}; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {