This is the mail archive of the
cluster-cvs@sourceware.org
mailing list for the cluster.
RHEL4 - fence_scsi: improve logging for debugging
- From: "Ryan O'Hara" <rohara at fedoraproject dot org>
- To: cluster-cvs-relay at redhat dot com
- Date: Wed, 10 Sep 2008 21:56:23 +0000 (UTC)
- Subject: RHEL4 - fence_scsi: improve logging for debugging
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=9538102331f90bc086329ffb50af82605c6716f4
Commit: 9538102331f90bc086329ffb50af82605c6716f4
Parent: d24259def729723cbc2bda9658d0bd9ba0bf7dae
Author: Ryan O'Hara <rohara@redhat.com>
AuthorDate: Wed Sep 10 16:55:04 2008 -0500
Committer: Ryan O'Hara <rohara@redhat.com>
CommitterDate: Wed Sep 10 16:56: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 e0da751..d5c34f3 100755
--- 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);