view release on metacpan or search on metacpan
Makefile.PL view on Meta::CPAN
'NAME' => 'AFS::Monitor',
'VERSION' => $VERSION,
($] >= 5.005 ?
('AUTHOR' => 'Alf Wachsmann, Elizabeth Cassell, and Steven Jenkins',
'ABSTRACT' => 'Perl interface to AFS monitoring and debugging APIs'
) : () ),
'realclean' => {FILES => 'Makefile.bak pod/*.html pod/pod2htm* lib/AFS/*.pod lib/AFS/Monitor/*.pod examples/debug_out/debug examples/debug_out/outputfile lib'},
);
sub MY::postamble {
'
html: Makefile
cd pod && $(MAKE) html
pod: blib
cp pod/Monitor.pod lib/AFS/Monitor.pod
cp pod/afsmon_stats.pod lib/AFS/Monitor/afsmon_stats.pod
cp pod/afsmonitor.pod lib/AFS/Monitor/afsmonitor.pod
cp pod/cmdebug.pod lib/AFS/Monitor/cmdebug.pod
cp pod/rxdebug.pod lib/AFS/Monitor/rxdebug.pod
examples/Meltdown.pl view on Meta::CPAN
# Example:
# Meltdown.pl -s point -p 7000 -t 300
#
# Check the server 'point' on port '7000' with 5 minutes between
# rxdebug commands.
#
use blib;
use AFS::Monitor;
sub Usage {
print STDERR "\n\n$progName: collect rxdebug stats on AFS process.\n";
print STDERR "usage: $progName [options]\n";
print STDERR "options:\n";
print STDERR " -s <server> (required parameter, no default).\n";
print STDERR " -p <port> (default: 7000).\n";
print STDERR " -t <interval> (default: 1200 seconds).\n";
print STDERR " -C \n";
print STDERR " -h (help: show this help message).\n\n";
print STDERR "Example: $progName -s point -p 7000\n";
print STDERR "Collect statistics on server point for port 7000\n";
print STDERR "Refresh interval will default to 20 minutes (1200 seconds)\n\n";
exit 0;
} # Usage
sub Check_data {
#
# If a value is going to overflow the field length,
# then bump the field length to match the value.
# It won't be pretty but we'll have valid data.
#
(length $wproc > $Ln[0]) ? ($Ln[0] = length $wproc) : "";
(length $nobuf > $Ln[1]) ? ($Ln[1] = length $nobuf) : "";
(length $wpack > $Ln[2]) ? ($Ln[2] = length $wpack) : "";
(length $fpack > $Ln[3]) ? ($Ln[3] = length $fpack) : "";
(length $calls > $Ln[4]) ? ($Ln[4] = length $calls) : "";
(length $delta > $Ln[5]) ? ($Ln[5] = length $delta) : "";
(length $data > $Ln[6]) ? ($Ln[6] = length $data) : "";
(length $resend > $Ln[7]) ? ($Ln[7] = length $resend) : "";
(length $idle > $Ln[8]) ? ($Ln[8] = length $idle) : "";
} # Check_data
sub Header {
if ($csvmode != 1) {
print "\nhh:mm:ss wproc nobufs wpack fpack calls delta data resends idle\n";
} else { # assume CSV mode...
print "\nhh:mm:ss,wproc,nobufs,wpack,fpack,calls,delta,data,resends,idle\n";
}
} # Header
#
# don't buffer the output
#
examples/afsmonitor view on Meta::CPAN
{ host => "virtue.openafs.org",
dlocalAccesses => 1
}
],
);
parse_results($fsinfo, $cminfo);
}
sub parse_results {
if ($AFS::CODE) {
print "Error case: ", ref($fsinfo), "\n" if (defined($fsinfo));
print "Error case: ", ref($cminfo), "\n" if (defined($cminfo));
# die("Error: AFS::CODE = $AFS::CODE (", ($AFS::CODE+0), ")\n");
print "Error: AFS::CODE = $AFS::CODE (", ($AFS::CODE+0), ")\n";
return;
}
if ($showdump) {
examples/cmdebug view on Meta::CPAN
print "\ncmdebug -server $server -port $port\n\n";
($locks, $cache_entries) = cmdebug(server => $server,
port => $port
);
parse_result($locks, $cache_entries);
}
sub parse_result {
my $l = shift;
my $c = shift;
if ($AFS::CODE) {
print "Error case: ", ref($l), "\n" if (defined($l));
print "Error case: ", ref($c), "\n" if (defined($c));
# die("Error: AFS::CODE = $AFS::CODE (", ($AFS::CODE+0), ")\n");
print "Error: AFS::CODE = $AFS::CODE (", ($AFS::CODE+0), ")\n";
return;
}
examples/cmdebug view on Meta::CPAN
}
if ($centry->{states} & 0x80) {
print ", mapped";
}
print "\n";
}
}
}
sub print_lock {
my $lock = shift;
print "(";
if ($lock->{waitStates}) {
if($lock->{waitStates} & constant("READ_LOCK")) {
print "reader_waiting";
}
if($lock->{waitStates} & constant("WRITE_LOCK")) {
print "writer_waiting";
}
examples/rxdebug view on Meta::CPAN
rxstats => 1,
peers => 1,
long => 1,
servers => $servers,
port => $port
);
parse_results($rxdeb);
}
sub parse_results {
my $val = shift;
# if there was an error, print it and then return.
if ($AFS::CODE) {
print "Error case: ", ref($val), "\n" if (defined($val));
# die("Error: AFS::CODE = $AFS::CODE (", ($AFS::CODE+0), ")\n");
print "Error: AFS::CODE = $AFS::CODE (", ($AFS::CODE+0), ")\n";
return;
}
examples/scout view on Meta::CPAN
if ($all || $tests[2]) {
print "\n******** TEST 2: ********\n";
print "\nscout -server virtue.openafs.org\n\n";
$result = scout(server => "virtue.openafs.org");
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) {
examples/udebug view on Meta::CPAN
print "\nudebug -server $server -port $port\n\n";
$result = udebug(server => $server,
port => $port
);
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) {
examples/xstat_cm_test view on Meta::CPAN
print "\n******** TEST 4: ********\n";
print "\nxstat_cm_test -cmname ", $cmname[0], "\n\n";
$result = xstat_cm_test(cmname => $cmname[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) {
examples/xstat_cm_test view on Meta::CPAN
} elsif ($host->{collectionNumber} == constant("AFSCB_XSTATSCOLL_FULL_PERF_INFO")) {
PrintFullPerfInfo($host);
} else {
printf "** Unknown collection: %d\n", $host->{collectionNumber};
}
}
}
}
sub PrintPerfInfo {
my $host = shift;
printf("AFSCB_XSTATSCOLL_PERF_INFO (coll %d) for CM %s\n[Probe 1, %s]\n\n",
$host->{collectionNumber},
$host->{hostName},
scalar localtime $host->{probeTime});
PrintOverallPerfInfo($host->{data});
}
sub PrintFullPerfInfo {
my $host = shift;
printf("AFSCB_XSTATSCOLL_FULL_PERF_INFO (coll %d) for CM %s\n[Probe 1, %s]\n\n",
$host->{collectionNumber},
$host->{hostName},
scalar localtime $host->{probeTime});
print "Overall Performance Info:\n-------------------------\n";
PrintOverallPerfInfo($host->{data}->{perf});
examples/xstat_cm_test view on Meta::CPAN
print "\n[Un]replicated accesses:\n------------------------\n";
printf("\t%d unrep, %d rep, %d reps accessed, %d max reps/ref, %d first OK\n\n",
$accessinfP->{unreplicatedRefs},
$accessinfP->{replicatedRefs},
$accessinfP->{numReplicasAccessed},
$accessinfP->{maxReplicasPerRef},
$accessinfP->{refFirstReplicaOK});
}
sub PrintOverallPerfInfo {
my $perf = shift;
printf "\t%10d numPerfCalls\n", $perf->{numPerfCalls};
printf "\t%10d epoch\n", $perf->{epoch};
printf "\t%10d numCellsVisible\n", $perf->{numCellsVisible};
printf "\t%10d numCellsContacted\n", $perf->{numCellsContacted};
printf "\t%10d dlocalAccesses\n", $perf->{dlocalAccesses};
printf "\t%10d vlocalAccesses\n", $perf->{vlocalAccesses};
printf "\t%10d dremoteAccesses\n", $perf->{dremoteAccesses};
examples/xstat_cm_test view on Meta::CPAN
PrintUpDownStats($perf->{fs_UpDown}->[1]);
print "\tVL Server up/downtimes, same cell:\n";
PrintUpDownStats($perf->{vl_UpDown}->[0]);
print "\tVL Server up/downtimes, diff cell:\n";
PrintUpDownStats($perf->{vl_UpDown}->[1]);
}
sub PrintUpDownStats {
my $updown = shift;
printf "\t\t%10d numTtlRecords\n", $updown->{numTtlRecords};
printf "\t\t%10d numUpRecords\n", $updown->{numUpRecords};
printf "\t\t%10d numDownRecords\n", $updown->{numDownRecords};
printf "\t\t%10d sumOfRecordAges\n",$updown->{sumOfRecordAges};
printf "\t\t%10d ageOfYoungestRecord\n",$updown->{ageOfYoungestRecord};
printf "\t\t%10d ageOfOldestRecord\n",$updown->{ageOfOldestRecord};
printf "\t\t%10d numDowntimeIncidents\n",$updown->{numDowntimeIncidents};
printf "\t\t%10d numRecordsNeverDown\n",$updown->{numRecordsNeverDown};
examples/xstat_cm_test view on Meta::CPAN
printf "\t\tDowntime incident distribution:\n";
printf "\t\t\t%8d: 0 times\n", $updown->{downIncidents}->[0];
printf "\t\t\t%8d: 1 time\n", $updown->{downIncidents}->[1];
printf "\t\t\t%8d: 2 .. 5 times\n", $updown->{downIncidents}->[2];
printf "\t\t\t%8d: 6 .. 10 times\n", $updown->{downIncidents}->[3];
printf "\t\t\t%8d: 10 .. 50 times\n", $updown->{downIncidents}->[4];
printf "\t\t\t%8d: > 50 times\n", $updown->{downIncidents}->[5];
}
sub PrintRPCPerfInfo {
my $rpc = shift;
print "FS Operation Timings:\n---------------------\n";
foreach (sort keys %{$rpc->{fsRPCTimes}}) {
printf "%15s: %d ops (%d OK); sum=%f, sqr=%f, min=%f, max=%f\n",
$_,
$rpc->{fsRPCTimes}->{$_}->{numOps}, $rpc->{fsRPCTimes}->{$_}->{numSuccesses},
$rpc->{fsRPCTimes}->{$_}->{sumTime}, $rpc->{fsRPCTimes}->{$_}->{sqrTime},
$rpc->{fsRPCTimes}->{$_}->{minTime}, $rpc->{fsRPCTimes}->{$_}->{maxTime};
}
examples/xstat_cm_test view on Meta::CPAN
printf "%15s: %d ops (%d OK); sum=%f, sqr=%f, min=%f, max=%f\n",
$_,
$rpc->{cmRPCTimes}->{$_}->{numOps}, $rpc->{cmRPCTimes}->{$_}->{numSuccesses},
$rpc->{cmRPCTimes}->{$_}->{sumTime}, $rpc->{cmRPCTimes}->{$_}->{sqrTime},
$rpc->{cmRPCTimes}->{$_}->{minTime}, $rpc->{cmRPCTimes}->{$_}->{maxTime};
}
}
sub PrintCallInfo {
my $host = shift;
printf "AFSCB_XSTATSCOLL_CALL_INFO (coll %d) for CM %s\n[Probe 1, %s]\n\n",
$host->{collectionNumber},
$host->{hostName},
scalar localtime $host->{probeTime};
my $data = $host->{data};
printf "\t%10d afs_init\n", $data->{afs_init};
examples/xstat_fs_test view on Meta::CPAN
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) {
examples/xstat_fs_test view on Meta::CPAN
} 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};
examples/xstat_fs_test view on Meta::CPAN
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);
examples/xstat_fs_test view on Meta::CPAN
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};
examples/xstat_fs_test view on Meta::CPAN
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},
src/Makefile.PL view on Meta::CPAN
# change the library name of the AFS system library "libcmd"
$command = "\'s#-lcmd#$AFSPath/lib/afs/libcmd.a#\'";
system("perl -p -i.bak -e $command Makefile");
# make changes to the typemap file if Perl < 5.6.0
$command = "\'s#T_UV#T_IV#\'";
system("perl -p -i.bak -e $command typemap") unless $] >= 5.006;
sub version {
my ($testver, $compver) = @_;
$compver = $ENV{VERSION} unless defined $compver;
# Remove possible package name from both strings.
$testver =~ s/^([a-zA-Z][^-]*-)*//;
$compver =~ s/^([a-zA-Z][^-]*-)*//;
for my $char ('-', '\.') {
if ("$testver$compver" =~ /$char/) {
src/Monitor.pm view on Meta::CPAN
xstat_cm_test
);
# Other items we are prepared to export if requested
@EXPORT_OK = qw(
error_message
constant
);
sub rxdebug {
my %subreq;
# parse the arguments and build a hash to pass to the XS do_rxdebug call.
return eval {
while (@_) {
$_ = shift;
if ( @_ and $_[0] !~ /^-/ ) {
$subreq{$_} = shift;
}
else {
$subreq{$_} = 1;
}
}
my $rxd = do_rxdebug(\%subreq);
return $rxd;
}
}
sub afsmonitor {
my %subreq;
return eval {
while (@_) {
$_ = shift;
if ( @_ and $_[0] !~ /^-/ ) {
$subreq{$_} = shift;
}
else {
$subreq{$_} = 1;
}
}
my ($fs, $cm) = do_afsmonitor(\%subreq);
return ($fs, $cm);
}
}
sub cmdebug {
my %subreq;
return eval {
while (@_) {
$_ = shift;
if ( @_ and $_[0] !~ /^-/ ) {
$subreq{$_} = shift;
}
else {
$subreq{$_} = 1;
}
}
my ($locks, $cache_entries) = do_cmdebug(\%subreq);
return ($locks, $cache_entries);
}
}
sub udebug {
my %subreq;
return eval {
while (@_) {
$_ = shift;
if ( @_ and $_[0] !~ /^-/ ) {
$subreq{$_} = shift;
}
else {
$subreq{$_} = 1;
}
}
my $result = do_udebug(\%subreq);
return $result;
}
}
sub scout {
my %subreq;
return eval {
while (@_) {
$_ = shift;
if ( @_ and $_[0] !~ /^-/ ) {
$subreq{$_} = shift;
}
else {
$subreq{$_} = 1;
}
}
my $result = do_scout(\%subreq);
return $result;
}
}
sub xstat_fs_test {
my %subreq;
return eval {
while (@_) {
$_ = shift;
if ( @_ and $_[0] !~ /^-/ ) {
$subreq{$_} = shift;
}
else {
$subreq{$_} = 1;
}
}
my $result = do_xstat_fs_test(\%subreq);
return $result;
}
}
sub xstat_cm_test {
my %subreq;
return eval {
while (@_) {
$_ = shift;
if ( @_ and $_[0] !~ /^-/ ) {
$subreq{$_} = shift;
}
else {
$subreq{$_} = 1;
}
}
my $result = do_xstat_cm_test(\%subreq);
return $result;
}
}
sub AUTOLOAD {
# This AUTOLOAD is used to 'autoload' constants from the constant()
# XS function. If a constant is not found then control is passed
# to the AUTOLOAD in AutoLoader.
# taken from perl v5.005_02 for backward compatibility
my $constname;
($constname = $AUTOLOAD) =~ s/.*:://;
croak "& not defined" if $constname eq 'constant';
my $val = constant($constname, @_ ? $_[0] : 0);
src/Monitor.pm view on Meta::CPAN
goto &AutoLoader::AUTOLOAD;
}
else {
croak "Your vendor has not defined AFS macro $constname";
}
}
{
no strict 'refs';
# Fixed between 5.005_53 and 5.005_61
if ($] >= 5.00561) {
*$AUTOLOAD = sub () { $val };
}
else {
*$AUTOLOAD = sub { $val };
}
}
goto &$AUTOLOAD;
}
bootstrap AFS::Monitor $VERSION;
# Preloaded methods go here. Autoload methods go after __END__, and are
# processed by the autosplit program.
src/t/Monitor.t view on Meta::CPAN
use lib qw(../../inc ../inc ./inc);
use Test::More tests => 11;
BEGIN {
use_ok('AFS::Monitor', qw(error_message constant));
}
# Some very basic tests first:
sub foo { return &AFS::Monitor::RX_CALL_CLEARED }
# test error_message
is(error_message(267274), 'Unknown code pt 10 (267274)', 'Return Code 267274');
# test subroutine returning a constant
is(foo(42,17), 64, 'Sub Foo returns constant (2 args)');
is(foo(42), 64, 'Sub Foo returns constant (1 arg)');
is(foo(), 64, 'Sub Foo returns constant (no args)');
# test constant