AFS-Monitor

 view release on metacpan or  search on metacpan

LICENSES/IBM-LICENSE  view on Meta::CPAN

   5. NO WARRANTY
   
   EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS
   PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY
   WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY
   OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
   responsible for determining the appropriateness of using and
   distributing the Program and assumes all risks associated with its
   exercise of rights under this Agreement, including but not limited to
   the risks and costs of program errors, compliance with applicable
   laws, damage to or loss of data, programs or equipment, and
   unavailability or interruption of operations.
   
   6. DISCLAIMER OF LIABILITY
   
   EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR
   ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT,
   INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING
   WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF
   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING

examples/rxdebug  view on Meta::CPAN

                   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;
  }

  # print entire hash to screen
  if ($showdump) {
    print Dumper($val);

examples/rxdebug  view on Meta::CPAN

  if (exists $val->{connections}) {
    for (my $i = 0; $i <= $#{$val->{connections}}; $i++) { # print each connection
      print "Connection from host ", $val->{connections}->[$i]->{host},
            ", port ", $val->{connections}->[$i]->{port},", ";

      if ($val->{connections}->[$i]->{epoch}) {
        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")) {

examples/rxdebug  view on Meta::CPAN

          print "hold, ";
        }

        # print call mode
        print "mode: ";
        if ($val->{connections}->[$i]->{callMode}->[$j] == constant("RX_MODE_SENDING")) {
          print "sending";
        } 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")) {

pod/afsmon_stats.pod  view on Meta::CPAN

GetXStats_max: Maximum execution time observed for GetXStats operations.

=back

File Server RPC Operation Errors Group (FS_RPCopErrors_group)

=over

=item *

FetchData_srv_err: Number of server-down errors during FetchData operations.

=item *

FetchData_net_err: Number of network errors during FetchData operations.

=item *

FetchData_prot_err_err: Number of protection violations during FetchData operations.

=item *

FetchData_vol_err: Number of volume related errors during FetchData operations.

=item *

FetchData_busy_err: Number of volume busy conditions during FetchData operations.

=item *

FetchData_other_err: Number of miscellaneous other errors during FetchData operations.

=item *

FetchACL_srv_err: Number of server-down errors during FetchACL operations.

=item *

FetchACL_net_err: Number of network errors during FetchACL operations.

=item *

FetchACL_prot_err: Number of protection violations during FetchACL operations.

=item *

FetchACL_vol_err: Number of volume related errors during FetchACL operations.

=item *

FetchACL_busy_err: Number of volume busy conditions encountered during FetchACL operations.

=item *

FetchACL_other_err: Number of miscellaneous other errors during FetchACL operations.

=item *

FetchStatus_srv_err: Number of server-down errors during FetchStatus operations.

=item *

FetchStatus_net_err: Number of network errors during FetchStatus operations.

=item *

FetchStatus_prot_err: Number of protection violations during FetchStatus operations.

=item *

FetchStatus_vol_err: Number of volume related errors during FetchStatus operations.

=item *

FetchStatus_busy_err: Number of volume busy conditions encountered during FetchStatus operations.

=item *

FetchStatus_other_err: Number of miscellaneous other errors during FetchStatus operations.

=item *

StoreData_srv_err: Number of server-down errors during StoreData operations.

=item *

StoreData_net_err: Number of network errors during StoreData operations.

=item *

StoreData_prot_err: Number of protection violations during StoreData operations.

=item *

StoreData_vol_err: Number of volume related errors during StoreData operations.

=item *

StoreData_busy_err: Number of volume busy conditions encountered during StoreData operations.

=item *

StoreData_other_err: Number of miscellaneous other errors during StoreData operations.

=item *

StoreACL_srv_err: Number of server-down errors during StoreACL operations.

=item *

StoreACL_net_err: Number of network errors during StoreACL operations.

=item *

StoreACL_prot_err: Number of protection violations during StoreACL operations.

=item *

StoreACL_vol_err: Number of volume related errors during StoreACL operations.

=item *

StoreACL_busy_err: Number of volume busy conditions encountered during StoreACL operations.

=item *

StoreACL_other_err: Number of miscellaneous other errors during StoreACL operations.

=item *

StoreStatus_srv_err: Number of server-down errors during StoreStatus operations.

=item *

StoreStatus_net_err: Number of network errors during StoreStatus operations.

=item *

StoreStatus_prot_err: Number of protection violations during StoreStatus operations.

=item *

StoreStatus_vol_err: Number of volume related errors during StoreStatus operations.

=item *

StoreStatus_busy_err: Number of volume busy conditions encountered during StoreStatus operations.

=item *

StoreStatus_other_err: Number of miscellaneous other errors during StoreStatus operations.

=item *

RemoveFile_srv_err: Number of server-down errors during RemoveFile operations.

=item *

RemoveFile_net_err: Number of network errors during RemoveFile operations.

=item *

RemoveFile_prot_err: Number of protection violations during RemoveFile operations.

=item *

RemoveFile_vol_err: Number of volume related errors during RemoveFile operations.

=item *

RemoveFile_busy_err: Number of volume busy conditions encountered during RemoveFile operations.

=item *

RemoveFile_other_err: Number of miscellaneous other errors during RemoveFile operations.

=item *

CreateFile_srv_err: Number of server-down errors during CreateFile operations.

=item *

CreateFile_net_err: Number of network errors during CreateFile operations.

=item *

CreateFile_prot_err: Number of protection violations during CreateFile operations.

=item *

CreateFile_vol_err: Number of volume related errors during CreateFile operations.

=item *

CreateFile_busy_err: Number of volume busy conditions encountered during CreateFile operations.

=item *

CreateFile_other_err: Number of miscellaneous other errors during CreateFile operations.

=item *

Rename_srv_err: Number of server-down errors during Rename operations.

=item *

Rename_net_err: Number of network errors during Rename operations.

=item *

Rename_prot_err: Number of protection violations during Rename operations.

=item *

Rename_vol_err: Number of volume related errors during Rename operations.

=item *

Rename_busy_err: Number of volume busy conditions encountered during Rename operations.

=item *

Rename_other_err: Number of miscellaneous other errors during Rename operations.

=item *

Symlink_srv_err: Number of server-down errors during Symlink operations.

=item *

Symlink_net_err: Number of network errors during Symlink operations.

=item *

Symlink_prot_err: Number of protection violations during Symlink operations.

=item *

Symlink_vol_err: Number of volume related errors during Symlink operations.

=item *

Symlink_busy_err: Number of volume busy conditions encountered during Symlink operations.

=item *

Symlink_other_err: Number of miscellaneous other errors during Symlink operations.

=item *

Link_srv_err: Number of server-down errors during Link operations.

=item *

Link_net_err: Number of network errors during Link operations.

=item *

Link_prot_err: Number of protection violations during Link operations.

=item *

Link_vol_err: Number of volume related errors during Link operations.

=item *

Link_busy_err: Number of volume busy conditions encountered during Link operations.

=item *

Link_other_err: Number of miscellaneous other errors during Link operations.

=item *

MakeDir_srv_err: Number of server-down errors during MakeDir operations.

=item *

MakeDir_net_err: Number of network errors during MakeDir operations.

=item *

MakeDir_prot_err: Number of protection violations during MakeDir operations.

=item *

MakeDir_vol_err: Number of volume related errors during MakeDir operations.

=item *

MakeDir_busy_err: Number of volume busy conditions encountered during MakeDir operations.

=item *

MakeDir_other_err: Number of miscellaneous other errors during MakeDir operations.

=item *

RemoveDir_srv_err: Number of server-down errors during RemoveDir operations.

=item *

RemoveDir_net_err: Number of network errors during RemoveDir operations.

=item *

RemoveDir_prot_err: Number of protection violations during RemoveDir operations.

=item *

RemoveDir_vol_err: Number of volume related errors during RemoveDir operations.

=item *

RemoveDir_busy_err: Number of volume busy conditions encountered during RemoveDir operations.

=item *

RemoveDir_other_err: Number of miscellaneous other errors during RemoveDir operations.

=item *

SetLock_srv_err: Number of server-down errors during SetLock operations.

=item *

SetLock_net_err: Number of network errors during SetLock operations.

=item *

SetLock_prot_err: Number of protection violations during SetLock operations.

=item *

SetLock_vol_err: Number of volume related errors during SetLock operations.

=item *

SetLock_busy_err: Number of volume busy conditions encountered during SetLock operations.

=item *

SetLock_other_err: Number of miscellaneous other errors during SetLock operations.

=item *

ExtendLock_srv_err: Number of server-down errors during ExtendLock operations.

=item *

ExtendLock_net_err: Number of network errors during ExtendLock operations.

=item *

ExtendLock_prot_err: Number of protection violations during ExtendLock operations.

=item *

ExtendLock_vol_err: Number of volume related errors during ExtendLock operations.

=item *

ExtendLock_busy_err: Number of volume busy conditions encountered during ExtendLock operations.

=item *

ExtendLock_other_err: Number of miscellaneous other errors during ExtendLock operations.

=item *

ReleaseLock_srv_err: Number of server-down errors during ReleaseLock operations.

=item *

ReleaseLock_net_err: Number of network errors during ReleaseLock operations.

=item *

ReleaseLock_prot_err: Number of protection violations during ReleaseLock operations.

=item *

ReleaseLock_vol_err: Number of volume related errors during ReleaseLock operations.

=item *

ReleaseLock_busy_err: Number of volume busy conditions encountered during ReleaseLock operations.

=item *

ReleaseLock_other_err: Number of miscellaneous other errors during ReleaseLock operations.

=item *

GetStatistics_srv_err: Number of server-down errors during GetStatistics operations.

=item *

GetStatistics_net_err: Number of network errors during GetStatistics operations.

=item *

GetStatistics_prot_err: Number of protection violations during GetStatistics operations.

=item *

GetStatistics_vol_err: Number of volume related errors during GetStatistics operations.

=item *

GetStatistics_busy_err: Number of volume busy conditions encountered during GetStatistics operations.

=item *

GetStatistics_other_err: Number of miscellaneous other errors during GetStatistics operations.

=item *

GiveUpCallbacks_srv_err: Number of server-down errors during GiveUpCallbacks operations.

=item *

GiveUpCallbacks_net_err: Number of network errors during GiveUpCallbacks operations.

=item *

GiveUpCallbacks_prot_err: Number of protection violations during GiveUpCallbacks operations.

=item *

GiveUpCallbacks_vol_err: Number of volume related errors during GiveUpCallbacks operations.

=item *

GiveUpCallbacks_busy_err: Number of volume busy conditions encountered during GiveUpCallbacks operations.

=item *

GiveUpCallbacks_other_err: Number of miscellaneous other errors during GiveUpCallbacks operations.

=item *

GetVolumeInfo_srv_err: Number of server-down errors during GetVolumeInfo operations.

=item *

GetVolumeInfo_net_err: Number of network errors during GetVolumeInfo operations.

=item *

GetVolumeInfo_prot_err: Number of protection violations during GetVolumeInfo operations.

=item *

GetVolumeInfo_vol_err: Number of volume related errors during GetVolumeInfo operations.

=item *

GetVolumeInfo_busy_err: Number of volume busy conditions encountered during GetVolumeInfo operations.

=item *

GetVolumeInfo_other_err: Number of miscellaneous other errors during GetVolumeInfo operations.

=item *

GetVolumeStatus_srv_err: Number of server-down errors during GetVolumeStatus operations.

=item *

GetVolumeStatus_net_err: Number of network errors during GetVolumeStatus operations.

=item *

GetVolumeStatus_prot_err: Number of protection violations during GetVolumeStatus operations.

=item *

GetVolumeStatus_vol_err: Number of volume related errors during GetVolumeStatus operations.

=item *

GetVolumeStatus_busy_err: Number of volume busy conditions encountered during GetVolumeStatus operations.

=item *

GetVolumeStatus_other_err: Number of miscellaneous other errors during GetVolumeStatus operations.

=item *

SetVolumeStatus_srv_err : Number of server-down errors during SetVolumeStatus operations.

=item *

SetVolumeStatus_net_err: Number of network errors during SetVolumeStatus operations.

=item *

SetVolumeStatus_prot_err: Number of protection violations during SetVolumeStatus operations.

=item *

SetVolumeStatus_vol_err: Number of volume related errors during SetVolumeStatus operations.

=item *

SetVolumeStatus_busy_err: Number of volume busy conditions encountered during SetVolumeStatus operations.

=item *

SetVolumeStatus_other_err: Number of miscellaneous other errors during SetVolumeStatus operations.

=item *

GetRootVolume_srv_err: Number of server-down errors during GetRootVolume operations.

=item *

GetRootVolume_net_err: Number of network errors during GetRootVolume operations.

=item *

GetRootVolume_prot_err: Number of protection violations during GetRootVolume operations.

=item *

GetRootVolume_vol_err: Number of volume related errors during GetRootVolume operations.

=item *

GetRootVolume_busy_err: Number of volume busy conditions encountered during GetRootVolume operations.

=item *

GetRootVolume_other_err: Number of miscellaneous other errors during GetRootVolume operations.

=item *

CheckToken_srv_err: Number of server-down errors during CheckToken operations.

=item *

CheckToken_net_err: Number of network errors during CheckToken operations.

=item *

CheckToken_prot_err: Number of protection violations during CheckToken operations.

=item *

CheckToken_vol_err: Number of volume related errors during CheckToken operations.

=item *

CheckToken_busy_err: Number of volume busy conditions encountered during CheckToken operations.

=item *

CheckToken_other_err: Number of miscellaneous other errors during CheckToken operations.

=item *

GetTime_srv_err: Number of server-down errors during GetTime operations.

=item *

GetTime_net_err: Number of network errors during GetTime operations.

=item *

GetTime_prot_err: Number of protection violations during GetTime operations.

=item *

GetTime_vol_err: Number of volume related errors during GetTime operations.

=item *

GetTime_busy_err: Number of volume busy conditions encountered during GetTime operations.

=item *

GetTime_other_err: Number of miscellaneous other errors during GetTime operations.

=item *

NGetVolumeInfo_srv_err: Number of server-down errors during NGetVolumeInfo operations.

=item *

NGetVolumeInfo_net_err: Number of network errors during NGetVolumeInfo operations.

=item *

NGetVolumeInfo_prot_err: Number of protection violations during NGetVolumeInfo operations.

=item *

NGetVolumeInfo_vol_err: Number of volume related errors during NGetVolumeInfo operations.

=item *

NGetVolumeInfo_busy_err: Number of volume busy conditions encountered during NGetVolumeInfo operations.

=item *

NGetVolumeInfo_other_err: Number of miscellaneous other errors during NGetVolumeInfo operations.

=item *

BulkStatus_srv_err: Number of server-down errors during BulkStatus operations.

=item *

BulkStatus_net_err: Number of network errors during BulkStatus operations.

=item *

BulkStatus_prot_err: Number of protection violations during BulkStatus operations.

=item *

BulkStatus_vol_err: Number of volume related errors during BulkStatus operations.

=item *

BulkStatus_busy_err: Number of volume busy conditions encountered during BulkStatus operations.

=item *

BulkStatus_other_err: Number of miscellaneous other errors during BulkStatus operations.

=item *

XStatsVersion_srv_err: Number of server-down errors during XStatsVersion operations.

=item *

XStatsVersion_net_err: Number of network errors during XStatsVersion operations.

=item *

XStatsVersion_prot_err: Number of protection violations during XStatsVersion operations.

=item *

XStatsVersion_vol_err: Number of volume related errors during XStatsVersion operations.

=item *

XStatsVersion_busy_err: Number of volume busy conditions encountered during XStatsVersion operations.

=item *

XStatsVersion_other_err: Number of miscellaneous other errors during XStatsVersion operations.

=item *

GetXStats_srv_err: Number of server-down errors during GetXStats operations.

=item *

GetXStats_net_err: Number of network errors during GetXStats operations.

=item *

GetXStats_prot_err: Number of protection violations during GetXStats operations.

=item *

GetXStats_vol_err: Number of volume related errors during GetXStats operations.

=item *

GetXStats_busy_err: Number of volume busy conditions encountered during GetXStats operations.

=item *

GetXStats_other_err: Number of miscellaneous other errors during GetXStats operations.

=back

File Server RPC Transfer Timings Group (FS_RPCopBytes_group)

=over

=item *

FetchData_xfers: Number of FetchData operations.

src/Monitor.pm  view on Meta::CPAN

              udebug
              cmdebug
              scout
              xstat_fs_test
              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;

src/Monitor.xs  view on Meta::CPAN



#if defined(AFS_3_4) || defined(AFS_3_5)
#else
#define int32 afs_int32
#define uint32 afs_uint32
#endif

const char *const xs_version = "Monitor.xs (Major Version 0.2 $Rev: 609 $)";

extern char *error_message();
extern struct hostent *hostutil_GetHostByName();
extern char *hostutil_GetNameByINet();

/* error handling macros */

#define SETCODE(code) set_code(code)
#define FSSETCODE(code) {if (code == -1) set_code(errno); else set_code(code);}
#define BSETCODE(code, msg) bv_set_code(code, msg)
#define VSETCODE(code, msg) bv_set_code(code, msg)

static int32 raise_exception = 0;


static void

src/Monitor.xs  view on Meta::CPAN

   int32 code;
{
   SV *sv = perl_get_sv("AFS::CODE", TRUE);
   sv_setiv(sv, (IV) code);
   if (code == 0) {
      sv_setpv(sv, "");
   }
   else {
      if (raise_exception) {
         char buffer[1024];
         sprintf(buffer, "AFS exception: %s (%d)", error_message(code), code);
         croak(buffer);
      }
      sv_setpv(sv, (char *)error_message(code));
   }
   SvIOK_on(sv);
}

/* end of error handling macros */


/* start of rxdebug helper functions */


/*
 * from src/rxdebug/rxdebug.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

 */

int
my_parse_threshEntry(a_line, global_fsThreshCount, global_cmThreshCount,
                     last_hostEntry, lastHostType, buffer)
   char *a_line;                /* line that is being parsed */
   int *global_fsThreshCount;   /* count of global file server thresholds */
   int *global_cmThreshCount;   /* count of global cache manager thresholds */
   struct afsmon_hostEntry *last_hostEntry; /* a pointer to the last host entry */
   int lastHostType;            /* points to an integer specifying whether the last host was fs or cm */
   char *buffer;                /* to return error messages in */
{
   char opcode[CFG_STR_LEN];    /* junk characters */
   char arg1[CFG_STR_LEN];      /* hostname or qualifier (fs/cm?)  */
   char arg2[CFG_STR_LEN];      /* threshold variable */
   char arg3[CFG_STR_LEN];      /* threshold value */
   char arg4[CFG_STR_LEN];      /* user's handler  */
   char arg5[CFG_STR_LEN];      /* junk characters */


   /* break it up */

src/Monitor.xs  view on Meta::CPAN

           (*global_fsThreshCount)++;
           break;
        case 1:    /* inc thresh count of last file server */
           last_hostEntry->numThresh++;
           break;
        case 2:
           sprintf(buffer,
                   "A threshold for a File Server cannot be placed after a Cache Manager host entry in the config file");
           return (-1);
        default:
           sprintf(buffer, "Programming error 1");
           return (-1);
      }
   }
   else if ((strcasecmp(arg1, "cm")) == 0) {
      switch (lastHostType) {
        case 0:    /* its a global threshold */
           (*global_cmThreshCount)++;
           break;
        case 2:    /* inc thresh count of last cache manager */
           last_hostEntry->numThresh++;
           break;
        case 1:
           sprintf(buffer,
                   "A threshold for a Cache Manager cannot be placed after a File Server host entry in the config file");
           return (-1);
        default:
           sprintf(buffer, "Programming error 2");
           return (-1);
      }
   }
   else {
      sprintf(buffer,
              "Syntax error. Second argument should be \"fs\" or \"cm\"");
      return (-1);
   }

   return (0);
}   /* my_parse_threshEntry() */



/*
 * from src/afsmonitor/afsmonitor.c

src/Monitor.xs  view on Meta::CPAN

         tmp_host = tmp_host->next;
      }
      (*global_TC)--;
      return (0);
   }

   /* it is not a global threshold, insert it in the thresh list of this
    * host only. We overwrite the global threshold if it was already set */

   if (*hostname == '\0') {
      sprintf(buffer, "Programming error 3");
      return (-1);
   }

   /* get the hostEntry that this threshold belongs to */
   tmp_host = Header;
   found = 0;
   for (i = 0; i < srvCount; i++) {
      if (strcasecmp(tmp_host->hostName, hostname) == 0) {
         found = 1;
         break;

src/Monitor.xs  view on Meta::CPAN

   int *numCM;
   int *lastHostType;
   struct afsmon_hostEntry **last_hostEntry;
   int *fs_showDefault;
   int *cm_showDefault;
   short *fs_showFlags;
   short *cm_showFlags;
   struct afsmon_hostEntry **FSnameList;
   struct afsmon_hostEntry **CMnameList;
{
   char buff1[256] = "";        /* for error messages */
   char buff2[256] = "";        /* for error messages returned from subroutines */
   FILE *configFD = 0;          /* config file descriptor */
   char line[4 * CFG_STR_LEN];  /* a line of config file */
   char opcode[CFG_STR_LEN];    /* specifies type of config entry */
   char arg1[CFG_STR_LEN];      /* hostname or qualifier (fs/cm?)  */
   char arg2[CFG_STR_LEN];      /* threshold variable */
   char arg3[CFG_STR_LEN];      /* threshold value */
   char arg4[CFG_STR_LEN];      /* user's handler  */
   struct afsmon_hostEntry *curr_host = 0;
   struct hostent *he = 0;      /* hostentry to resolve host name */
   char *handlerPtr = 0;        /* ptr to pass theresh handler string */
   int code = 0;                /* error code */
   int linenum = 0;             /* config file line number */
   int threshCount = 0;         /* count of thresholds for each server */
   int error_in_config = 0;     /* syntax errors in config file  ?? */
   int i = 0;
   int numBytes = 0;
   /* int global_ThreshFlag = 1; */
   int global_fsThreshCount = 0;
   int global_cmThreshCount = 0;
   static char last_fsHost[HOST_NAME_LEN];
   static char last_cmHost[HOST_NAME_LEN];

   /* open config file */
   configFD = fopen(a_config_filename, "r");

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

      else {
         /* fprintf(STDERR, " - unknown entry\n"); */
         sprintf(buff2, "Unknown opcode %s", opcode);
         code = 1;
      }

      if (code) {
         sprintf(buff1,
                 "Error processing config file line %d (\"%s %s %s %s %s\"). %s",
                 linenum, opcode, arg1, arg2, arg3, arg4, buff2);
         error_in_config = 1;
         BSETCODE(10, buff1);
         return (-1);
      }
   }
   /* fprintf(STDERR, "got to end of file.\n"); */

   if (error_in_config) {
      sprintf(buff1, "Error in config file. %s", buff2);
      BSETCODE(10, buff1);
      return (-1);
   }

   /* the threshold count of all hosts in increased by 1 for each global
    * threshold. If one of the hosts has a local threshold for the same
    * variable it would end up being counted twice. whats a few bytes of memory
    * wasted anyway ? */

src/Monitor.xs  view on Meta::CPAN


   /* Second Pass */

   fseek(configFD, 0, 0);   /* seek to the beginning */

   /* allocate memory for threshold lists */

   curr_host = *FSnameList;
   for (i = 0; i < *numFS; i++) {
      if (curr_host->hostName[0] == '\0') {
         sprintf(buff1, "Programming error 4");
         BSETCODE(20, buff1);
         return (-1);
      }
      if (curr_host->numThresh) {
         numBytes = curr_host->numThresh * sizeof(struct Threshold);
         curr_host->thresh = (struct Threshold *)malloc(numBytes);
         if (curr_host->thresh == (struct Threshold *) NULL) {
            sprintf(buff1, "Memory Allocation error 1");
            BSETCODE(25, buff1);
            return (-1);
         }
         memset(curr_host->thresh, 0, numBytes);
      }
      curr_host = curr_host->next;
   }

   curr_host = *CMnameList;
   for (i = 0; i < *numCM; i++) {
      if (curr_host->hostName[0] == '\0') {
         sprintf(buff1, "Programming error 5");
         BSETCODE(30, buff1);
         return (-1);
      }
      if (curr_host->numThresh) {
         numBytes = curr_host->numThresh * sizeof(struct Threshold);
         curr_host->thresh = (struct Threshold *)malloc(numBytes);
         if (curr_host->thresh == (struct Threshold *) NULL) {
            sprintf(buff1, "Memory Allocation error 2");
            BSETCODE(35, buff1);
            return (-1);
         }
         memset(curr_host->thresh, 0, numBytes);
      }
      curr_host = curr_host->next;
   }

   opcode[0] = 0;
   arg1[0] = 0;

src/Monitor.xs  view on Meta::CPAN

                                      &global_fsThreshCount, *FSnameList,
                                      last_fsHost, *numFS, buff2);

         else if (strcasecmp(arg1, "cm") == 0)
            code = my_store_threshold(2,    /* 2 = cm */
                                      arg2, arg3, handlerPtr,
                                      &global_cmThreshCount, *CMnameList,
                                      last_cmHost, *numCM, buff2);

         else {
            sprintf(buff1, "Programming error 6");
            BSETCODE(40, buff1);
            return (-1);
         }
         if (code) {
            sprintf(buff1,
                    "Error processing config file line %d (\"%s %s %s %s %s\"): Failed to store threshold. %s",
                    linenum, opcode, arg1, arg2, arg3, arg4, buff2);
            BSETCODE(45, buff1);
            return (-1);
         }

src/Monitor.xs  view on Meta::CPAN

                               *currCollIDP,
                               &srvVersionNumber,
                               &(xstat_fs_Results.probeTime),
                               &(xstat_fs_Results.data));
            code =
               ProbeHandler(xstat_fs_Results, xstat_fs_numServers, index,
                            buff2, argp);
            index++;

            if (code) {
               sprintf(buffer, "Handler returned error code %d. %s",
                       code, buff2);
               return (code);
            }

         }  /* For each collection */
      } /*Valid Rx connection */

      /*
       * Advance the xstat_fs connection pointer.
       */

