#!/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);
#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});
}
sub parse_OverallPerfInfo {
my $data = shift;
printf "\t%10d numPerfCalls\n\n", $data->{numPerfCalls};
printf "\t%10d vcache_L_Entries\n", $data->{vcache_L_Entries};
printf "\t%10d vcache_L_Allocs\n", $data->{vcache_L_Allocs};
printf "\t%10d vcache_L_Gets\n", $data->{vcache_L_Gets};
printf "\t%10d vcache_L_Reads\n", $data->{vcache_L_Reads};
printf "\t%10d vcache_L_Writes\n\n", $data->{vcache_L_Writes};
printf "\t%10d vcache_S_Entries\n", $data->{vcache_S_Entries};
printf "\t%10d vcache_S_Allocs\n", $data->{vcache_S_Allocs};
printf "\t%10d vcache_S_Gets\n", $data->{vcache_S_Gets};
printf "\t%10d vcache_S_Reads\n", $data->{vcache_S_Reads};
printf "\t%10d vcache_S_Writes\n\n", $data->{vcache_S_Writes};
printf "\t%10d vcache_H_Entries\n", $data->{vcache_H_Entries};
printf "\t%10d vcache_H_Gets\n", $data->{vcache_H_Gets};
printf "\t%10d vcache_H_Replacements\n\n", $data->{vcache_H_Replacements};
printf "\t%10d dir_Buffers\n", $data->{dir_Buffers};
printf "\t%10d dir_Calls\n", $data->{dir_Calls};
printf "\t%10d dir_IOs\n\n", $data->{dir_IOs};
printf "\t%10d rx_packetRequests\n", $data->{rx_packetRequests};
printf "\t%10d rx_noPackets_RcvClass\n", $data->{rx_noPackets_RcvClass};
printf "\t%10d rx_noPackets_SendClass\n", $data->{rx_noPackets_SendClass};
printf "\t%10d rx_noPackets_SpecialClass\n", $data->{rx_noPackets_SpecialClass};
printf "\t%10d rx_socketGreedy\n", $data->{rx_socketGreedy};
printf "\t%10d rx_bogusPacketOnRead\n", $data->{rx_bogusPacketOnRead};
printf "\t%10d rx_bogusHost\n", $data->{rx_bogusHost};
printf "\t%10d rx_noPacketOnRead\n", $data->{rx_noPacketOnRead};
printf "\t%10d rx_noPacketBuffersOnRead\n", $data->{rx_noPacketBuffersOnRead};
printf "\t%10d rx_selects\n", $data->{rx_selects};
printf "\t%10d rx_sendSelects\n", $data->{rx_sendSelects};
printf "\t%10d rx_packetsRead_RcvClass\n", $data->{rx_packetsRead_RcvClass};
printf "\t%10d rx_packetsRead_SendClass\n", $data->{rx_packetsRead_SendClass};
printf "\t%10d rx_packetsRead_SpecialClass\n", $data->{rx_packetsRead_SpecialClass};
printf "\t%10d rx_dataPacketsRead\n", $data->{rx_dataPacketsRead};
printf "\t%10d rx_ackPacketsRead\n", $data->{rx_ackPacketsRead};
printf "\t%10d rx_dupPacketsRead\n", $data->{rx_dupPacketsRead};
printf "\t%10d rx_spuriousPacketsRead\n", $data->{rx_spuriousPacketsRead};
printf "\t%10d rx_packetsSent_RcvClass\n", $data->{rx_packetsSent_RcvClass};
printf "\t%10d rx_packetsSent_SendClass\n", $data->{rx_packetsSent_SendClass};
printf "\t%10d rx_packetsSent_SpecialClass\n", $data->{rx_packetsSent_SpecialClass};
printf "\t%10d rx_ackPacketsSent\n", $data->{rx_ackPacketsSent};
printf "\t%10d rx_pingPacketsSent\n", $data->{rx_pingPacketsSent};
printf "\t%10d rx_abortPacketsSent\n", $data->{rx_abortPacketsSent};
printf "\t%10d rx_busyPacketsSent\n", $data->{rx_busyPacketsSent};
printf "\t%10d rx_dataPacketsSent\n", $data->{rx_dataPacketsSent};
printf "\t%10d rx_dataPacketsReSent\n", $data->{rx_dataPacketsReSent};
printf "\t%10d rx_dataPacketsPushed\n", $data->{rx_dataPacketsPushed};
printf "\t%10d rx_ignoreAckedPacket\n", $data->{rx_ignoreAckedPacket};
printf "\t%10d rx_totalRtt_Sec\n", $data->{rx_totalRtt_Sec};
printf "\t%10d rx_totalRtt_Usec\n", $data->{rx_totalRtt_Usec};
printf "\t%10d rx_minRtt_Sec\n", $data->{rx_minRtt_Sec};
printf "\t%10d rx_minRtt_Usec\n", $data->{rx_minRtt_Usec};
printf "\t%10d rx_maxRtt_Sec\n", $data->{rx_maxRtt_Sec};
printf "\t%10d rx_maxRtt_Usec\n", $data->{rx_maxRtt_Usec};
printf "\t%10d rx_nRttSamples\n", $data->{rx_nRttSamples};
printf "\t%10d rx_nServerConns\n", $data->{rx_nServerConns};
printf "\t%10d rx_nClientConns\n", $data->{rx_nClientConns};
printf "\t%10d rx_nPeerStructs\n", $data->{rx_nPeerStructs};
printf "\t%10d rx_nCallStructs\n", $data->{rx_nCallStructs};
printf "\t%10d rx_nFreeCallStructs\n", $data->{rx_nFreeCallStructs};
if (defined($data->{rx_nBusies})) { # only on OpenAFS-1.4.1
printf "\t%10d rx_nBusies\n\n", $data->{rx_nBusies};
printf "\t%10d fs_nBusies\n", $data->{fs_nBusies};
printf "\t%10d fs_GetCapabilities\n\n", $data->{fs_GetCapabilities};
}
printf "\t%10d host_NumHostEntries\n", $data->{host_NumHostEntries};
printf "\t%10d host_HostBlocks\n", $data->{host_HostBlocks};
printf "\t%10d host_NonDeletedHosts\n", $data->{host_NonDeletedHosts};
printf "\t%10d host_HostsInSameNetOrSubnet\n", $data->{host_HostsInSameNetOrSubnet};
printf "\t%10d host_HostsInDiffSubnet\n", $data->{host_HostsInDiffSubnet};
printf "\t%10d host_HostsInDiffNetwork\n", $data->{host_HostsInDiffNetwork};
printf "\t%10d host_NumClients\n", $data->{host_NumClients};
printf "\t%10d host_ClientBlocks\n\n", $data->{host_ClientBlocks};
printf "\t%10d sysname_ID\n", $data->{sysname_ID};
}
sub parse_DetailedPerfInfo {
my $data = shift;
printf "\t%10d epoch\n", $data->{epoch};
my $rpcop = $data->{rpcOpTimes};
parse_OpTiming("FetchData", $rpcop);
parse_OpTiming("FetchACL", $rpcop);
parse_OpTiming("FetchStatus", $rpcop);
parse_OpTiming("StoreData", $rpcop);
parse_OpTiming("StoreACL", $rpcop);
parse_OpTiming("StoreStatus", $rpcop);
parse_OpTiming("RemoveFile", $rpcop);
parse_OpTiming("CreateFile", $rpcop);
parse_OpTiming("Rename", $rpcop);
parse_OpTiming("Symlink", $rpcop);
parse_OpTiming("Link", $rpcop);
parse_OpTiming("MakeDir", $rpcop);
parse_OpTiming("RemoveDir", $rpcop);
parse_OpTiming("SetLock", $rpcop);
parse_OpTiming("ExtendLock", $rpcop);
parse_OpTiming("ReleaseLock", $rpcop);
parse_OpTiming("GetStatistics", $rpcop);
parse_OpTiming("GiveUpCallbacks", $rpcop);
parse_OpTiming("GetVolumeInfo", $rpcop);
parse_OpTiming("GetVolumeStatus", $rpcop);
parse_OpTiming("SetVolumeStatus", $rpcop);
parse_OpTiming("GetRootVolume", $rpcop);
parse_OpTiming("CheckToken", $rpcop);
parse_OpTiming("GetTime", $rpcop);
parse_OpTiming("NGetVolumeInfo", $rpcop);
parse_OpTiming("BulkStatus", $rpcop);
parse_OpTiming("XStatsVersion", $rpcop);
parse_OpTiming("GetXStats", $rpcop);
my $xferop = $data->{xferOpTimes};
parse_XferTiming("FetchData", $xferop);
parse_XferTiming("StoreData", $xferop);
}
sub parse_CbCounters {
my $host = shift;
printf("AFS_XSTATSCOLL_CBSTATS (coll %d) for FS %s\n[Probe 1, %s]\n\n",
$host->{collectionNumber},
$host->{hostName},
scalar localtime($host->{probeTime}));
printf "\t%10d DeleteFiles\n", $host->{CbCounters}->{DeleteFiles};
printf "\t%10d DeleteCallBacks\n", $host->{CbCounters}->{DeleteCallBacks};
printf "\t%10d BreakCallBacks\n", $host->{CbCounters}->{BreakCallBacks};
printf "\t%10d AddCallBack\n", $host->{CbCounters}->{AddCallBack};
printf "\t%10d GotSomeSpaces\n", $host->{CbCounters}->{GotSomeSpaces};
printf "\t%10d DeleteAllCallBacks\n", $host->{CbCounters}->{DeleteAllCallBacks};
printf "\t%10d nFEs\n", $host->{CbCounters}->{nFEs};
printf "\t%10d nCBs\n", $host->{CbCounters}->{nCBs};
printf "\t%10d nblks\n", $host->{CbCounters}->{nblks};
printf "\t%10d CBsTimedOut\n", $host->{CbCounters}->{CBsTimedOut};
printf "\t%10d nbreakers\n", $host->{CbCounters}->{nbreakers};
printf "\t%10d GSS1\n", $host->{CbCounters}->{GSS1};
printf "\t%10d GSS2\n", $host->{CbCounters}->{GSS2};
printf "\t%10d GSS3\n", $host->{CbCounters}->{GSS3};
printf "\t%10d GSS4\n", $host->{CbCounters}->{GSS4};
printf "\t%10d GSS5\n", $host->{CbCounters}->{GSS5};
}
sub parse_OpTiming {
my ($name, $rpcop) = @_;
printf("%15s: %d ops (%d OK); sum=%f, sqr=%f, min=%f, max=%f\n",
$name, $rpcop->{$name}->{numOps}, $rpcop->{$name}->{numSuccesses},
$rpcop->{$name}->{sumTime}, $rpcop->{$name}->{sqrTime},
$rpcop->{$name}->{minTime}, $rpcop->{$name}->{maxTime});
}
sub parse_XferTiming {
my ($name, $xferop) = @_;
printf("%s: %d xfers (%d OK), time sum=%f, sqr=%f, min=%f, max=%f\n",
$name, $xferop->{$name}->{numXfers}, $xferop->{$name}->{numSuccesses},
$xferop->{$name}->{sumTime}, $xferop->{$name}->{sqrTime},
$xferop->{$name}->{minTime}, $xferop->{$name}->{maxTime});
printf("\t[bytes: sum=%lu, min=%d, max=%d]\n",
$xferop->{$name}->{sumBytes},
$xferop->{$name}->{minBytes},
$xferop->{$name}->{maxBytes});
printf("\t[buckets: 0: %d, 1: %d, 2: %d, 3: %d, 4: %d, 5: %d, 6: %d, 7: %d, 8: %d]\n",
$xferop->{$name}->{count}->[0],
$xferop->{$name}->{count}->[1],
$xferop->{$name}->{count}->[2],
$xferop->{$name}->{count}->[3],
$xferop->{$name}->{count}->[4],
$xferop->{$name}->{count}->[5],
$xferop->{$name}->{count}->[6],
$xferop->{$name}->{count}->[7],
$xferop->{$name}->{count}->[8]);
}