From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17540 invoked by alias); 29 Sep 2008 13:31:37 -0000 Received: (qmail 17531 invoked by alias); 29 Sep 2008 13:31:36 -0000 X-Spam-Status: No, hits=-0.3 required=5.0 tests=AWL,BAYES_50,KAM_MX,SPF_HELO_PASS X-Spam-Check-By: sourceware.org X-Spam-Checker-Version: SpamAssassin 3.2.4 (2008-01-01) on bastion.fedora.phx.redhat.com X-Spam-Level: Subject: STABLE2 - fence_scsi: improve logging for debugging To: cluster-cvs-relay@redhat.com X-Project: Cluster Project X-Git-Module: cluster.git X-Git-Refname: refs/heads/STABLE2 X-Git-Reftype: branch X-Git-Oldrev: 07aaff32a7abf3533bf560e5d2641b893c4bbd80 X-Git-Newrev: 45f1776b076b92dd28a7b2bcb17cc9d468a55d43 From: "Ryan O'Hara" Message-Id: <20080929133034.C291A120468@lists.fedorahosted.org> Date: Mon, 29 Sep 2008 13:31:00 -0000 X-Scanned-By: MIMEDefang 2.58 on 172.16.52.254 Mailing-List: contact cluster-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: cluster-cvs-owner@sourceware.org X-SW-Source: 2008-q3/txt/msg00548.txt.bz2 Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=45f1776b076b92dd28a7b2bcb17cc9d468a55d43 Commit: 45f1776b076b92dd28a7b2bcb17cc9d468a55d43 Parent: 07aaff32a7abf3533bf560e5d2641b893c4bbd80 Author: Ryan O'Hara AuthorDate: Wed Sep 10 16:55:04 2008 -0500 Committer: Ryan O'Hara CommitterDate: Mon Sep 29 08:30:19 2008 -0500 fence_scsi: improve logging for debugging Using the -v (verbose) option will print more information that it previously did. Output will also be easier to understand, which should help track down any problems that might occur. --- fence/agents/scsi/fence_scsi.pl | 91 ++++++++++++++++++++++++++------------ 1 files changed, 62 insertions(+), 29 deletions(-) diff --git a/fence/agents/scsi/fence_scsi.pl b/fence/agents/scsi/fence_scsi.pl index fb5093f..85d67d6 100644 --- a/fence/agents/scsi/fence_scsi.pl +++ b/fence/agents/scsi/fence_scsi.pl @@ -5,7 +5,7 @@ use XML::LibXML; use IPC::Open3; use POSIX; -my @volumes; +my @device_list; $_ = $0; s/.*\///; @@ -75,7 +75,6 @@ sub get_cluster_id while (<$out>) { chomp; - print "OUT: $_\n" if $opt_v; my ($name, $value) = split(/\s*:\s*/, $_); @@ -90,6 +89,8 @@ sub get_cluster_id close($out); close($err); + print "[$pname]: get_cluster_id: cluster_id=$cluster_id\n" if $opt_v; + return $cluster_id; } @@ -104,11 +105,15 @@ sub get_node_id my $node_id = $tree->findvalue($xpath); + print "[$pname]: get_node_id ($node): node_id=$node_id\n" if $opt_v; + return $node_id; } sub get_node_name { + print "[$pname]: get_hode_name: node_name=$opt_n\n" if $opt_v; + return $opt_n; } @@ -128,7 +133,6 @@ sub get_host_id while (<$out>) { chomp; - print "OUT: $_\n" if $opt_v; my ($name, $value) = split(/\s*:\s*/, $_); @@ -143,6 +147,8 @@ sub get_host_id close($out); close($err); + print "[$pname]: get_host_id: host_id=$host_id\n" if $opt_v; + return $host_id; } @@ -162,7 +168,6 @@ sub get_host_name while (<$out>) { chomp; - print "OUT: $_\n" if $opt_v; my ($name, $value) = split(/\s*:\s*/, $_); @@ -177,6 +182,8 @@ sub get_host_name close($out); close($err); + print "[$pname]: get_host_name: host_name=$host_name\n" if $opt_v; + return $host_name; } @@ -193,6 +200,8 @@ sub get_key my $key = sprintf "%x%.4x", $cluster_id, $node_id; + print "[$pname]: get_key ($node): key=$key\n" if $opt_v; + return $key; } @@ -253,7 +262,7 @@ sub get_key_list my ($in, $out, $err); - my $cmd = "sg_persist -n -d $dev -i -k"; + my $cmd = "sg_persist -d $dev -i -k"; my $pid = open3($in, $out, $err, $cmd) or die "$!\n"; waitpid($pid, 0); @@ -272,6 +281,22 @@ sub get_key_list } } + # DEBUG: use -v option + # + if ($opt_v) + { + my $count = keys %key_list; + my $index = 0; + + print "[$pname]: get_key_list: found $count keys registered with $dev\n"; + + for $key (keys %key_list) + { + print "[$pname]: ($index) key=$key\n"; + $index++; + } + } + close($in); close($out); close($err); @@ -290,19 +315,34 @@ sub get_scsi_devices waitpid($pid, 0); - die "Unable to execute lvs.\n" if ($?>>8); + die "Unable to execute vgs.\n" if ($?>>8); while (<$out>) { chomp; - print "OUT: $_\n" if $opt_v; - my ($vg_attrs, $device) = split(/:/, $_); + my ($vg_attrs, $dev) = split(/:/, $_); if ($vg_attrs =~ /.*c$/) { - $device =~ s/\(.*\)//; - push(@volumes, $device); + $dev =~ s/\(.*\)//; + push(@device_list, $dev); + } + } + + # DEBUG: use -v flag + # + if ($opt_v) + { + my $count = scalar @device_list; + my $index = 0; + + print "[$pname]: get_scsi_devices: found $count devices\n"; + + for $dev (@device_list) + { + print "[$pname]: ($index) dev=$dev\n"; + $index++; } } @@ -321,12 +361,6 @@ sub check_sg_persist die "Unable to execute sg_persist.\n" if ($?>>8); - while (<$out>) - { - chomp; - print "OUT: $_\n" if $opt_v; - } - close($in); close($out); close($err); @@ -344,12 +378,6 @@ sub do_register die "Unable to execute sg_persist ($dev).\n" if ($?>>8); - while (<$out>) - { - chomp; - print "OUT: $_\n" if $opt_v; - } - close($in); close($out); close($err); @@ -365,10 +393,17 @@ sub fence_node my ($in, $out, $err); - foreach $dev (@volumes) + foreach $dev (@device_list) { my %key_list = get_key_list($dev); + # DEBUG: use -v option + # + if ($opt_v) + { + print "[$pname]: unregister key 0x$node_key from device $dev\n"; + } + if (!$key_list{$host_key}) { do_register($dev, $host_key); @@ -376,6 +411,10 @@ sub fence_node if (!$key_list{$node_key}) { + if ($opt_v) + { + print "[$pname]: key 0x$node_key is not registered with device $dev\n"; + } next; } @@ -394,12 +433,6 @@ sub fence_node die "Unable to execute sg_persist ($dev).\n" if ($?>>8); - while (<$out>) - { - chomp; - print "OUT: $_\n" if $opt_v; - } - close($in); close($out); close($err);