src/Monitor.xs  view on Meta::CPAN


   PortToUse = XSTAT_FS_CBPORT;

   do {
      code = rx_Init(htons(PortToUse));
      if (code) {
         if (code == RX_ADDRINUSE) {
            PortToUse++;
         }
         else {
            sprintf(buffer, "Fatal error in rx_Init()");
            return (-1);
         }
      }
   } while (code);

    /*
     * Create a null Rx client security object, to be used by the
     * probe LWP.
     */
   secobj = rxnull_NewClientSecurityObject();

src/Monitor.xs  view on Meta::CPAN

   int idx;
   afs_int32 numLongs;


   fullP = (struct afs_stats_CMFullPerf *)
      (a_cmResults->data.AFSCB_CollData_val);

   /* There are 4 parts to CM statistics
    * - Overall performance statistics (including up/down statistics)
    * - This CMs FS RPC operations info
    * - This CMs FS RPC errors info
    * - This CMs FS transfers info
    * - Authentication info
    * - [Un]Replicated access info
    */


   /* copy overall performance statistics */
   srcbuf = (afs_int32 *) & (fullP->perf);
   idx = 0;

src/Monitor.xs  view on Meta::CPAN

      idx++;
      srcbuf++;
      tmpbuf = srcbuf++;    /* max time */
      sprintf(a_cmData->data[idx], "%d.%06d", *tmpbuf, *srcbuf);
      idx++;
      srcbuf++;
   }

   /*printf("Ending index value = %d\n",idx-1); */

   /* copy CMs individual FS RPC errors info */

   srcbuf = (afs_int32 *) (fullP->rpc.fsRPCErrors);
   for (i = 0; i < AFS_STATS_NUM_FS_RPC_OPS; i++) {
      sprintf(a_cmData->data[idx], "%d", *srcbuf);  /* server */
      idx++;
      srcbuf++;
      sprintf(a_cmData->data[idx], "%d", *srcbuf);  /* network */
      idx++;
      srcbuf++;
      sprintf(a_cmData->data[idx], "%d", *srcbuf);  /* prot */

src/Monitor.xs  view on Meta::CPAN

                                 &srvVersionNumber,
                                 &(xstat_cm_Results.probeTime),
                                 &(xstat_cm_Results.data));

            code =
               ProbeHandler(xstat_cm_Results, xstat_cm_numServers, index,
                            buff2, argp);
            index++;

            if (code) {
               sprintf(buffer, "Handler routine got error code %d. %s",
                       code, buff2);
               return (code);
            }

         }  /* For each collection */
      } /*Valid Rx connection */

      /*
       * Advance the xstat_fs connection pointer.
       */

