AFS-Monitor

 view release on metacpan or  search on metacpan

examples/afsmonitor  view on Meta::CPAN

my @cmhosts = ("www.openafs.org", "virtue.openafs.org", "andrew.e.kth.se");  # cache manager machines to monitor
my @fshosts = ("www.openafs.org", "virtue.openafs.org", "andrew.e.kth.se"); # file server machines to monitor
my $configfilename = 'configs/configfile';
my $badconfigfile  = 'configs/badconfig';
my $outputfilename = 'debug_out/outputfile';

my @tests;      # choose which tests to run
$tests[1] = 1;  # test of FS afsmonitor with detailed output file
$tests[2] = 2;  # test of CM afsmonitor
$tests[3] = 0;  # test of invalid file name
$tests[4] = 0;  # test of detailed flag without output flag
$tests[5] = 0;  # test of invalid FS host
$tests[6] = 0;  # test of invalid CM host
$tests[7] = 0;  # test of no flags
$tests[8] = 0;  # test of cmhosts and fshosts and config flags all at once
$tests[9] = 0;  # test of cmhosts and fshosts
$tests[10] = 0; # test of config file
$tests[11] = 0; # test of invalid config file
$tests[12] = 0; # test of config file with output file
$tests[13] = 0; # test of show and threshold parameters

my $all = 1;    # show all tests

my $showdump = 0;     # print entire contents of hash for each test
my $readable = 1;     # print readable formatted output (and execute

