AFS-Monitor
view release on metacpan or search on metacpan
examples/xstat_fs_test view on Meta::CPAN
#!/usr/bin/perl -w
#
# Copyright © 2004-2006
# Alf Wachsmann <alfw@slac.stanford.edu> and
# Elizabeth Cassell <e_a_c@mailsnare.net>
#
# $Revision: 1.8 $ $Date: 2006/07/05 22:25:10 $ $Author: alfw $
#
use blib;
use strict;
use AFS::Monitor qw(xstat_fs_test constant);
use Data::Dumper;
#my @fsname = ("virtue.openafs.org", "andrew.e.kth.se");
my @fsname = ("afs101.slac.stanford.edu");
my @collID = (0, 1, 2, 3);
my @tests; # choose which tests to run
$tests[1] = 0; # test of fsname @fsname and collIDs @collID
$tests[2] = 0; # test of fsname but no collID
$tests[3] = 1; # test of single fsname with collID 0
$tests[4] = 1; # test of single fsname with collID 1
$tests[5] = 0; # test of single fsname with collID 2
$tests[6] = 1; # test of single fsname with collID 3
$tests[7] = 0; # test of single fsname but no single collID
my $all = 0;
my $showdump = 0; # print entire contents of hash for each test
my $formatted = 1; # print formatted like original xstat_fs_test program
print "# Starting now... #\n";
my $result;
if ($all || $tests[1]) {
print "\n******** TEST 1: ********\n";
print "\nxstat_fs_test -fsname ", join(" ", @fsname),
" -collID ", join(" ", @collID), "\n\n";
$result = xstat_fs_test(fsname => \@fsname,
collID => \@collID);
parse_result($result);
}
if ($all || $tests[2]) {
print "\n******** TEST 2: ********\n";
print "\nxstat_fs_test -fsname ", join(" ", @fsname), "\n\n";
$result = xstat_fs_test(fsname => \@fsname);
parse_result($result);
}
if ($all || $tests[3]) {
print "\n******** TEST 3: ********\n";
print "\nxstat_fs_test -fsname ", $fsname[0],
" -collID 0\n\n";
$result = xstat_fs_test(fsname => $fsname[0],
collID => 0);
parse_result($result);
}
if ($all || $tests[4]) {
print "\n******** TEST 4: ********\n";
print "\nxstat_fs_test -fsname ", $fsname[0],
" -collID 1\n\n";
$result = xstat_fs_test(fsname => $fsname[0],
collID => 1);
parse_result($result);
}
if ($all || $tests[5]) {
print "\n******** TEST 5: ********\n";
print "\nxstat_fs_test -fsname ", $fsname[0],
" -collID 2\n\n";
$result = xstat_fs_test(fsname => $fsname[0],
collID => 2);
parse_result($result);
}
if ($all || $tests[6]) {
print "\n******** TEST 6: ********\n";
print "\nxstat_fs_test -fsname ", $fsname[0],
" -collID 3\n\n";
$result = xstat_fs_test(fsname => $fsname[0],
collID => 3);
parse_result($result);
}
if ($all || $tests[7]) {
print "\n******** TEST 7: ********\n";
print "\nxstat_fs_test -fsname ", $fsname[0], "\n\n";
$result = xstat_fs_test(fsname => $fsname[0]);
parse_result($result);
}
sub parse_result {
my $info = shift;
if ($AFS::CODE) {
print "Error case: ", ref($info), "\n" if (defined($info));
# die("Error: AFS::CODE = $AFS::CODE (", ($AFS::CODE+0), ")\n");
print "Error: AFS::CODE = $AFS::CODE (", ($AFS::CODE+0), ")\n";
return;
}
if ($showdump) {
local $Data::Dumper::Quotekeys = 0;
local $Data::Dumper::Sortkeys = 1;
local $Data::Dumper::Indent = 1;
local $Data::Dumper::Varname = "xstat_fs_test";
local $Data::Dumper::Maxdepth = 2;
print Dumper($info);
}
if ($formatted) {
foreach my $host (@$info) {
print "\n------------------------------------------------------------\n";
if ($host->{probeOK} == 0) {
printf "FS_Handler: Probe 1 to File Server '$host->{hostName}' failed\n",
} elsif($host->{collectionNumber} == constant("AFS_XSTATSCOLL_CALL_INFO")) {
parse_CallInfo($host);
} elsif($host->{collectionNumber} == constant("AFS_XSTATSCOLL_PERF_INFO")) {
parse_PerfInfo($host);
} elsif($host->{collectionNumber} == constant("AFS_XSTATSCOLL_FULL_PERF_INFO")) {
parse_FullPerfInfo($host);
} elsif($host->{collectionNumber} == constant("AFS_XSTATSCOLL_CBSTATS")) {
parse_CbCounters($host);
} else {
print "Unknown collection: $host->{collectionNumber}\n";
}
}
}
}
sub parse_CallInfo {
my $host = shift;
printf("AFS_XSTATSCOLL_CALL_INFO (coll %d) for FS %s\n[Probe 1, %s]\n\n",
$host->{collectionNumber},
$host->{hostName},
scalar localtime $host->{probeTime});
for (my $i = 0; $i < $host->{data}->{AFS_CollData_len}; $i++) {
print $host->{i}, " ";
}
print "\n";
}
sub parse_PerfInfo {
my $host = shift;
printf("AFS_XSTATSCOLL_PERF_INFO (coll %d) for FS %s\n[Probe 1, %s]\n\n",
$host->{collectionNumber},
$host->{hostName},
scalar localtime($host->{probeTime}));
parse_OverallPerfInfo($host->{data});
}
sub parse_FullPerfInfo {
my $host = shift;
printf("AFS_XSTATSCOLL_FULL_PERF_INFO (coll %d) for FS %s\n[Probe 1, %s]\n\n",
$host->{collectionNumber},
$host->{hostName},
scalar localtime($host->{probeTime}));
parse_OverallPerfInfo($host->{data});
parse_DetailedPerfInfo($host->{data});
( run in 0.416 second using v1.01-cache-2.11-cpan-39bf76dae61 )