src/Monitor.xs  view on Meta::CPAN

   if (xstat_cm_ConnInfo == (struct xstat_cm_ConnectionInfo *) NULL) {
      sprintf(buffer,
              "Can't allocate %d connection info structs (%d bytes)",
              xstat_cm_numServers,
              (xstat_cm_numServers * sizeof(struct xstat_cm_ConnectionInfo)));
      return (-1);  /*No cleanup needs to be done yet */
   }

   code = rx_Init(htons(0));
   if (code) {
      sprintf(buffer, "Fatal error in rx_Init(), error=%d", code);
      return (-1);
   }

    /*
     * Create a null Rx client security object, to be used by the
     * probe LWP.
     */
   secobj = rxnull_NewClientSecurityObject();
   if (secobj == (struct rx_securityClass *) NULL) {
      /*Delete already-malloc'ed areas */

src/Monitor.xs  view on Meta::CPAN

   struct AFSDBLock lock;
   afs_int32 code;
   HV *LOCK;
   HV *LOCKDESC;

   for (i = 0; i < 1000; i++) {
      code = RXAFSCB_GetLock(aconn, i, &lock);
      if (code) {
         if (code == 1)
            break;
         /* otherwise we have an unrecognized error */
         sprintf(buffer, "cmdebug: error checking locks: %s",
                 error_message(code));
         return code;
      }
      /* here we have the lock information, so display it, perhaps */
      if (aint32 || IsLocked(&lock.lock)) {
         LOCK = newHV();
         hv_store(LOCK, "name", 4, newSVpv(lock.name, 0), 0);
         LOCKDESC = newHV();
         my_PrintLock(&lock.lock, LOCKDESC);
         hv_store(LOCK, "lock", 4, newRV_inc((SV *) LOCKDESC), 0);
         av_store(LOCKS, i, newRV_inc((SV *) LOCK));

src/Monitor.xs  view on Meta::CPAN

   HV *NETFID;
   HV *CENTRY;
   HV *LOCK;

   for (i = 0; i < 10000; i++) {
      code = RXAFSCB_GetCE(aconn, i, &centry);
      if (code) {
         if (code == 1)
            break;
         sprintf(buffer, "cmdebug: failed to get cache entry %d (%s)", i,
                 error_message(code));
         return code;
      }

      CENTRY = newHV();

      hv_store(CENTRY, "addr", 4, newSViv(centry.addr), 0);

      if (centry.addr == 0) {
         /* PS output */
         NETFID = newHV();

src/Monitor.xs  view on Meta::CPAN

    HV *NETFID;
    HV *CENTRY;
    HV *LOCK;

    for (i = 0; i < 10000; i++) {
        code = RXAFSCB_GetCE(aconn, i, &centry);
        if (code) {
            if (code == 1)
                break;
            sprintf(buffer, "cmdebug: failed to get cache entry %d (%s)\n", i,
                   error_message(code));
            return code;
        }

        CENTRY = newHV();

        hv_store(CENTRY, "addr", 4, newSViv(centry.addr), 0);

        if (centry.addr == 0) {
            /* PS output */
            printf("Proc %4d sleeping at %08x, pri %3d\n",

src/Monitor.xs  view on Meta::CPAN

    HV *NETFID;
    HV *CENTRY;
    HV *LOCK;

    for (i = 0; i < 10000; i++) {
        code = RXAFSCB_GetCE64(aconn, i, &centry);
        if (code) {
            if (code == 1)
                break;
            sprintf(buffer, "cmdebug: failed to get cache entry %d (%s)\n", i,
                   error_message(code));
            return code;
        }

        CENTRY = newHV();

        hv_store(CENTRY, "addr", 4, newSViv(centry.addr), 0);

        if (centry.addr == 0) {
            /* PS output */
            NETFID = newHV();

src/Monitor.xs  view on Meta::CPAN

         if (code == RX_ADDRINUSE) {
            if (scout_debugfd) {
               fprintf(scout_debugfd,
                       "[%s] Callback port %d in use, advancing\n", rn,
                       PortToUse);
               fflush(scout_debugfd);
            }
            PortToUse++;
         }
         else {
            sprintf(buffer, "[%s] Fatal error in rx_Init()\n", rn);
            return (-1);
         }
      }
   } while (code);
   if (scout_debugfd) {
      fprintf(scout_debugfd, "[%s] Rx initialized on port %d\n", rn,
              PortToUse);
      fflush(scout_debugfd);
   }

src/Monitor.xs  view on Meta::CPAN



/* end of xstat_cm_test helper functions */



MODULE = AFS::Monitor    PACKAGE = AFS::Monitor    PREFIX = afs_
PROTOTYPES: ENABLE

BOOT:
    initialize_rxk_error_table();


void
afs_do_xstat_cm_test(args)
    HV* args = (HV*) SvRV($arg);
  PREINIT:
  PPCODE:
  {
    SV *value;
    I32 keylen = 0;

src/Monitor.xs  view on Meta::CPAN

      BSETCODE(code, buffer);
      if (scout_debugfd != (FILE *) NULL) {
        fprintf(scout_debugfd, "[%s] Closing debugging file\n", rn);
        fclose(scout_debugfd);
      }
      XSRETURN_UNDEF;
    }
    code = my_FS_Handler(fsprobe_Results, numservers, fsprobe_ConnInfo,
                         scout_debugfd, RETVAL, buff2);
    if (code) {
      sprintf(buffer, "[%s] Handler routine returned error code %d. %s", rn, code, buff2);
      BSETCODE(code, buffer);
      if (scout_debugfd != (FILE *) NULL) {
        fprintf(scout_debugfd, "[%s] Closing debugging file\n", rn);
        fclose(scout_debugfd);
      }
      XSRETURN_UNDEF;
    }

    if (scout_debugfd != (FILE *) NULL) {
       fprintf(scout_debugfd, "[%s] Closing debugging file\n", rn);

src/Monitor.xs  view on Meta::CPAN

             memset(&usdebug, 0, sizeof(usdebug));
             code = VOTE_SDebugOld(tconn, i, (struct ubik_sdebug_old *) ptr);
          }
          else
             code = VOTE_SDebug(tconn, i, &usdebug);
#endif

          if (code > 0)
                break;          /* done */
          if (code < 0) {
             warn("error code %d from VOTE_SDebug\n", code);
             break;
          }

          /* otherwise print the structure */
          USDEBUG = newHV();
          inhostAddr.s_addr = htonl(usdebug.addr);

          hv_store(USDEBUG, "addr", 4, newSVpv(afs_inet_ntoa(htonl(usdebug.addr)), 0), 0);

          ALTADDR = newAV();

src/Monitor.xs  view on Meta::CPAN

                   /* 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);
                     sprintf(buffer,"cm %s",host);
                     code = my_parse_hostEntry(buffer, &numFS, &numCM, &lastHostType,
                                            &last_hostEntry, &FSnameList, &CMnameList, buff2);
                     /* fprintf(STDERR, "got host: %s\n", host); */
                     if (code) {
                       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);

src/Monitor.xs  view on Meta::CPAN

        XSRETURN_UNDEF;
      }
      fclose (outputFD);
    }

    /* cannot use 'detailed' without 'output' */
    if (detailed) {
      if (!output_filename) {
        sprintf(buffer, "detailed switch can be used only with output switch");
        BSETCODE(165, buffer);
        /* 165 is the exit code for this error in the original afsmonitor.c */
        XSRETURN_UNDEF;
      }
    }

    /* The config option is mutually exclusive with the fshosts,cmhosts options */
    if (config_filename) {
      if (numFS || numCM) {
        sprintf(buffer,"Cannot use config option with fshosts or cmhosts");
        BSETCODE(170, buffer);
        /* 170 is the exit code for this error in the original afsmonitor.c */
        XSRETURN_UNDEF;
      }
    }
    else {
      if (!numFS && !numCM) {
        sprintf(buffer,"Must specify either config or (fshosts and/or cmhosts) options");
        BSETCODE(175, buffer);
        /* 175 is the exit code for this error in the original afsmonitor.c */
        XSRETURN_UNDEF;
      }
    }

    if (fsthresh_array) {
      if(!numFS) {
        sprintf(buffer, "Cannot use fsthresh option without specifying fshosts");
        BSETCODE(-1, buffer);
        XSRETURN_UNDEF;
      }

src/Monitor.xs  view on Meta::CPAN

          temp_host->numThresh += global_fsThreshCount;
          temp_host = temp_host->next;
        }
      }
      temp_host = FSnameList;
      for (i = 0; i < numFS; i++) {
        if (temp_host->numThresh) {
          numBytes = temp_host->numThresh * sizeof(struct Threshold);
          temp_host->thresh = (struct Threshold *)malloc(numBytes);
          if (temp_host->thresh == (struct Threshold *) NULL) {
            sprintf(buffer, "Memory Allocation error 1.5");
            BSETCODE(25, buffer);
            XSRETURN_UNDEF;
          }
          memset(temp_host->thresh, 0, numBytes);
        }
        temp_host = temp_host->next;
      }
      num = av_len(fsthresh_array);
      for (i=0; i<=num; i++) {
        thresh_host = 0;

src/Monitor.xs  view on Meta::CPAN

          temp_host->numThresh += global_cmThreshCount;
          temp_host = temp_host->next;
        }
      }
      temp_host = CMnameList;
      for (i = 0; i < numCM; i++) {
        if (temp_host->numThresh) {
          numBytes = temp_host->numThresh * sizeof(struct Threshold);
          temp_host->thresh = (struct Threshold *)malloc(numBytes);
          if (temp_host->thresh == (struct Threshold *) NULL) {
            sprintf(buffer, "Memory Allocation error 2.5");
            BSETCODE(25, buffer);
            XSRETURN_UNDEF;
          }
          memset(temp_host->thresh, 0, numBytes);
        }
        temp_host = temp_host->next;
      }
      num = av_len(cmthresh_array);
      for (i=0; i<=num; i++) {
        thresh_host = 0;

src/Monitor.xs  view on Meta::CPAN

        BSETCODE(-1, buffer);
        XSRETURN_UNDEF;
      }
      *collIDP = 2;     /* USE A macro for this */

      code = my_xstat_fs_Init(my_afsmon_FS_Handler, numFS, FSSktArray, numCollIDs,
                              collIDP, buff2, output_filename, detailed, FILESERV,
                              FSnameList, fs_showFlags, fs_showDefault);

      if (code) {
        sprintf(buffer,"my_xstat_fs_Init() returned error. %s", buff2);
        BSETCODE(125, buffer);
        XSRETURN_UNDEF;
      }
    }  /* end of process fileserver entries */

    /* process cache manager entries */
    if (numCM) {
    /* Allocate an array of sockets for each fileserver we monitor */

      CMsktbytes = numCM * sizeof(struct sockaddr_in);

src/Monitor.xs  view on Meta::CPAN

        BSETCODE(-1, buffer);
        XSRETURN_UNDEF;
      }
      *collIDP = 2;     /* USE A macro for this */

      code = my_xstat_cm_Init(my_afsmon_CM_Handler, numCM, CMSktArray, numCollIDs,
                              collIDP, buff2, output_filename, detailed, CACHEMAN,
                              CMnameList, cm_showFlags, cm_showDefault);

      if (code) {
        sprintf(buffer,"my_xstat_cm_Init() returned error. %s", buff2);
        BSETCODE(130, buffer);
        XSRETURN_UNDEF;
      }

    }  /* end of process fileserver entries */

  /* end from afsmon_execute() */

    SETCODE(0);

src/Monitor.xs  view on Meta::CPAN

    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); */

src/Monitor.xs  view on Meta::CPAN

    s = socket(AF_INET, SOCK_DGRAM, 0);
    taddr.sin_family = AF_INET;
    taddr.sin_port = 0;
    taddr.sin_addr.s_addr = 0;
#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);

src/Monitor.xs  view on Meta::CPAN

             (tconn.secStats.level != onlyAuth)) continue;
          }
        }
        TCONN = newHV();
        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) {

src/Monitor.xs  view on Meta::CPAN

    ST(0) = sv_2mortal(newRV_inc((SV*)RETVAL));
    SETCODE(0);
    XSRETURN(1);
}





void
afs_error_message(code)
        int32   code
    PPCODE:
    {
        ST(0) = sv_newmortal();
        sv_setpv(ST(0), (char *) error_message(code));
        XSRETURN(1);
    }



  /* this function is generated automatically by constant_gen */
  /* You didn't think I would type in this crap did you? */
  /* thats what perl is for :-) */

void

src/t/Monitor.t  view on Meta::CPAN

use strict;

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
is(constant('RX_CONN_DESTROY_ME'), 2, 'Constant RX_CONN_DESTROY_ME');
is(constant('RX_CONN_DESTROY_ME', 2), 2, 'Constant RX_CONN_DESTROY_ME with argument');
isnt(constant('zzz'), 2, 'Unknown Constant zzz');



( run in 0.664 second using v1.01-cache-2.11-cpan-65fba6d93b7 )