examples/rxdebug  view on Meta::CPAN

        printf "Cuid %x/%x", $val->{connections}->[$i]->{epoch}, $val->{connections}->[$i]->{cid};
      } else {
        printf "cid %x", $val->{connections}->[$i]->{cid};
      }
      if ($val->{connections}->[$i]->{error}) {
        print ", error ", $val->{connections}->[$i]->{error};
      }
      print "\n  serial $val->{connections}->[$i]->{serial}, ";
      print " natMTU $val->{connections}->[$i]->{natMTU}, ";

      if ($val->{connections}->[$i]->{flags}) {
        print "flags";
        if ($val->{connections}->[$i]->{flags} & constant("RX_CONN_MAKECALL_WAITING")) {
          print " MAKECALL_WAITING";
        }
        if ($val->{connections}->[$i]->{flags} & constant("RX_CONN_DESTROY_ME")) {
          print " DESTROYED";
        }
        if ($val->{connections}->[$i]->{flags} & constant("RX_CONN_USING_PACKET_CKSUM")) {
          print " pktCksum";
        }
        print ", ";
      }

      print "security index $val->{connections}->[$i]->{securityIndex}, ";
      if ($val->{connections}->[$i]->{type} == constant("RX_CLIENT_CONNECTION")) {
        print "client conn\n";
      } else {
        print "server conn\n";

examples/rxdebug  view on Meta::CPAN


      # print secStats if this connection has them
      if (exists $val->{connections}->[$i]->{secStats}) {
        my $secStatsType = $val->{connections}->[$i]->{secStats}->{type};
        if ($secStatsType == 0) {
          if ($val->{connections}->[$i]->{securityIndex} == 2) {
            print "  no GetStats procedure for security object\n";
          }
        } elsif ($secStatsType == 1) {
          print "  rxnull level=", $val->{connections}->[$i]->{secStats}->{level};
          print ", flags=", $val->{connections}->[$i]->{secStats}->{flags},"\n";
        } elsif ($secStatsType == 2) {
          print "  rxvab level=", $val->{connections}->[$i]->{secStats}->{level};
          print ", flags=", $val->{connections}->[$i]->{secStats}->{flags},"\n";
        } elsif ($secStatsType == 3) {
          my $secStatsLevel;
          my $secStatsFlags = $val->{connections}->[$i]->{secStats}->{flags};
          if ($val->{connections}->[$i]->{secStats}->{level} == 0) {
            $secStatsLevel = "clear";
          } elsif ($val->{connections}->[$i]->{secStats}->{level} == 1) {
            $secStatsLevel = "auth";
          } elsif ($val->{connections}->[$i]->{secStats}->{level} == 2) {
            $secStatsLevel = "crypt";
          } else {
            $secStatsLevel = "unknown";
          }
          print "  rxkad: level ", $secStatsLevel;
          if ($secStatsFlags) {
            print ", flags";
          }
          if ($secStatsFlags & 1) {
            print " unalloc";
          }
          if ($secStatsFlags & 2) {
            print " authenticated";
          }
          if ($secStatsFlags & 4) {
            print " expired";
          }

examples/rxdebug  view on Meta::CPAN

        } elsif ($val->{connections}->[$i]->{callMode}->[$j] == constant("RX_MODE_RECEIVING")) {
          print "receiving";
        } elsif ($val->{connections}->[$i]->{callMode}->[$j] == constant("RX_MODE_ERROR")) {
          print "error";
        } elsif ($val->{connections}->[$i]->{callMode}->[$j] == constant("RX_MODE_EOF")) {
          print "eof";
        } else {
          print "unknown";
        }

        # print flags for this call
        if ($val->{connections}->[$i]->{callFlags}->[$j]) {
          printf(", flags:");
          if ($val->{connections}->[$i]->{callFlags}->[$j] & constant("RX_CALL_READER_WAIT")) {
            print " reader_wait";
          }
          if ($val->{connections}->[$i]->{callFlags}->[$j] & constant("RX_CALL_WAIT_WINDOW_ALLOC")) {
            print " window_alloc";
          }
          if ($val->{connections}->[$i]->{callFlags}->[$j] & constant("RX_CALL_WAIT_WINDOW_SEND")) {
            print " window_send";
          }
          if ($val->{connections}->[$i]->{callFlags}->[$j] & constant("RX_CALL_WAIT_PACKETS")) {

examples/rxdebug  view on Meta::CPAN

        }
        if ($val->{connections}->[$i]->{callOther}->[$j] & constant("RX_OTHER_IN")) {
          print ", has_input_packets";
        }
        if ($val->{connections}->[$i]->{callOther}->[$j] & constant("RX_OTHER_OUT")) {
          print ", has_output_packets";
        }
        print "\n";
      }
    }
    # if -nodally flag was set, print number of dallying connections skipped
    if (exists $val->{dallyCounter}) {
      print "Skipped ", $val->{dallyCounter}, " dallying connections.\n";
    }
  } # done printing connections

  # print peers if they were returned
  if (exists $val->{peers}) {
    for (my $i = 0; $i <= $#{$val->{peers}}; $i++) {
      print "Peer at host ", $val->{peers}->[$i]->{host},
            ", port ", $val->{peers}->[$i]->{port}, "\n";

examples/rxdebug  view on Meta::CPAN

      my $tpeer_rtt = $val->{peers}->[$i]->{rtt} >> 3;
      my $tpeer_rtt_dev = $val->{peers}->[$i]->{rtt_dev} >> 2;
      printf("\trtt %d msec, rtt_dev %d msec\n",
             $tpeer_rtt, $tpeer_rtt_dev);

      my $timeoutusec = $val->{peers}->[$i]->{timeout}->{usec};
      $timeoutusec = $timeoutusec / 1000;
      printf("\ttimeout %d.%03d sec\n",
              $val->{peers}->[$i]->{timeout}->{sec}, $timeoutusec);

      # prints extra information if -long flag was set
      if (exists $val->{peers}->[$i]->{inPacketSkew}) {
        printf("\tin/out packet skew: %d/%d\n",
                $val->{peers}->[$i]->{inPacketSkew},
                $val->{peers}->[$i]->{outPacketSkew});
        printf("\tcongestion window %d, MTU %d\n",
                $val->{peers}->[$i]->{cwind},
                $val->{peers}->[$i]->{MTU});
        printf("\tcurrent/if/max jumbogram size: %d/%d/%d\n",
                $val->{peers}->[$i]->{nDgramPackets},
                $val->{peers}->[$i]->{ifDgramPackets},

pod/afsmon_stats.pod  view on Meta::CPAN

=item *

rx_dataPacketsReSent: Retransmissions sent.

=item *

rx_dataPacketsPushed: Retransmissions pushed by NACK.

=item *

rx_ignoreAckedPacket: Packets with ACKed flag on rxi_Start.

=item *

rx_totalRtt_Sec and rx_totalRtt_Usec: Total round trip time (in seconds and milliseconds).

=item *

rx_minRtt_Sec and rx_minRtt_Usec: Minimum round trip time (in seconds and milliseconds).

=item *

pod/afsmonitor.pod  view on Meta::CPAN


   time  host_name  CM|FS   list_of_measured_values

and specifies the time at which the list_of_measured_values were
gathered from the Cache Manager (CM) or File Server (FS) process
housed on host_name. On those occasion where probes fail, the
value -1 is reported instead of the list_of_measured_values.

If the administrator usually reviews the output file manually,
rather than using it as input to an automated analysis program or
script, including the B<detail> flag formats the data in a more
easily readable form.

=head1 THE CONFIGURATION FILE

To customize the B<afsmonitor> function, create an ASCII-format
configuration file and use the B<config> argument to name it. You
can specify the following in the configuration file:

=over

pod/rxdebug.pod  view on Meta::CPAN

=item *

C<dallyCounter>: the number of dallying connections skipped.

=item *

C<peers>: a reference to an array of hash references containing information about each peer.

=back

The simplest case would be if the version flag was set.
The hash table would have only three keys in it:
C<address>, C<port>, and C<version>.

For more details about the contents of the returned hash reference,
and an example of printing its entire contents in a readable format,
refer to the B<rxdebug> script in the B<examples> directory.


=head1 AUTHORS

pod/udebug.pod  view on Meta::CPAN


=item B<recoveryState>

If there are multiple database sites, and the B<server> argument
names the coordinator (synchronization site), then this entry will
contain a hexadecimal number that indicates the current state of the quorum.
A value of C<1f> indicates complete database synchronization, whereas a value
of C<f> means that the coordinator has the correct database but cannot contact
all secondary sites to determine if they also have it. Lesser values are
acceptable if the B<udebug> function is issued during coordinator election, but
they denote a problem if they persist. The individual flags have the
following meanings:

=over

=item C<0x1>

This machine is the coordinator

=item C<0x2>

pod/udebug.pod  view on Meta::CPAN

=item B<up>

1 if the Ubik process at the site is functioning correctly, 0 if it is not.

=item B<beaconSinceDown>

1 if the site has responded to the coordinator's last request for votes, 0 if it has not

=back

Including the B<long> flag produces peer entries even when the B<server>
argument names a secondary site, but in that case only the ip address is
guaranteed to be accurate. For example, the value in the B<remoteVersion> field
is usually 0.0, because secondary sites do not poll their peers for this
information. The values in the B<lastVoteTime> and B<lastBeaconSent> fields
indicate when this site last received or requested a vote as coordinator; they
generally indicate the time of the last coordinator election.

=back

For further details of interpreting the contents of the returned hash

src/Makefile.PL  view on Meta::CPAN

  die "\nCould not compile test code to retrieve the version of AFS system libraries...\n";
}
my $version = `./a.out` || die "\nCould not run test code to retrieve the version of AFS system libraries...\n";
unlink 'a.out', 'fotav.c';
print "AFS Version = $version \n";

if ($version =~ /3.[4,5]/) {
  die("This release does not support AFS 3.4/3.5 system libraries ...\n");
}

# set the compiler flag "-D$version" according to the AFS version
my ($d_flag, $a_flag) = ('', '');
if    ($version =~ /3.4/)   { $d_flag = 'AFS 3.4'; }
elsif ($version =~ /3.5/)   { $d_flag = 'AFS 3.5'; }
elsif ($version =~ /3.6/)   { $d_flag = 'AFS 3.6'; }
elsif ($version =~ /1.0/)   { $d_flag = 'OpenAFS 1.0'; }
elsif ($version =~ /1.1/)   { $d_flag = 'OpenAFS 1.1'; }
elsif ($version =~ /1.2/)   { $d_flag = 'OpenAFS 1.2'; }
elsif ($version =~ /1.4/)   { $d_flag = 'OpenAFS 1.4'; }
elsif ($version =~ /devel/) { $d_flag = 'OpenAFS devel'; }

if ($version =~ /openafs/)  { $a_flag = '-DOpenAFS'; }

$version =~ s/(<|>)//g;
if(version("openafs 1.2.8", $version) > 0) {
  $a_flag .= " -DUSE_GETCELLNAME";
}
if(version("openafs 1.2.5", $version) > 0) {
  $a_flag .= " -DGETREALCELLBYINDEX";
}
if(version("openafs 1.0.3", $version) > 0) {
  $a_flag .= " -DUSE_VOTEXDEBUG";
}
if($version =~ /devel/) {
  $a_flag .= " -DNOAFS_XSTATSCOLL_CBSTATS";
}
if($version =~ /openafs 1.4.0/) {
  $a_flag .= " -DNOAFS_XSTATSCOLL_CBSTATS";
}
if ($version =~ /openafs 1.4.1-rc/) {
  $a_flag .= " -DNOAFS_XSTATSCOLL_CBSTATS";
}
if ($version =~ /openafs 1.4.2/) {
  $a_flag .= " -DEXT2=extern";
}
if ($version !~ /1.4./) {
  $a_flag .= " -DNOAFS_XSTATSCOLL_CBSTATS";
}
$version = $d_flag;
$d_flag =~ tr/\. /__/;
$d_flag = '-D' . $d_flag;
$d_flag .= ' -DRXDEBUG';

# determine the alpha_sys value
my $alpha_sys = `$AFSPath/bin/fs sysname 2>&1` || 'unknown';
if ($alpha_sys =~ s/Current sysname (list|) is? //) {
  $alpha_sys =~ /(\w+)/;
  $alpha_sys = $1;
}

# print out a summary of determined data
print "Your AFS system library is located at:  $AFSPath \n";
print "              and it is major version:  $version \n";
print "Your AFS system type seems to be:       $alpha_sys \n\n";

# set the Makefile values
my %MakefileArgs = (
    'NAME'         => 'AFS::Monitor',
    'VERSION'      => "$VERSION",
    'DEFINE'	   => "$d_flag $a_flag",
    'INC'          => "-I$AFSPath/include",
    'LIBS'         => [
                       "-L$AFSPath/lib -L$AFSPath/lib/afs "
                       . join (
                                   " ", qw(
                                           -lfsprobe
                                           -lvolser
                                           -lvldb

                                           -lkauth

src/Makefile.PL  view on Meta::CPAN

  $MakefileArgs{DEFINE} .= ' -Dint32=afs_int32 -Duint32=afs_uint32' if $alpha_sys eq 'sun4x_56'; # From Peter@PSDT.com
  $MakefileArgs{LIBS}->[0] .= ' -lresolv -lsocket -lnsl -lintl -ldl';
  $MakefileArgs{CC} = 'gcc';
  #$MakefileArgs{LD} = 'gcc';
  $MakefileArgs{CCCDLFLAGS} = '-fPIC';
  $MakefileArgs{LIBS}->[0] .= " -R$AFSPath/lib";
} elsif ($Config{osname} =~ /linux/) {
  $MakefileArgs{LIBS}->[0] .= ' -lresolv';
###  $MakefileArgs{LDFLAGS} = "-Wl,-rpath -Wl,$AFSPath/lib";
} elsif ($Config{osname} =~ /darwin/) {
  $MakefileArgs{LDDLFLAGS} = $Config{lddlflags} . ' -lresolv -multiply_defined suppress -read_only_relocs suppress';
}
# elsif ($Config{osname} =~ /dec_osf/) {
# # hier fehlt noch was !!!!!
# }
else {
  warn("System type '$Config{osname}' not yet tested with this Makefile.PL...\n\n"
       . "Using the default values, which may or may not work\n"
       . "If it is working, please inform the maintainer of this package.\n"
       . "Thank you.\n\n");
}

src/Monitor.xs  view on Meta::CPAN

 *
 */

/* structures to store statistics in a format convenient to dump to the
screen */
/* for file servers */
struct fs_Display_Data {
   char hostName[HOST_NAME_LEN];
   int probeOK;                 /* 0 => probe failed */
   char data[NUM_FS_STAT_ENTRIES][FS_STAT_STRING_LEN];
   short threshOvf[NUM_FS_STAT_ENTRIES];    /* overflow flags */
   int ovfCount;                /* overflow count */
};
/* for cache managers */
struct cm_Display_Data {
   char hostName[HOST_NAME_LEN];
   int probeOK;                 /* 0 => probe failed */
   char data[NUM_CM_STAT_ENTRIES][CM_STAT_STRING_LEN];
   short threshOvf[NUM_CM_STAT_ENTRIES];    /* overflow flags */
   int ovfCount;                /* overflow count */
};



/*
 * from src/afsmonitor/afsmonitor.c
 *    ("$Header: /afs/slac/g/scs/slur/Repository/AFSDebug/Debug/src/Monitor.xs,v 1.2 2006/07/05 22:25:10 alfw Exp $");
 */

src/Monitor.xs  view on Meta::CPAN

   char *a_threshName;          /* threshold variable name */
   char *a_threshValue;         /* threshold value */
   char *a_actValue;            /* actual value */
   HV *ENTRY;
   char *buffer;
{
   char fileName[256];          /* file name to execute */
   int i;
   char *ch;
   int argNum;
   int anotherArg;              /* boolean used to flag if another arg is available */
   char args[20 * 256] = "";
   char fsHandler_args[20][256];


   /* get the filename to execute - the first argument */
   sscanf(a_handler, "%s", fileName);

   /* construct the contents of *argv[] */

   strncpy(fsHandler_args[0], fileName, 256);

src/Monitor.xs  view on Meta::CPAN

      return (-1);
   }

   /* parse config file */

   /* First Pass - check syntax and count number of servers and thresholds to monitor */

   *numFS = 0;
   *numCM = 0;
   threshCount = 0;
   error_in_config = 0; /* flag to note if config file has syntax errors */

   while ((fgets(line, CFG_STR_LEN, configFD)) != NULL) {
      opcode[0] = 0;
      arg1[0] = 0;
      arg2[0] = 0;
      arg3[0] = 0;
      arg4[0] = 0;
      sscanf(line, "%s %s %s %s %s", opcode, arg1, arg2, arg3, arg4);
      linenum++;
      /* fprintf(STDERR, "Got line %d: \"%s %s %s %s %s\"\n",

src/Monitor.xs  view on Meta::CPAN

      hv_store(HOSTINFO, "probeOK", 7, newSViv(0), 0);
   }
   else {   /* probe succeeded, update display data structures */
      hv_store(HOSTINFO, "probeOK", 7, newSViv(1), 0);

      my_fs_Results_ltoa(curr_fsDataP, a_fsResults);

      fs_Results_to_Hash(curr_fsDataP, HOSTINFO, fs_showFlags,
                         fs_showDefault);

      /* compare with thresholds and set the overflow flags.
       * note that the threshold information is in the hostEntry structure and
       * each threshold item has a positional index associated with it */

      /* locate the hostEntry for this host */
      done = 0;
      curr_host = FSnameList;
      for (i = 0; i < numFS; i++) {
         if (strcasecmp(curr_host->hostName, a_fsResults->connP->hostName)
             == 0) {
            done = 1;

src/Monitor.xs  view on Meta::CPAN

      else if(strncmp(key, "cmname", keylen) == 0 && keylen <= 6) {
        if (SvROK(value))
          host_array = (AV*) SvRV(value);
        else {
          host_array = av_make(1, &value);
          sv_2mortal((SV *) host_array);
        }
        numCMs = av_len(host_array) + 1;
      }
      else {
        sprintf(buffer, "Unrecognized flag: %s", key);
        BSETCODE(-1, buffer);
        XSRETURN_UNDEF;
      } /* end ifs */

    } /* end while */
    /* done parsing arguments */

    if (host_array == 0) {
      sprintf(buffer, "Missing required parameter 'cmname'");
      BSETCODE(-1, buffer);

src/Monitor.xs  view on Meta::CPAN

            else {
              host_array = av_make(1, &value);
              sv_2mortal((SV *) host_array);
            }
            numFSs = av_len(host_array) + 1;
          } else goto unrecognized;
        break;

        default:
          unrecognized:
          sprintf(buffer, "Unrecognized flag: %s", key);
          BSETCODE(-1, buffer);
          XSRETURN_UNDEF;
        break;
      } /* end switch */
    } /* end while */
    /* done parsing arguments */

    if (host_array == 0) {
      sprintf(buffer, "Missing required parameter 'fsname'");
      BSETCODE(-1, buffer);

src/Monitor.xs  view on Meta::CPAN

            else {
              host_array = av_make(1, &value);
              sv_2mortal((SV *) host_array);
            }
            numservers = av_len(host_array) + 1;
          } else goto unrecognized;
        break;

        default:
          unrecognized:
          sprintf(buffer, "Unrecognized flag: %s", key);
          BSETCODE(-1, buffer);
          XSRETURN_UNDEF;
        break;
      } /* end switch */
    } /* end while */
    /* done parsing arguments */

    if(numservers == 0) {
      sprintf(buffer, "Missing required parameter 'server'");
      BSETCODE(-1, buffer);

src/Monitor.xs  view on Meta::CPAN

        break;

        case 's':
          if(strncmp(key, "server", keylen) == 0 && keylen <= 6) {
            hostName = (char *) SvPV(value, PL_na);
          } else goto unrecognized;
        break;

        default:
          unrecognized:
          sprintf(buffer, "Unrecognized flag: %s", key);
          BSETCODE(-1, buffer);
          XSRETURN_UNDEF;
        break;
      } /* end switch */
    } /* end while */
    /* done parsing arguments */


    /* lookup host */
    if (hostName) {

src/Monitor.xs  view on Meta::CPAN

        break;

        case 's':
          if(strncmp(key, "servers", keylen) == 0 && keylen <= 7) {
            hostName = (char *) SvPV(value, PL_na);
          } else goto unrecognized;
        break;

        default:
          unrecognized:
          sprintf(buffer, "Unrecognized flag: %s", key);
          BSETCODE(-1, buffer);
          XSRETURN_UNDEF;
        break;
      } /* end switch */
    } /* end while */
    /* done parsing arguments */

    rx_Init(0);

    thp = hostutil_GetHostByName(hostName);

src/Monitor.xs  view on Meta::CPAN

      fs_showFlags[i] = 0;
    for(i=0; i<NUM_CM_STAT_ENTRIES; i++)
      cm_showFlags[i] = 0;

    /* parse arguments */
    num_args = hv_iterinit(args);
    /* fprintf(STDERR, "[afsmonitor] Parsing args now: %d\n", num_args); */
    while (num_args--) {
      value = hv_iternextsv(args, &key, &keylen);

      /* fprintf(STDERR, "got flag %s, size %d. %d remaining.\n", key, keylen, num_args); */

      switch (*key) {
        case 'c':
          if(keylen < 2) goto unrecognized;
          switch(key[1]) {
            case 'o':
              if(strncmp(key, "config", keylen) == 0 && keylen <= 6) {
                /* fprintf(STDERR, "flag %s recognized as config; value is %s\n",
                   key, (char *) SvPV(value, PL_na)); */
                config_filename = (char *) SvPV(value, PL_na);
              } else goto unrecognized;
            break;

            case 'm':
              if(keylen < 3) goto unrecognized;
              switch(key[2]) {
                case 'h':
                 if(strncmp(key, "cmhosts", keylen) == 0 && keylen <= 7) {
                   /* fprintf(STDERR, "flag %s recognized as cmhosts\n", key); */
                  if (SvROK(value))
                    host_array = (AV*) SvRV(value);
                  else {
                    host_array = av_make(1, &value);
                    sv_2mortal((SV *) host_array);
                  }
                   num = av_len(host_array);
                   /* fprintf(STDERR, "it has %d elements.\n", num+1); */
                   for(i=0; i<=num; i++) {
                     host = (char *) SvPV(*av_fetch(host_array, i, 0), PL_na);

src/Monitor.xs  view on Meta::CPAN

                       sprintf(buffer, "Could not parse cache manager %s. %s", host, buff2);
                       BSETCODE(180, buffer);
                       /* 180 is the exit code for this error in the original afsmonitor.c */
                       XSRETURN_UNDEF;
                     }
                   }
                 } else goto unrecognized;
                 break;
                case 's':
                 if(strncmp(key, "cmshow", keylen) == 0 && keylen <= 6) {
                   /* fprintf(STDERR, "flag %s recognized as cmshow\n", key); */
                   show_array = (AV*) SvRV(value);
                   num = av_len(show_array);
                   for (i=0; i<=num; i++) {
                     sprintf(buffer, "show cm %s", SvPV(*av_fetch(show_array, i, 0), PL_na));
                     code = my_parse_showEntry(buffer, &fs_showDefault, &cm_showDefault,
                                               fs_showFlags, cm_showFlags, buff2);
                     if(code) {
                       sprintf(buffer, "Error parsing cmshow flag. %s", buff2);
                       BSETCODE(-1, buffer);
                       XSRETURN_UNDEF;
                     }
                   }
                 } else goto unrecognized;
                 break;
                case 't':
                 if(strncmp(key, "cmthresh", keylen) == 0 && keylen <= 8) {
                   /* fprintf(STDERR, "flag %s recognized as cmthresh\n", key); */
                   cmthresh_array = (AV*) SvRV(value);
                 } else goto unrecognized;
                 break;
                default:
                 goto unrecognized;
              }
            break;

            default:
              goto unrecognized;
          }
          break;

        case 'd':
          if(strncmp(key, "detailed", keylen) == 0 && keylen <= 8) {
            /* fprintf(STDERR, "flag %s recognized as detailed; value is %d\n",
                       key, (int) SvIV(value)); */
            detailed = (int) SvIV(value);
          } else goto unrecognized;
        break;

        case 'f':
          if(keylen < 3 || key[1] != 's') goto unrecognized;
          switch(key[2]) {
            case 'h':
              if(strncmp(key, "fshosts", keylen) == 0 && keylen <= 7) {
                /* fprintf(STDERR, "flag %s recognized as fshosts\n", key); */
                if (SvROK(value))
                  host_array = (AV*) SvRV(value);
                else {
                  host_array = av_make(1, &value);
                  sv_2mortal((SV *) host_array);
                }
                num = av_len(host_array);
                /* fprintf(STDERR, "it has %d elements.\n", num+1); */
                for(i=0; i<=num; i++) {
                  host = (char *) SvPV(*av_fetch(host_array, i, 0), PL_na);

src/Monitor.xs  view on Meta::CPAN

                  if (code) {
                    sprintf(buffer, "Could not parse file server %s. %s", host, buff2);
                    BSETCODE(180, buffer);
                    XSRETURN_UNDEF;
                  }
                }
              } else goto unrecognized;
              break;
            case 's':
              if(strncmp(key, "fsshow", keylen) == 0 && keylen <= 6) {
                /* fprintf(STDERR, "flag %s recognized as fsshow\n", key); */
                show_array = (AV*) SvRV(value);
                num = av_len(show_array);
                for (i=0; i<=num; i++) {
                  sprintf(buffer, "show fs %s", SvPV(*av_fetch(show_array, i, 0), PL_na));
                  code = my_parse_showEntry(buffer, &fs_showDefault, &cm_showDefault,
                                            fs_showFlags, cm_showFlags, buff2);
                  if(code) {
                    sprintf(buffer, "Error parsing fsshow flag. %s", buff2);
                    BSETCODE(-1, buffer);
                    XSRETURN_UNDEF;
                  }
                }
              } else goto unrecognized;
              break;
            case 't':
              if(strncmp(key, "fsthresh", keylen) == 0 && keylen <= 8) {
                /* fprintf(STDERR, "flag %s recognized as fsthresh\n", key); */
                fsthresh_array = (AV*) SvRV(value);
              } else goto unrecognized;
              break;
            default:
              goto unrecognized;
          }
        break;

        case 'o':
          if(strncmp(key, "output", keylen) == 0 && keylen <= 6) {
            /* fprintf(STDERR, "flag %s recognized as output; value is %s\n",
                       key, (char *) SvPV(value, PL_na)); */
            output_filename = (char *) SvPV(value, PL_na);
          } else goto unrecognized;
        break;

        default:
          unrecognized:
          /* fprintf(STDERR,
                     "flag not recognized. (key: %s) (value: %s)\n",
                     key, (char *) SvPV(value, PL_na)); */
          sprintf(buffer, "Unrecognized flag: %s", key);
          BSETCODE(-1, buffer);
          XSRETURN_UNDEF;
      } /* end switch */
    } /* end while */
    /* done parsing arguments */

    /* Open output file, if provided. */
    if (output_filename) {
      outputFD = fopen(output_filename,"a");
      if (outputFD == (FILE *) NULL) {

src/Monitor.xs  view on Meta::CPAN

        thresh_host = 0;
        thresh_handler = "";
        thresh_entry = (HV*) SvRV(*av_fetch(fsthresh_array, i, 0));
        hv_iterinit(thresh_entry);
        while((value = hv_iternextsv(thresh_entry, &key, &keylen))) {
          if(strcmp(key, "host")==0) {
            thresh_host = (char *)SvPV(value, PL_na);
            he = GetHostByName(thresh_host);
            if(he == (struct hostent *) NULL) {
              sprintf(buffer,
                      "Couldn't parse fsthresh flag; unable to resolve hostname %s\n",
                      thresh_host);
              BSETCODE(-1, buffer);
              XSRETURN_UNDEF;
            }
            thresh_host = he->h_name;
          }
          else if(strcmp(key, "handler")==0) {
            thresh_handler = (char *) SvPV(value, PL_na);
          }
          else {

src/Monitor.xs  view on Meta::CPAN

        thresh_host = 0;
        thresh_handler = "";
        thresh_entry = (HV*) SvRV(*av_fetch(fsthresh_array, i, 0));
        hv_iterinit(thresh_entry);
        while((value = hv_iternextsv(thresh_entry, &key, &keylen))) {
          if(strcmp(key, "host") == 0) {
            thresh_host = (char *)SvPV(value, PL_na);
            he = GetHostByName(thresh_host);
            if(he == (struct hostent *) NULL) {
              sprintf(buffer,
                      "Couldn't parse fsthresh flag; unable to resolve hostname %s\n",
                      thresh_host);
              BSETCODE(-1, buffer);
              XSRETURN_UNDEF;
            }
            thresh_host = he->h_name;
          }
          else if(strcmp(key, "handler")==0) {
            thresh_handler = (char *) SvPV(value, PL_na);
          }
          else {

src/Monitor.xs  view on Meta::CPAN

        thresh_host = 0;
        thresh_handler = "";
        thresh_entry = (HV*) SvRV(*av_fetch(cmthresh_array, i, 0));
        hv_iterinit(thresh_entry);
        while((value = hv_iternextsv(thresh_entry, &key, &keylen))) {
          if(strcmp(key, "host")==0) {
            thresh_host = (char *)SvPV(value, PL_na);
            he = GetHostByName(thresh_host);
            if(he == (struct hostent *) NULL) {
              sprintf(buffer,
                      "Couldn't parse cmthresh flag; unable to resolve hostname %s\n",
                      thresh_host);
              BSETCODE(-1, buffer);
              XSRETURN_UNDEF;
            }
            thresh_host = he->h_name;
          }
          else if(strcmp(key, "handler")==0) {
            thresh_handler = (char *) SvPV(value, PL_na);
          }
          else {

src/Monitor.xs  view on Meta::CPAN

        thresh_host = 0;
        thresh_handler = "";
        thresh_entry = (HV*) SvRV(*av_fetch(cmthresh_array, i, 0));
        hv_iterinit(thresh_entry);
        while((value = hv_iternextsv(thresh_entry, &key, &keylen))) {
          if(strcmp(key, "host") == 0) {
            thresh_host = (char *)SvPV(value, PL_na);
            he = GetHostByName(thresh_host);
            if(he == (struct hostent *) NULL) {
              sprintf(buffer,
                      "Couldn't parse cmthresh flag; unable to resolve hostname %s\n",
                      thresh_host);
              BSETCODE(-1, buffer);
              XSRETURN_UNDEF;
            }
            thresh_host = he->h_name;
          }
          else if(strcmp(key, "handler")==0) {
            thresh_handler = (char *) SvPV(value, PL_na);
          }
          else {

src/Monitor.xs  view on Meta::CPAN

    struct hostent *th;
    register afs_int32 code;
    int nodally=0;
    int allconns=0;
    int rxstats=0;
    int onlyClient=0;
    int onlyServer=0;
    afs_int32 onlyHost = -1;
    short onlyPort = -1;
    int onlyAuth = 999;
    int flag;
    int dallyCounter;
    int withSecStats;
    int withAllConn;
    int withRxStats;
    int withWaiters;
    int withIdleThreads;
    int withPeers;
    struct rx_debugStats tstats;
    char *portName = (char *) NULL;
    char *hostName = (char *) NULL;
    struct rx_debugConn tconn;
    short noConns=0;
    short showPeers=0;
    short showLong=0;
    int version_flag=0;
    afs_int32 length=64;
    char version[64];
    char buffer[240]; /* for error messages */

    afs_uint32 supportedDebugValues = 0;
    afs_uint32 supportedStatValues = 0;
    afs_uint32 supportedConnValues = 0;
    afs_uint32 supportedPeerValues = 0;
    afs_int32 nextconn = 0;
    afs_int32 nextpeer = 0;

  size = hv_iterinit(args);
  /* fprintf(STDERR, "Parsing args now: %d\n", size); */
  while (size--) {
    char *flag;
    entry = hv_iternext(args);
    key = hv_iterkey(entry, &keylen);
    value = hv_iterval(args, entry);
    flag = key;
    /* fprintf(STDERR, "size = %d, format: got flag %s\n", size, key); */

    switch (*flag) {
    case 'a':
        if (memcmp( flag, "allconnections", 14) == 0 ) {
            allconns = (int) SvIV(value);
        }
        break;

    case 'l':
        if (memcmp( flag, "long", 4) == 0 ) {
            showLong = (int) SvIV(value);
        }
        break;

    case 'n':
        if (memcmp( flag, "nodally", 7) == 0 ) {
            nodally = (int) SvIV(value);
        } else if (memcmp( flag, "noconns", 7) == 0 ) {
            noConns = (int) SvIV(value);
        }
        break;

    case 'o':
        if (memcmp( flag, "onlyserver", 10) == 0 ) {
            onlyServer = (int) SvIV(value);
        } else if (memcmp( flag, "onlyclient", 10) == 0 ) {
            onlyClient = (int) SvIV(value);
        } else if (memcmp( flag, "onlyhost", 8) == 0 ) {
            char *name = (char *) SvPV(value, PL_na);
        struct hostent *th;
        th = hostutil_GetHostByName(name);
        if (!th) {
            sprintf(buffer, "rxdebug: host %s not found in host table", name);
            BSETCODE(-1, buffer);
            XSRETURN_UNDEF;
        }
        memcpy(&onlyHost, th->h_addr, sizeof(afs_int32));

        } else if (memcmp( flag, "onlyauth", 8) == 0 ) {
            char *name = (char *) SvPV(value, PL_na);
            if (strcmp (name, "clear") == 0) onlyAuth = 0;
            else if (strcmp (name, "auth") == 0) onlyAuth = 1;
            else if (strcmp (name, "crypt") == 0) onlyAuth = 2;
            else if ((strcmp (name, "null") == 0) ||
                     (strcmp (name, "none") == 0) ||
                     (strncmp (name, "noauth", 6) == 0) ||
                     (strncmp (name, "unauth", 6) == 0)) onlyAuth = -1;
            else {
              sprintf (buffer, "Unknown authentication level: %s", name);
              BSETCODE(-1, buffer);
              XSRETURN_UNDEF;
            }

        } else if (memcmp( flag, "onlyport", 8) == 0 ) {
            char *name = (char *) SvPV(value, PL_na);
            if ((onlyPort = rxdebug_PortNumber(name)) == -1)
              onlyPort = rxdebug_PortName(name);
            if (onlyPort == -1) {
              sprintf(buffer, "rxdebug: can't resolve port name %s", name);
              VSETCODE(-1, buffer);
              XSRETURN_UNDEF;
            }
        }

        break;

    case 'p':
        if (memcmp( flag, "port", 4) == 0 ) {
            portName = (char *) SvPV(value, PL_na);
        } else if (memcmp( flag, "peers", 5) == 0 ) {
           showPeers  = (int) SvIV(value);
        }
        break;

    case 'r':
        if (memcmp( flag, "rxstats", 7) == 0 ) {
            rxstats = (int) SvIV(value);
        }
        break;

    case 's':
        if (memcmp( flag, "servers", 7) == 0 ) {
            hostName = (char *) SvPV(value, PL_na);
        }
        break;

    case 'v':
        if (memcmp( flag, "version", 7) == 0 ) {
            version_flag = (int) SvIV(value);
        }
        break;

    default:
        break;
    } /* switch */
  } /* while */
  /*  fprintf(STDERR, "Done parsing args\n\n"); */

    /* lookup host */

src/Monitor.xs  view on Meta::CPAN

#ifdef STRUCT_SOCKADDR_HAS_SA_LEN
    taddr.sin_len = sizeof(struct sockaddr_in);
#endif
    code = bind(s, (struct sockaddr *) &taddr, sizeof(struct sockaddr_in));
    FSSETCODE(code);
    if (code) {
      perror("bind");
      XSRETURN_UNDEF;
    }

    if (version_flag) /* add version to RETVAL and finish */
    {
       code = rx_GetServerVersion(s, host, port, length, version);
       if (code < 0)
       {
          sprintf(buffer, "get version call failed with code %d, errno %d",code,errno);
          BSETCODE(code, buffer);
          XSRETURN_UNDEF;
       }
       hv_store(RETVAL, "version", 7, newSVpv(version, 0), 0);
       goto done;

src/Monitor.xs  view on Meta::CPAN


        RXSTATS = newHV();

        myPrintTheseStats(RXSTATS, &rxstats);

        hv_store(RETVAL, "rxstats", 7, newRV_inc((SV*)(RXSTATS)), 0);

      }
    }

    /* get connections unless -noconns flag was set */
    /* array of connections added at key 'connections' in RETVAL hash */
    if (!noConns) {
      if (allconns) {
        if (!withAllConn) {
          warn("WARNING: Server doesn't support retrieval of all connections,\n");
          warn("         getting only interesting instead.\n");
          }
      }

      CONNECTIONS = newAV();

src/Monitor.xs  view on Meta::CPAN

        if (code < 0) {
          warn("getconn call failed with code %d\n", code);
          break;
        }
        if (tconn.cid == 0xffffffff) {
          break;
        }

        /* see if we're in nodally mode and all calls are dallying */
        if (nodally) {
          flag = 0;
          for (j = 0; j < RX_MAXCALLS; j++) {
             if (tconn.callState[j] != RX_STATE_NOTINIT &&
                 tconn.callState[j] != RX_STATE_DALLY) {
               flag = 1;
               break;
             }
          }
          if (flag == 0) {
            /* this call looks too ordinary, bump skipped count and go
             * around again */
            dallyCounter++;
            continue;
          }
        }
        if ((onlyHost != -1) && (onlyHost != tconn.host)) continue;
        if ((onlyPort != -1) && (onlyPort != tconn.port)) continue;
        if (onlyServer && (tconn.type != RX_SERVER_CONNECTION)) continue;
        if (onlyClient && (tconn.type != RX_CLIENT_CONNECTION)) continue;

src/Monitor.xs  view on Meta::CPAN

        hostAddr.s_addr = tconn.host;
        hv_store(TCONN, "host", 4, newSVpv(inet_ntoa(hostAddr), 0), 0);
        hv_store(TCONN, "port", 4, newSViv(ntohs(tconn.port)), 0);

        hv_store(TCONN, "cid", 3, newSViv(tconn.cid), 0);
        hv_store(TCONN, "epoch", 5, newSViv(tconn.epoch), 0);
        hv_store(TCONN, "error", 5, newSViv(tconn.error), 0);
        hv_store(TCONN, "serial", 6, newSViv(tconn.serial), 0);
        hv_store(TCONN, "natMTU", 6, newSViv(tconn.natMTU), 0);

        hv_store(TCONN, "flags", 5, newSViv(tconn.flags), 0);

        hv_store(TCONN, "securityIndex", 13, newSViv(tconn.securityIndex), 0);

        hv_store(TCONN, "type", 4, newSViv(tconn.type), 0);

        if (withSecStats) {
          HV* SECSTATS = newHV();
          hv_store(SECSTATS, "type", 4,
                   newSViv(tconn.secStats.type), 0);
          hv_store(SECSTATS, "level", 5,
                   newSViv(tconn.secStats.level), 0);
          hv_store(SECSTATS, "flags", 5,
                   newSViv(tconn.secStats.flags), 0);
          hv_store(SECSTATS, "expires", 7,
                   newSViv(tconn.secStats.expires), 0);
          hv_store(SECSTATS, "packetsReceived", 15,
                   newSViv(tconn.secStats.packetsReceived), 0);
          hv_store(SECSTATS, "packetsSent", 11,
                   newSViv(tconn.secStats.packetsSent), 0);
          hv_store(SECSTATS, "bytesReceived", 13,
                   newSViv(tconn.secStats.bytesReceived), 0);
          hv_store(SECSTATS, "bytesSent", 9,
                   newSViv(tconn.secStats.bytesSent), 0);

src/ppport.h  view on Meta::CPAN

#  else
#	define dTHR extern int errno
#  endif
#endif

#ifndef boolSV
#	define boolSV(b) ((b) ? &PL_sv_yes : &PL_sv_no)
#endif

#ifndef gv_stashpvn
#	define gv_stashpvn(str,len,flags) gv_stashpv(str,flags)
#endif

#ifndef newSVpvn
#	define newSVpvn(data,len) ((len) ? newSVpv ((data), (len)) : newSVpv ("", 0))
#endif

#ifndef newRV_inc
/* Replace: 1 */
#	define newRV_inc(sv) newRV(sv)
/* Replace: 0 */



( run in 0.410 second using v1.01-cache-2.11-cpan-94b05bcf43c )