AFS-Monitor

 view release on metacpan or  search on metacpan

src/Monitor.xs  view on Meta::CPAN

/***********************************************************************
 *
 * AFS.xs - AFS extensions for Perl
 *
 * RCS-Id: @(#)$Id: Monitor.xs,v 1.2 2006/07/05 22:25:10 alfw Exp $
 *
 * Copyright (c) 2003, International Business Machines Corporation and others.
 *
 * This software has been released under the terms of the IBM Public
 * License.  For details, see the IBM-LICENSE file in the LICENCES
 * directory or online at http://www.openafs.org/dl/license10.html
 *
 * Contributors
 *         2004-2006: Elizabeth Cassell <e_a_c@mailsnare.net>
 *                    Alf Wachsmann <alfw@slac.stanford.edu>
 *
 * The code for the original library were mainly taken from the AFS
 * source distribution, which comes with this message:
 *
 *    Copyright (C) 1989-1994 Transarc Corporation - All rights reserved
 *    P_R_P_Q_# (C) COPYRIGHT IBM CORPORATION 1987, 1988, 1989
 *
 ***********************************************************************/

#include "EXTERN.h"

#ifdef __sgi    /* needed to get a clean compile */
#include <setjmp.h>
#endif

#include <stdarg.h>

#include "perl.h"
#include "XSUB.h"
#include "ppport.h"

#include <afs/afsint.h>

#include <afs/kautils.h>

#include <afs/xstat_fs.h>
#include <afs/xstat_cm.h>
#include "afsmon-labels.h"  /* labels for afsmonitor variables */

#include <afs/fsprobe.h>

/* from volser/volser_prototypes.h */
extern void MapPartIdIntoName(afs_int32 partId, char *partName);


#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
bv_set_code(code, msg)
   int32 code;
   const char *msg;
{
   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)", msg, code);
         croak(buffer);
      }
      sv_setpv(sv, (char *)msg);
   }
   SvIOK_on(sv);
}

static void
set_code(code)
   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 $");
 */

static short
rxdebug_PortNumber(aport)
   register char *aport;
{
   register int tc;
   register short total;

   total = 0;
   while ((tc = (*aport++))) {
      if (tc < '0' || tc > '9')
         return -1; /* bad port number */
      total *= 10;
      total += tc - (int)'0';
   }
   return htons(total);
}


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

static short
rxdebug_PortName(char *aname)
{
   register struct servent *ts;
   ts = getservbyname(aname, (char *) NULL);
   if (!ts)
      return -1;
   return ts->s_port;   /* returns it in network byte order */
}


/*
 * replaces rx_PrintTheseStats() in original c code.
 * places stats in RXSTATS instead of printing them
 * from src/rx/rx.c
 *    ("$Header: /afs/slac/g/scs/slur/Repository/AFSDebug/Debug/src/Monitor.xs,v 1.2 2006/07/05 22:25:10 alfw Exp $");
 */

static void
myPrintTheseStats(HV *RXSTATS, struct rx_statistics *rxstats)
{
   HV *PACKETS;

src/Monitor.xs  view on Meta::CPAN

   if (a_type == FS) {  /* fs threshold */
      for (index = 0; index < NUM_FS_STAT_ENTRIES; index++) {
         if (strcasecmp(a_varName, fs_varNames[index]) == 0) {
            found = 1;
            break;
         }
      }
      if (!found) {
         sprintf(buffer, "Unknown FS threshold variable name %s", a_varName);
         return (-1);
      }
   }
   else if (a_type == CM) { /* cm threshold */
      for (index = 0; index < NUM_CM_STAT_ENTRIES; index++) {
         if (strcasecmp(a_varName, cm_varNames[index]) == 0) {
            found = 1;
            break;
         }
      }
      if (!found) {
         sprintf(buffer, "Unknown CM threshold variable name %s", a_varName);
         return (-1);
      }
   }
   else
      return (-1);

   /* if the global thresh count is not zero, place this threshold on
    * all the host entries  */

   if (*global_TC) {
      tmp_host = Header;
      for (i = 0; i < srvCount; i++) {
         threshP = tmp_host->thresh;
         done = 0;
         for (j = 0; j < tmp_host->numThresh; j++) {
            if ((threshP->itemName[0] == '\0') ||
                (strcasecmp(threshP->itemName, a_varName) == 0)) {
               strncpy(threshP->itemName, a_varName, THRESH_VAR_NAME_LEN);
               strncpy(threshP->threshVal, a_value, THRESH_VAR_LEN);
               strcpy(threshP->handler, a_handler);
               threshP->index = index;
               done = 1;
               break;
            }
            threshP++;
         }
         if (!done) {
            sprintf(buffer,
                    "Could not insert threshold entry for %s in thresh list of host %s",
                    a_varName, tmp_host->hostName);
            return (-1);
         }
         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;
      }
      tmp_host = tmp_host->next;
   }
   if (!found) {
      sprintf(buffer, "Unable to find host %s in %s hostEntry list", hostname,
              (a_type - 1) ? "CM" : "FS");
      return (-1);
   }

   /* put this entry on the thresh list of this host, overwrite global value
    * if needed */

   threshP = tmp_host->thresh;
   done = 0;
   for (i = 0; i < tmp_host->numThresh; i++) {
      if ((threshP->itemName[0] == '\0') ||
          (strcasecmp(threshP->itemName, a_varName) == 0)) {
         strncpy(threshP->itemName, a_varName, THRESH_VAR_NAME_LEN);
         strncpy(threshP->threshVal, a_value, THRESH_VAR_LEN);
         strcpy(threshP->handler, a_handler);
         threshP->index = index;
         done = 1;
         break;
      }
      threshP++;
   }

   if (!done) {
      sprintf(buffer, "Unable to insert threshold %s for %s host %s",
              a_varName, (a_type - 1) ? "CM" : "FS", tmp_host->hostName);
      return (-1);
   }

   return (0);

}   /* my_store_threshold() */



/*
 * 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 $");
 *
 * int
 * check_fs_thresholds(a_hostEntry, a_Data)
 * struct afsmon_hostEntry *a_hostEntry;
 * struct fs_Display_Data *a_Data;

src/Monitor.xs  view on Meta::CPAN

      }
   }
   /* 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 ? */

   if (global_fsThreshCount) {
      curr_host = *FSnameList;
      for (i = 0; i < *numFS; i++) {
         curr_host->numThresh += global_fsThreshCount;
         curr_host = curr_host->next;
      }
   }
   if (global_cmThreshCount) {
      curr_host = *CMnameList;
      for (i = 0; i < *numCM; i++) {
         curr_host->numThresh += global_cmThreshCount;
         curr_host = curr_host->next;
      }
   }

   /* make sure we have something to monitor */
   if (*numFS == 0 && *numCM == 0) {
      sprintf(buff1,
              "Config file must specify atleast one File Server or Cache Manager host to monitor.");
      fclose(configFD);
      BSETCODE(15, buff1);
      return (-1);
   }

   /* 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;
   arg2[0] = 0;
   arg3[0] = 0;
   arg4[0] = 0;
   last_fsHost[0] = '\0';
   last_cmHost[0] = '\0';
   linenum = 0;
   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++;

      /* if we have a host entry, remember the host name */
      if (strcasecmp(opcode, "fs") == 0) {
         he = GetHostByName(arg1);
         strncpy(last_fsHost, he->h_name, HOST_NAME_LEN);
      }
      else if (strcasecmp(opcode, "cm") == 0) {
         he = GetHostByName(arg1);
         strncpy(last_cmHost, he->h_name, HOST_NAME_LEN);
      }
      else if (strcasecmp(opcode, "thresh") == 0) {
         /* if we have a threshold handler it may have arguments
          * and the sscanf() above would not get them, so do the
          * following */
         if (strlen(arg4)) {
            handlerPtr = line;
            /* now skip over 4 words - this is done by first
             * skipping leading blanks then skipping a word */
            for (i = 0; i < 4; i++) {
               while (isspace(*handlerPtr))
                  handlerPtr++;
               while (!isspace(*handlerPtr))
                  handlerPtr++;
            }
            while (isspace(*handlerPtr))
               handlerPtr++;
            /* we how have a pointer to the start of the handler
             * name & args */
         }
         else
            handlerPtr = arg4;  /* empty string */

         if (strcasecmp(arg1, "fs") == 0)
            code = my_store_threshold(1,    /* 1 = fs */
                                      arg2, arg3, handlerPtr,
                                      &global_fsThreshCount, *FSnameList,
                                      last_fsHost, *numFS, buff2);

         else if (strcasecmp(arg1, "cm") == 0)
            code = my_store_threshold(2,    /* 2 = cm */

src/Monitor.xs  view on Meta::CPAN

   while (secidx < FS_NUM_DATA_CATEGORIES) {

      sscanf(fs_categories[secidx], "%s %d", section, &numgrp);
      SECTION = newHV();

      while (grpidx <= secidx + numgrp) {
         GROUP = newHV();
         sscanf(fs_categories[grpidx], "%s %d %d", group, &fromidx, &toidx);
         for (i = fromidx; i <= toidx; i++) {
            if (showFlags[i] || showDefault) {
               ENTRY = newHV();
               hv_store(ENTRY, "value", 5, newSVnv(atof(fsData->data[i])), 0);
               hv_store(GROUP, fs_varNames[i], strlen(fs_varNames[i]),
                        newRV_inc((SV *) ENTRY), 0);
            }
         }
         if (HvKEYS(GROUP))
            hv_store(SECTION, group, strlen(group), newRV_inc((SV *) GROUP),
                     0);
         grpidx++;
      }
      if (HvKEYS(SECTION))
         hv_store(HOSTINFO, section, strlen(section),
                  newRV_inc((SV *) SECTION), 0);
      secidx += numgrp + 1;
      grpidx = secidx + 1;
   }
}   /* fs_Results_to_Hash() */



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

int
my_save_FS_data_forDisplay(a_fsResults, HOSTINFO, numFS, FSnameList,
                           fs_showFlags, fs_showDefault, buffer)
   struct xstat_fs_ProbeResults *a_fsResults;
   HV *HOSTINFO;
   int numFS;
   struct afsmon_hostEntry *FSnameList;
   short *fs_showFlags;
   int fs_showDefault;
   char *buffer;
{
   struct fs_Display_Data *curr_fsDataP;
   struct afsmon_hostEntry *curr_host = 0;
   int i = 0;
   int code = 0;
   int done = 0;
   char buff2[256] = "";

   curr_fsDataP =
      (struct fs_Display_Data *)malloc(sizeof(struct fs_Display_Data));
   if (curr_fsDataP == (struct fs_Display_Data *) NULL) {
      sprintf(buffer, "Memory allocation failure");
      return (-1);
   }
   memset(curr_fsDataP, 0, sizeof(struct fs_Display_Data));

   hv_store(HOSTINFO, "hostName", 8, newSVpv(a_fsResults->connP->hostName, 0),
            0);

   /*  Check the status of the probe. If it succeeded, we store its
    * results in the display data structure. If it failed we only mark
    * the failed status in the display data structure. */

   if (a_fsResults->probeOK) {  /* 1 => notOK the xstat results */
      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;
            break;
         }
         curr_host = curr_host->next;;
      }
      if (!done) {
         sprintf(buffer, "Error storing results for FS host %s (70)",
                 a_fsResults->connP->hostName);
         return (70);
      }

      code = my_check_thresholds(curr_host, HOSTINFO, FS, buff2);
      if (code) {
         sprintf(buffer, "Error in checking thresholds (75) %s", buff2);
         return (75);
      }

   }    /* the probe succeeded, so we store the data in the display structure */
   return (0);

}   /* my_save_FS_data_forDisplay() */



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

int
my_afsmon_FS_Handler(xstat_fs_Results, numFS, conn_idx, buffer, argp)
   struct xstat_fs_ProbeResults xstat_fs_Results;
   int numFS;
   int conn_idx;
   char *buffer;
   va_list argp;
{
   char *outputfile = va_arg(argp, char *);
   int detailed = va_arg(argp, int);
   AV *FILESERV = va_arg(argp, AV *);
   struct afsmon_hostEntry *FSnameList =
      va_arg(argp, struct afsmon_hostEntry *);
   short *fs_showFlags = va_arg(argp, short *);
   int fs_showDefault = va_arg(argp, int);

   HV *HOSTINFO = newHV();

   int code = 0;

   if (outputfile)
      my_afsmon_fsOutput(outputfile, detailed, xstat_fs_Results);

src/Monitor.xs  view on Meta::CPAN

   /* Add HOSTINFO to FS */
   av_store(FILESERV, conn_idx, newRV_inc((SV *) (HOSTINFO)));
   return (0);

}   /* my_afsmon_FS_Handler() */




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

int
my_xstat_fs_LWP(ProbeHandler, xstat_fs_ConnInfo, xstat_fs_numServers,
                xstat_fs_collIDP, xstat_fs_numCollections, buffer, argp)
   int (*ProbeHandler) ();
   struct xstat_fs_ConnectionInfo *xstat_fs_ConnInfo;
   int xstat_fs_numServers;
   afs_int32 *xstat_fs_collIDP;
   int xstat_fs_numCollections;
   char *buffer;
   va_list argp;
{
   afs_int32 srvVersionNumber = 0;  /*Xstat version # */
   afs_int32 clientVersionNumber = AFS_XSTAT_VERSION;   /*Client xstat version */
   afs_int32 *currCollIDP = 0;
   int numColls = 0;
   int conn_idx = 0;
   struct xstat_fs_ConnectionInfo *curr_conn = 0;
   char buff2[256] = "";
   int code = 0;
   int index = 0;

   struct xstat_fs_ProbeResults xstat_fs_Results;
   afs_int32 xstat_fsData[AFS_MAX_XSTAT_LONGS];
   xstat_fs_Results.probeTime = 0;
   xstat_fs_Results.connP = (struct xstat_fs_ConnectionInfo *) NULL;
   xstat_fs_Results.collectionNumber = 0;
   xstat_fs_Results.data.AFS_CollData_len = AFS_MAX_XSTAT_LONGS;
   xstat_fs_Results.data.AFS_CollData_val = (afs_int32 *) xstat_fsData;
   xstat_fs_Results.probeOK = 0;

   curr_conn = xstat_fs_ConnInfo;
   for (conn_idx = 0; conn_idx < xstat_fs_numServers; conn_idx++) {
      /*
       * Grab the statistics for the current File Server, if the
       * connection is valid.
       */
      if (curr_conn->rxconn != (struct rx_connection *) NULL) {

         currCollIDP = xstat_fs_collIDP;
         for (numColls = 0;
              numColls < xstat_fs_numCollections; numColls++, currCollIDP++) {
            /*
             * Initialize the per-probe values.
             */
            xstat_fs_Results.collectionNumber = *currCollIDP;
            xstat_fs_Results.data.AFS_CollData_len = AFS_MAX_XSTAT_LONGS;
            memset(xstat_fs_Results.data.AFS_CollData_val, 0,
                   AFS_MAX_XSTAT_LONGS * 4);

            xstat_fs_Results.connP = curr_conn;

            xstat_fs_Results.probeOK =
               RXAFS_GetXStats(curr_conn->rxconn,
                               clientVersionNumber,
                               *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.
       */
      curr_conn++;

   }    /* For each xstat_fs connection */
   return (0);
}   /* my_xstat_fs_LWP() */


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

int
my_xstat_fs_Init(int (*ProbeHandler) (), int xstat_fs_numServers,
                 struct sockaddr_in *a_socketArray,
                 int xstat_fs_numCollections, afs_int32 * xstat_fs_collIDP,
                 char *buffer, ...)
{
   int curr_srv = 0;
   int conn_err = 0;
   char *hostNameFound = "";
   struct xstat_fs_ConnectionInfo *curr_conn = 0, *xstat_fs_ConnInfo = 0;
   struct rx_securityClass *secobj = 0; /*Client security object */
   char buff2[256] = "";
   int PortToUse = 0;
   int code = 0;
   va_list argp;

   xstat_fs_ConnInfo = (struct xstat_fs_ConnectionInfo *)
      malloc(xstat_fs_numServers * sizeof(struct xstat_fs_ConnectionInfo));
   if (xstat_fs_ConnInfo == (struct xstat_fs_ConnectionInfo *) NULL) {
      sprintf(buffer,

src/Monitor.xs  view on Meta::CPAN

         }
         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();
   if (secobj == (struct rx_securityClass *) NULL) {
      /*Delete already-malloc'ed areas */
      my_xstat_fs_Cleanup(1, xstat_fs_numServers, xstat_fs_ConnInfo, buff2);
      sprintf(buffer, "Can't create probe LWP client security object. %s",
              buff2);
      return (-1);
   }

   curr_conn = xstat_fs_ConnInfo;
   conn_err = 0;
   for (curr_srv = 0; curr_srv < xstat_fs_numServers; curr_srv++) {
      /*
       * Copy in the socket info for the current server, resolve its
       * printable name if possible.
       */

      memcpy(&(curr_conn->skt), a_socketArray + curr_srv,
             sizeof(struct sockaddr_in));

      hostNameFound = hostutil_GetNameByINet(curr_conn->skt.sin_addr.s_addr);
      if (hostNameFound == NULL) {
         warn("Can't map Internet address %lu to a string name",
              curr_conn->skt.sin_addr.s_addr);
         curr_conn->hostName[0] = '\0';
      }
      else {
         strcpy(curr_conn->hostName, hostNameFound);
      }

      /*
       * Make an Rx connection to the current server.
       */

      curr_conn->rxconn = rx_NewConnection(curr_conn->skt.sin_addr.s_addr,  /*Server addr */
                                           curr_conn->skt.sin_port, /*Server port */
                                           1,   /*AFS service # */
                                           secobj,  /*Security obj */
                                           0);  /*# of above */
      if (curr_conn->rxconn == (struct rx_connection *) NULL) {
         sprintf(buffer,
                 "Can't create Rx connection to server '%s' (%lu)",
                 curr_conn->hostName, curr_conn->skt.sin_addr.s_addr);
         my_xstat_fs_Cleanup(1, xstat_fs_numServers, xstat_fs_ConnInfo,
                             buff2);
         return (-2);
      }
      /*
       * Bump the current xstat_fs connection to set up.
       */
      curr_conn++;

   }    /*for curr_srv */


   va_start(argp, buffer);
   code =
      my_xstat_fs_LWP(ProbeHandler, xstat_fs_ConnInfo, xstat_fs_numServers,
                      xstat_fs_collIDP, xstat_fs_numCollections, buffer,
                      argp);
   va_end(argp);

   if (code) {
      return (code);
   }
   my_xstat_fs_Cleanup(1, xstat_fs_numServers, xstat_fs_ConnInfo, buff2);
   return (0);
}   /* my_xstat_fs_Init() */


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

int
my_xstat_fs_Cleanup(a_releaseMem, xstat_fs_numServers, xstat_fs_ConnInfo,
                    buffer)
   int a_releaseMem;
   int xstat_fs_numServers;
   struct xstat_fs_ConnectionInfo *xstat_fs_ConnInfo;
   char *buffer;
{
   int code = 0;                /*Return code */
   int conn_idx = 0;            /*Current connection index */
   struct xstat_fs_ConnectionInfo *curr_conn = 0;   /*Ptr to xstat_fs connection */

   /*
    * Take care of all Rx connections first.  Check to see that the
    * server count is a legal value.
    */
   if (xstat_fs_numServers <= 0) {
      sprintf(buffer,
              "Illegal number of servers (xstat_fs_numServers = %d)",
              xstat_fs_numServers);
      code = -1;
   }
   else {
      if (xstat_fs_ConnInfo != (struct xstat_fs_ConnectionInfo *) NULL) {
         /*
          * The xstat_fs connection structure array exists.  Go through
          * it and close up any Rx connections it holds.
          */
         curr_conn = xstat_fs_ConnInfo;
         for (conn_idx = 0; conn_idx < xstat_fs_numServers; conn_idx++) {
            if (curr_conn->rxconn != (struct rx_connection *) NULL) {
               rx_DestroyConnection(curr_conn->rxconn);
               curr_conn->rxconn = (struct rx_connection *) NULL;
            }

src/Monitor.xs  view on Meta::CPAN

   while (secidx < CM_NUM_DATA_CATEGORIES) {

      sscanf(cm_categories[secidx], "%s %d", section, &numgrp);
      SECTION = newHV();

      while (grpidx <= secidx + numgrp) {
         GROUP = newHV();
         sscanf(cm_categories[grpidx], "%s %d %d", group, &fromidx, &toidx);
         for (i = fromidx; i <= toidx; i++) {
            if (showFlags[i] || showDefault) {
               ENTRY = newHV();
               hv_store(ENTRY, "value", 5, newSVnv(atof(cmData->data[i])), 0);
               hv_store(GROUP, cm_varNames[i], strlen(cm_varNames[i]),
                        newRV_inc((SV *) ENTRY), 0);
            }
         }
         if (HvKEYS(GROUP))
            hv_store(SECTION, group, strlen(group), newRV_inc((SV *) GROUP),
                     0);
         grpidx++;
      }
      if (HvKEYS(SECTION))
         hv_store(HOSTINFO, section, strlen(section),
                  newRV_inc((SV *) SECTION), 0);
      secidx += numgrp + 1;
      grpidx = secidx + 1;
   }
}   /* cm_Results_to_Hash() */



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

int
my_save_CM_data_forDisplay(a_cmResults, HOSTINFO, numCM, CMnameList,
                           cm_showFlags, cm_showDefault, buffer)
   struct xstat_cm_ProbeResults *a_cmResults;
   HV *HOSTINFO;
   int numCM;
   struct afsmon_hostEntry *CMnameList;
   short *cm_showFlags;
   int cm_showDefault;
   char *buffer;
{
   struct cm_Display_Data *curr_cmDataP;
   struct afsmon_hostEntry *curr_host = 0;
   int i = 0;
   int code = 0;
   int done = 0;
   char buff2[256] = "";

   curr_cmDataP =
      (struct cm_Display_Data *)malloc(sizeof(struct cm_Display_Data));
   if (curr_cmDataP == (struct cm_Display_Data *) NULL) {
      sprintf(buffer, "Memory allocation failure");
      return (-10);
   }
   memset(curr_cmDataP, 0, sizeof(struct cm_Display_Data));

   hv_store(HOSTINFO, "hostName", 8, newSVpv(a_cmResults->connP->hostName, 0),
            0);

   /*  Check the status of the probe. If it succeeded, we store its
    * results in the display data structure. If it failed we only mark
    * the failed status in the display data structure. */

   if (a_cmResults->probeOK) {  /* 1 => notOK the xstat results */
      hv_store(HOSTINFO, "probeOK", 7, newSViv(0), 0);
   }
   else {   /* probe succeeded, update display data structures */
      hv_store(HOSTINFO, "probeOK", 7, newSViv(1), 0);

      my_cm_Results_ltoa(curr_cmDataP, a_cmResults);

      cm_Results_to_Hash(curr_cmDataP, HOSTINFO, cm_showFlags,
                         cm_showDefault);

      done = 0;
      curr_host = CMnameList;
      for (i = 0; i < numCM; i++) {
         if (strcasecmp(curr_host->hostName, a_cmResults->connP->hostName)
             == 0) {
            done = 1;
            break;
         }
         curr_host = curr_host->next;;
      }
      if (!done) {
         sprintf(buffer, "Error storing results for CM host %s (100)",
                 a_cmResults->connP->hostName);
         return (100);
      }

      code = my_check_thresholds(curr_host, HOSTINFO, CM, buff2);
      if (code) {
         sprintf(buffer, "Error in checking thresholds (105) %s", buff2);
         return (105);
      }

   }

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



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

int
my_afsmon_CM_Handler(xstat_cm_Results, numCM, conn_idx, buffer, argp)
   struct xstat_cm_ProbeResults xstat_cm_Results;
   int numCM;
   int conn_idx;
   char *buffer;
   va_list argp;

src/Monitor.xs  view on Meta::CPAN


   /* Add HOSTINFO to CM */
   av_store(CACHEMAN, conn_idx, newRV_inc((SV *) HOSTINFO));
   return (0);
}   /* my_afsmon_CM_Handler() */




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

int
my_xstat_cm_LWP(ProbeHandler, xstat_cm_ConnInfo, xstat_cm_numServers,
                xstat_cm_collIDP, xstat_cm_numCollections, buffer, argp)
   int (*ProbeHandler) ();
   struct xstat_cm_ConnectionInfo *xstat_cm_ConnInfo;
   int xstat_cm_numServers;
   afs_int32 *xstat_cm_collIDP;
   int xstat_cm_numCollections;
   char *buffer;
   va_list argp;
{
   afs_int32 srvVersionNumber = 0;  /*Xstat version # */
   afs_int32 clientVersionNumber = AFSCB_XSTAT_VERSION; /*Client xstat version */
   afs_int32 *currCollIDP = 0;
   int numColls = 0;
   int conn_idx = 0;
   struct xstat_cm_ConnectionInfo *curr_conn = 0;
   char buff2[256] = "";
   int code = 0;
   int index = 0;

   struct xstat_cm_ProbeResults xstat_cm_Results;
   afs_int32 xstat_cmData[AFSCB_MAX_XSTAT_LONGS];
   xstat_cm_Results.probeTime = 0;
   xstat_cm_Results.connP = (struct xstat_cm_ConnectionInfo *) NULL;
   xstat_cm_Results.collectionNumber = 0;
   xstat_cm_Results.data.AFSCB_CollData_len = AFSCB_MAX_XSTAT_LONGS;
   xstat_cm_Results.data.AFSCB_CollData_val = (afs_int32 *) xstat_cmData;
   xstat_cm_Results.probeOK = 0;

   curr_conn = xstat_cm_ConnInfo;
   for (conn_idx = 0; conn_idx < xstat_cm_numServers; conn_idx++) {
      /*
       * Grab the statistics for the current File Server, if the
       * connection is valid.
       */
      if (curr_conn->rxconn != (struct rx_connection *) NULL) {

         currCollIDP = xstat_cm_collIDP;
         for (numColls = 0;
              numColls < xstat_cm_numCollections; numColls++, currCollIDP++) {
            /*
             * Initialize the per-probe values.
             */
            xstat_cm_Results.collectionNumber = *currCollIDP;
            xstat_cm_Results.data.AFSCB_CollData_len = AFSCB_MAX_XSTAT_LONGS;
            memset(xstat_cm_Results.data.AFSCB_CollData_val, 0,
                   AFSCB_MAX_XSTAT_LONGS * 4);

            xstat_cm_Results.connP = curr_conn;

            xstat_cm_Results.probeOK =
               RXAFSCB_GetXStats(curr_conn->rxconn,
                                 clientVersionNumber, *currCollIDP,
                                 &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.
       */
      curr_conn++;

   }    /* For each xstat_cm connection */
   return (0);
}   /* my_xstat_cm_LWP() */



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

int
my_xstat_cm_Init(int (*ProbeHandler) (), int xstat_cm_numServers,
                 struct sockaddr_in *a_socketArray,
                 int xstat_cm_numCollections, afs_int32 * xstat_cm_collIDP,
                 char *buffer, ...)
{
   int curr_srv = 0;
   int conn_err = 0;
   char *hostNameFound = "";
   struct xstat_cm_ConnectionInfo *curr_conn = 0, *xstat_cm_ConnInfo = 0;
   struct rx_securityClass *secobj = 0; /*Client security object */
   char buff2[256] = "";
   int code = 0;
   va_list argp;

   xstat_cm_ConnInfo = (struct xstat_cm_ConnectionInfo *)
      malloc(xstat_cm_numServers * sizeof(struct xstat_cm_ConnectionInfo));
   if (xstat_cm_ConnInfo == (struct xstat_cm_ConnectionInfo *) NULL) {
      sprintf(buffer,

src/Monitor.xs  view on Meta::CPAN

   }

   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 */
      my_xstat_cm_Cleanup(1, xstat_cm_numServers, xstat_cm_ConnInfo, buff2);
      sprintf(buffer, "Can't create probe LWP client security object. %s",
              buff2);
      return (-1);
   }

   curr_conn = xstat_cm_ConnInfo;
   conn_err = 0;
   for (curr_srv = 0; curr_srv < xstat_cm_numServers; curr_srv++) {
      /*
       * Copy in the socket info for the current server, resolve its
       * printable name if possible.
       */

      memcpy(&(curr_conn->skt), a_socketArray + curr_srv,
             sizeof(struct sockaddr_in));

      hostNameFound = hostutil_GetNameByINet(curr_conn->skt.sin_addr.s_addr);
      if (hostNameFound == NULL) {
         warn("Can't map Internet address %lu to a string name",
              curr_conn->skt.sin_addr.s_addr);
         curr_conn->hostName[0] = '\0';
      }
      else {
         strcpy(curr_conn->hostName, hostNameFound);
      }

      /*
       * Make an Rx connection to the current server.
       */

      curr_conn->rxconn = rx_NewConnection(curr_conn->skt.sin_addr.s_addr,  /*Server addr */
                                           curr_conn->skt.sin_port, /*Server port */
                                           1,   /*AFS service # */
                                           secobj,  /*Security obj */
                                           0);  /*# of above */
      if (curr_conn->rxconn == (struct rx_connection *) NULL) {
         sprintf(buffer,
                 "Can't create Rx connection to server '%s' (%lu)",
                 curr_conn->hostName, curr_conn->skt.sin_addr.s_addr);
         my_xstat_cm_Cleanup(1, xstat_cm_numServers, xstat_cm_ConnInfo,
                             buff2);
         return (-2);
      }
      /*
       * Bump the current xstat_fs connection to set up.
       */
      curr_conn++;

   }    /*for curr_srv */


   va_start(argp, buffer);
   code =
      my_xstat_cm_LWP(ProbeHandler, xstat_cm_ConnInfo, xstat_cm_numServers,
                      xstat_cm_collIDP, xstat_cm_numCollections, buffer,
                      argp);
   va_end(argp);

   if (code) {
      return (code);
   }
   my_xstat_cm_Cleanup(1, xstat_cm_numServers, xstat_cm_ConnInfo, buff2);
   return (0);


}   /* my_xstat_cm_Init() */


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

int
my_xstat_cm_Cleanup(int a_releaseMem, int xstat_cm_numServers,
                    struct xstat_cm_ConnectionInfo *xstat_cm_ConnInfo,
                    char *buffer)
{
   int code = 0;                /*Return code */
   int conn_idx = 0;            /*Current connection index */
   struct xstat_cm_ConnectionInfo *curr_conn = 0;   /*Ptr to xstat_fs connection */

   /*
    * Take care of all Rx connections first.  Check to see that the
    * server count is a legal value.
    */
   if (xstat_cm_numServers <= 0) {
      sprintf(buffer,
              "Illegal number of servers (xstat_cm_numServers = %d)",
              xstat_cm_numServers);
      code = -1;
   }
   else {
      if (xstat_cm_ConnInfo != (struct xstat_cm_ConnectionInfo *) NULL) {
         /*
          * The xstat_fs connection structure array exists.  Go through
          * it and close up any Rx connections it holds.
          */
         curr_conn = xstat_cm_ConnInfo;
         for (conn_idx = 0; conn_idx < xstat_cm_numServers; conn_idx++) {
            if (curr_conn->rxconn != (struct rx_connection *) NULL) {
               rx_DestroyConnection(curr_conn->rxconn);
               curr_conn->rxconn = (struct rx_connection *) NULL;
            }
            curr_conn++;

src/Monitor.xs  view on Meta::CPAN

        return 7002;
    } else if (strncmp(aname, "kaserver", len) == 0) {
        return 7004;
    } else if (strncmp(aname, "buserver", len) == 0) {
        return 7021;
    }
    return (-1);
}


/* end of udebug helper functions */





/* scout helper functions */


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

#define FSPROBE_CBPORT  7101

extern int RXAFSCB_ExecuteRequest();

int
my_fsprobe_LWP(fsprobe_numServers, fsprobe_ConnInfo, fsprobe_Results,
               fsprobe_statsBytes, fsprobe_probeOKBytes,
               scout_debugfd, RETVAL, buffer)
   int fsprobe_numServers;
   struct fsprobe_ConnectionInfo *fsprobe_ConnInfo;
   struct fsprobe_ProbeResults *fsprobe_Results;
   int fsprobe_statsBytes;
   int fsprobe_probeOKBytes;
   FILE *scout_debugfd;
   AV *RETVAL;
   char *buffer;
{
   static char rn[] = "fsprobe_LWP";    /*Routine name */
   register afs_int32 code = 0; /*Results of calls */
   int conn_idx;                /*Connection index */
   struct fsprobe_ConnectionInfo *curr_conn;    /*Current connection */
   struct ProbeViceStatistics *curr_stats;  /*Current stats region */
   int *curr_probeOK;           /*Current probeOK field */
   int i;

   if (scout_debugfd) {
      fprintf(scout_debugfd, "[%s] Called\n", rn);
      fprintf(scout_debugfd,
              "[%s] Collecting data from %d connected servers\n", rn,
              fsprobe_numServers);
      fflush(scout_debugfd);
   }
   curr_conn = fsprobe_ConnInfo;
   curr_stats = fsprobe_Results->stats;
   curr_probeOK = fsprobe_Results->probeOK;
   fsprobe_Results->probeNum++;
   memset(fsprobe_Results->stats, 0, fsprobe_statsBytes);
   memset(fsprobe_Results->probeOK, 0, fsprobe_probeOKBytes);

   for (conn_idx = 0; conn_idx < fsprobe_numServers; conn_idx++) {
      /*
       * Grab the statistics for the current FileServer, if the
       * connection is valid.
       */
      if (scout_debugfd) {
         fprintf(scout_debugfd, "[%s] Contacting server %s\n", rn,
                 curr_conn->hostName);
         fflush(scout_debugfd);
      }
      if (curr_conn->rxconn != (struct rx_connection *) NULL) {
         if (scout_debugfd) {
            fprintf(scout_debugfd,
                    "[%s] Connection valid, calling RXAFS_GetStatistics\n",
                    rn);
            fflush(scout_debugfd);
         }
         *curr_probeOK = RXAFS_GetStatistics(curr_conn->rxconn, (struct ViceStatistics *)curr_stats);

      } /*Valid Rx connection */

      /*
       * Call the Volume Server too to get additional stats
       */
      if (scout_debugfd) {
         fprintf(scout_debugfd, "[%s] Contacting volume server %s\n", rn,
                 curr_conn->hostName);
         fflush(scout_debugfd);
      }
      if (curr_conn->rxVolconn != (struct rx_connection *) NULL) {
         char pname[10];
         struct diskPartition partition;

         if (scout_debugfd) {
            fprintf(scout_debugfd,
                    "[%s] Connection valid, calling RXAFS_GetStatistics\n",
                    rn);
            fflush(scout_debugfd);
         }
         for (i = 0; i < curr_conn->partCnt; i++) {
            if (curr_conn->partList.partFlags[i] & PARTVALID) {
               MapPartIdIntoName(curr_conn->partList.partId[i], pname);
               code =
                  AFSVolPartitionInfo(curr_conn->rxVolconn, pname,
                                      &partition);
               if (code) {
                  sprintf(buffer,
                          "Could not get information on server %s partition %s",
                          curr_conn->hostName, pname);
               }
               else {
                  curr_stats->Disk[i].BlocksAvailable = partition.free;
                  curr_stats->Disk[i].TotalBlocks = partition.minFree;
                  strcpy(curr_stats->Disk[i].Name, pname);
               }
            }
         }
      }

src/Monitor.xs  view on Meta::CPAN

   if (fsprobe_Results->probeOK != (int *) NULL)
      free(fsprobe_Results->probeOK);

   /*
    * Return the news, whatever it is.
    */
   return (code);


}


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

int
my_fsprobe_Init(fsprobe_Results, fsprobe_ConnInfo, a_numServers,
                a_socketArray, RETVAL, scout_debugfd, buffer)
   struct fsprobe_ProbeResults *fsprobe_Results;    /*Latest probe results */
   struct fsprobe_ConnectionInfo **fsprobe_ConnInfo;    /*Ptr to connection array */
   int a_numServers;
   struct sockaddr_in *a_socketArray;
   AV *RETVAL;
   FILE *scout_debugfd;
   char *buffer;
{
   static char rn[] = "my_fsprobe_Init";
   struct fsprobe_ConnectionInfo *curr_conn;    /*Current connection */
   int fsprobe_statsBytes;      /*Num bytes in stats block */
   int fsprobe_probeOKBytes;    /*Num bytes in probeOK block */
   int conn_err = 0, code = 0;
   int curr_srv;
   char *hostNameFound;
   int PortToUse;
   struct rx_securityClass *secobj;
   struct rx_securityClass *CBsecobj;
   struct rx_service *rxsrv_afsserver;
   char buff2[256] = "";

   struct rx_call *rxcall;      /*Bogus param */
   AFSCBFids *Fids_Array;       /*Bogus param */
   AFSCBs *CallBack_Array;      /*Bogus param */
   struct interfaceAddr *interfaceAddr; /*Bogus param */


   if (scout_debugfd) {
      fprintf(scout_debugfd, "[%s] Called\n", rn);
      fflush(scout_debugfd);
   }
   if (a_numServers <= 0) {
      sprintf(buffer, "[%s] Illegal number of servers: %d", rn, a_numServers);
      return (-1);
   }
   if (a_socketArray == (struct sockaddr_in *) NULL) {
      sprintf(buffer, "[%s] Null server socket array argument", rn);
      return (-1);
   }

   memset(fsprobe_Results, 0, sizeof(struct fsprobe_ProbeResults));


   rxcall = (struct rx_call *) NULL;
   Fids_Array = (AFSCBFids *) NULL;
   CallBack_Array = (AFSCBs *) NULL;
   interfaceAddr = (struct interfaceAddr *) NULL;

   SRXAFSCB_CallBack(rxcall, Fids_Array, CallBack_Array);
   SRXAFSCB_InitCallBackState2(rxcall, interfaceAddr);
   SRXAFSCB_Probe(rxcall);



   *fsprobe_ConnInfo = (struct fsprobe_ConnectionInfo *)
      malloc(a_numServers * sizeof(struct fsprobe_ConnectionInfo));
   if (*fsprobe_ConnInfo == (struct fsprobe_ConnectionInfo *) NULL) {
      sprintf(buffer,
              "[%s] Can't allocate %d connection info structs (%d bytes)\n",
              rn, a_numServers,
              (a_numServers * sizeof(struct fsprobe_ConnectionInfo)));
      return (-1);  /*No cleanup needs to be done yet */
   }
   else if (scout_debugfd) {
      fprintf(scout_debugfd, "[%s] *fsprobe_ConnInfo allocated (%d bytes)\n",
              rn, a_numServers * sizeof(struct fsprobe_ConnectionInfo));
      fflush(scout_debugfd);
   }

   fsprobe_statsBytes = a_numServers * sizeof(struct ProbeViceStatistics);
   fsprobe_Results->stats = (struct ProbeViceStatistics *)
      malloc(fsprobe_statsBytes);
   if (fsprobe_Results->stats == (struct ProbeViceStatistics *) NULL) {
      /*Delete already-malloc'ed areas */
      my_fsprobe_Cleanup(fsprobe_Results, *fsprobe_ConnInfo, a_numServers,
                         scout_debugfd, buff2);
      sprintf(buffer,
              "[%s] Can't allocate %d statistics structs (%d bytes). %s", rn,
              a_numServers, fsprobe_statsBytes, buff2);
      return (-1);
   }
   else if (scout_debugfd) {
      fprintf(scout_debugfd,
              "[%s] fsprobe_Results->stats allocated (%d bytes)\n", rn,
              fsprobe_statsBytes);
      fflush(scout_debugfd);
   }

   fsprobe_probeOKBytes = a_numServers * sizeof(int);
   fsprobe_Results->probeOK = (int *)malloc(fsprobe_probeOKBytes);
   if (fsprobe_Results->probeOK == (int *) NULL) {
      /* Delete already-malloc'ed areas */
      my_fsprobe_Cleanup(fsprobe_Results, *fsprobe_ConnInfo, a_numServers,
                         scout_debugfd, buff2);
      sprintf(buffer,
              "[%s] Can't allocate %d probeOK array entries (%d bytes). %s",
              rn, a_numServers, fsprobe_probeOKBytes, buff2);
      return (-1);
   }
   else if (scout_debugfd) {
      fprintf(scout_debugfd,
              "[%s] fsprobe_Results->probeOK allocated (%d bytes)\n",
              rn, fsprobe_probeOKBytes);
      fflush(scout_debugfd);
   }
   fsprobe_Results->probeNum = 0;
   fsprobe_Results->probeTime = 0;
   memset(fsprobe_Results->stats, 0,
          (a_numServers * sizeof(struct ProbeViceStatistics)));

   if (scout_debugfd) {
      fprintf(scout_debugfd, "[%s] Initializing Rx\n", rn);
      fflush(scout_debugfd);
   }
   PortToUse = FSPROBE_CBPORT;
   do {
      code = rx_Init(htons(PortToUse));
      if (code) {
         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);
   }


   /*
    * Create a null Rx server security object, to be used by the
    * Callback listener.
    */
   CBsecobj = (struct rx_securityClass *)rxnull_NewServerSecurityObject();
   if (CBsecobj == (struct rx_securityClass *) NULL) {
      /*Delete already-malloc'ed areas */
      my_fsprobe_Cleanup(fsprobe_Results, *fsprobe_ConnInfo, a_numServers,
                         scout_debugfd, buff2);
      sprintf(buffer,
              "[%s] Can't create null security object for the callback listener. %s",
              rn, buff2);
      return (-1);
   }
   if (scout_debugfd)
      fprintf(scout_debugfd, "[%s] Callback server security object created\n",
              rn);


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

src/Monitor.xs  view on Meta::CPAN

         strcpy(curr_conn->hostName, hostNameFound);
         if (scout_debugfd) {
            fprintf(scout_debugfd,
                    "[%s] Host name for server index %d is %s\n", rn,
                    curr_srv, curr_conn->hostName);
            fflush(scout_debugfd);
         }
      }

      /*
       * Make an Rx connection to the current server.
       */
      if (scout_debugfd) {
         fprintf(scout_debugfd,
                 "[%s] Connecting to srv idx %d, IP addr 0x%lx, port %d, service 1\n",
                 rn, curr_srv, curr_conn->skt.sin_addr.s_addr,
                 curr_conn->skt.sin_port);
         fflush(scout_debugfd);
      }

      curr_conn->rxconn = rx_NewConnection(curr_conn->skt.sin_addr.s_addr,  /*Server addr */
                                           curr_conn->skt.sin_port, /*Server port */
                                           1,   /*AFS service num */
                                           secobj,  /*Security object */
                                           0);  /*Number of above */
      if (curr_conn->rxconn == (struct rx_connection *) NULL) {
         sprintf(buffer,
                 "[%s] Can't create Rx connection to server %s (%lu)",
                 rn, curr_conn->hostName, curr_conn->skt.sin_addr.s_addr);
         conn_err = 1;
      }
      if (scout_debugfd) {
         fprintf(scout_debugfd, "[%s] New connection at 0x%lx\n",
                 rn, curr_conn->rxconn);
         fflush(scout_debugfd);
      }

      /*
       * Make an Rx connection to the current volume server.
       */
      if (scout_debugfd) {
         fprintf(scout_debugfd,
                 "[%s] Connecting to srv idx %d, IP addr 0x%lx, port %d, service 1\n",
                 rn, curr_srv, curr_conn->skt.sin_addr.s_addr, htons(7005));
         fflush(scout_debugfd);
      }
      curr_conn->rxVolconn = rx_NewConnection(curr_conn->skt.sin_addr.s_addr,   /*Server addr */
                                              htons(AFSCONF_VOLUMEPORT),    /*Volume Server port */
                                              VOLSERVICE_ID,    /*AFS service num */
                                              secobj,   /*Security object */
                                              0);   /*Number of above */
      if (curr_conn->rxVolconn == (struct rx_connection *) NULL) {
         sprintf(buffer,
                 "[%s] Can't create Rx connection to volume server %s (%lu)\n",
                 rn, curr_conn->hostName, curr_conn->skt.sin_addr.s_addr);
         conn_err = 1;
      }
      else {
         int i, cnt;

         memset(&curr_conn->partList, 0, sizeof(struct partList));
         curr_conn->partCnt = 0;
         i = my_XListPartitions(curr_conn->rxVolconn, &curr_conn->partList,
                                &cnt, scout_debugfd);
         if (!i) {
            curr_conn->partCnt = cnt;
         }
      }
      if (scout_debugfd) {
         fprintf(scout_debugfd, "[%s] New connection at 0x%lx\n",
                 rn, curr_conn->rxVolconn);
         fflush(scout_debugfd);
      }


      /*
       * Bump the current fsprobe connection to set up.
       */
      curr_conn++;
   }    /*for curr_srv */

   /*
    * Create the AFS callback service (listener).
    */
   if (scout_debugfd)
      fprintf(scout_debugfd, "[%s] Creating AFS callback listener\n", rn);
   rxsrv_afsserver = rx_NewService(0,   /*Use default port */
                                   1,   /*Service ID */
                                   "afs",   /*Service name */
                                   &CBsecobj,   /*Ptr to security object(s) */
                                   1,   /*Number of security objects */
                                   RXAFSCB_ExecuteRequest); /*Dispatcher */
   if (rxsrv_afsserver == (struct rx_service *) NULL) {
      /*Delete already-malloc'ed areas */
      my_fsprobe_Cleanup(fsprobe_Results, *fsprobe_ConnInfo, a_numServers,
                         scout_debugfd, buff2);
      sprintf(buffer, "[%s] Can't create callback Rx service/listener. %s",
              rn, buff2);
      return (-1);
   }
   if (scout_debugfd)
      fprintf(scout_debugfd, "[%s] Callback listener created\n", rn);

   /*
    * Start up the AFS callback service.
    */
   if (scout_debugfd)
      fprintf(scout_debugfd, "[%s] Starting up callback listener.\n", rn);
   rx_StartServer(0 /*Don't donate yourself to LWP pool */ );

   /* start probe */
   code = my_fsprobe_LWP(a_numServers, *fsprobe_ConnInfo, fsprobe_Results,
                         fsprobe_statsBytes, fsprobe_probeOKBytes,
                         scout_debugfd, RETVAL, buffer);
   if (code)
      return (code);

   if (conn_err)
      return (-2);
   else
      return (0);

}   /* my_fsprobe_Init() */


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

int
my_FS_Handler(fsprobe_Results, numServers, fsprobe_ConnInfo, scout_debugfd,
              RETVAL, buffer)
   struct fsprobe_ProbeResults fsprobe_Results;
   int numServers;
   struct fsprobe_ConnectionInfo *fsprobe_ConnInfo;
   FILE *scout_debugfd;

src/Monitor.xs  view on Meta::CPAN

   data_name = "afs_gn_readdir";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_gn_readdir), 0);
   data_name = "afs_gn_select";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_gn_select), 0);
   data_name = "afs_gn_strategy";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_gn_strategy), 0);
   data_name = "afs_gn_symlink";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_gn_symlink), 0);
   data_name = "afs_gn_revoke";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_gn_revoke), 0);
   data_name = "afs_gn_link";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_gn_link), 0);
   data_name = "afs_gn_mkdir";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_gn_mkdir), 0);
   data_name = "afs_gn_mknod";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_gn_mknod), 0);
   data_name = "afs_gn_remove";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_gn_remove), 0);
   data_name = "afs_gn_rename";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_gn_rename), 0);
   data_name = "afs_gn_rmdir";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_gn_rmdir), 0);
   data_name = "afs_gn_fid";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_gn_fid), 0);
   data_name = "afs_gn_lookup";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_gn_lookup), 0);
   data_name = "afs_gn_open";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_gn_open), 0);
   data_name = "afs_gn_create";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_gn_create), 0);
   data_name = "afs_gn_hold";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_gn_hold), 0);
   data_name = "afs_gn_rele";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_gn_rele), 0);
   data_name = "afs_gn_unmap";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_gn_unmap), 0);
   data_name = "afs_gn_access";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_gn_access), 0);
   data_name = "afs_gn_getattr";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_gn_getattr), 0);
   data_name = "afs_gn_setattr";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_gn_setattr), 0);
   data_name = "afs_gn_fclear";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_gn_fclear), 0);
   data_name = "afs_gn_fsync";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_gn_fsync), 0);
   data_name = "phash";
   hv_store(DATA, "pHash", strlen("pHash"), newSViv(cmp->callInfo.C_pHash),
            0);
   data_name = "DInit";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_DInit), 0);
   data_name = "DRead";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_DRead), 0);
   data_name = "FixupBucket";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_FixupBucket), 0);
   data_name = "afs_newslot";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_newslot), 0);
   data_name = "DRelease";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_DRelease), 0);
   data_name = "DFlush";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_DFlush), 0);
   data_name = "DFlushEntry";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_DFlushEntry), 0);
   data_name = "DVOffset";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_DVOffset), 0);
   data_name = "DZap";
   hv_store(DATA, data_name, strlen(data_name), newSViv(cmp->callInfo.C_DZap),
            0);
   data_name = "DNew";
   hv_store(DATA, data_name, strlen(data_name), newSViv(cmp->callInfo.C_DNew),
            0);
   data_name = "afs_RemoveVCB";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_RemoveVCB), 0);
   data_name = "afs_NewVCache";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_NewVCache), 0);
   data_name = "afs_FlushActiveVcaches";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_FlushActiveVcaches), 0);
   data_name = "afs_VerifyVCache";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_VerifyVCache), 0);
   data_name = "afs_WriteVCache";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_WriteVCache), 0);
   data_name = "afs_GetVCache";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_GetVCache), 0);
   data_name = "afs_StuffVcache";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_StuffVcache), 0);
   data_name = "afs_FindVCache";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_FindVCache), 0);
   data_name = "afs_PutDCache";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_PutDCache), 0);
   data_name = "afs_PutVCache";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_PutVCache), 0);
   data_name = "CacheStoreProc";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_CacheStoreProc), 0);
   data_name = "afs_FindDcache";
   hv_store(DATA, "afs_FindDCache", strlen("afs_FindDCache"),
            newSViv(cmp->callInfo.C_afs_FindDCache), 0);
   data_name = "afs_TryToSmush";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_TryToSmush), 0);
   data_name = "afs_AdjustSize";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_AdjustSize), 0);
   data_name = "afs_CheckSize";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_CheckSize), 0);
   data_name = "afs_StoreWarn";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_StoreWarn), 0);
   data_name = "CacheFetchProc";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_CacheFetchProc), 0);
   data_name = "UFS_CacheStoreProc";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_UFS_CacheStoreProc), 0);

src/Monitor.xs  view on Meta::CPAN

   data_name = "afs_TruncateAllSegments";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_TruncateAllSegments), 0);
   data_name = "afs_CheckVolSync";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_CheckVolSync), 0);
   data_name = "afs_wakeup";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_wakeup), 0);
   data_name = "afs_CFileOpen";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_CFileOpen), 0);
   data_name = "afs_CFileTruncate";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_CFileTruncate), 0);
   data_name = "afs_GetDownD";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_GetDownD), 0);
   data_name = "afs_WriteDCache";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_WriteDCache), 0);
   data_name = "afs_FlushDCache";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_FlushDCache), 0);
   data_name = "afs_GetDownDSlot";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_GetDownDSlot), 0);
   data_name = "afs_FlushVCache";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_FlushVCache), 0);
   data_name = "afs_GetDownV";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_GetDownV), 0);
   data_name = "afs_QueueVCB";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_QueueVCB), 0);
   data_name = "afs_call";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_call), 0);
   data_name = "afs_syscall_call";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_syscall_call), 0);
   data_name = "afs_syscall_icreate";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_syscall_icreate), 0);
   data_name = "afs_syscall_iopen";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_syscall_iopen), 0);
   data_name = "afs_syscall_iincdec";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_syscall_iincdec), 0);
   data_name = "afs_syscall_ireadwrite";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_syscall_ireadwrite), 0);
   data_name = "afs_syscall";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_syscall), 0);
   data_name = "lpioctl";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_lpioctl), 0);
   data_name = "lsetpag";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_lsetpag), 0);
   data_name = "afs_CheckInit";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_CheckInit), 0);
   data_name = "ClearCallback";
   hv_store(DATA, "ClearCallBack", strlen("ClearCallBack"),
            newSViv(cmp->callInfo.C_ClearCallBack), 0);
   data_name = "SRXAFSCB_GetCE";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_SRXAFSCB_GetCE), 0);
   data_name = "SRXAFSCB_GetLock";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_SRXAFSCB_GetLock), 0);
   data_name = "SRXAFSCB_CallBack";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_SRXAFSCB_CallBack), 0);
   data_name = "SRXAFSCB_InitCallBackState";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_SRXAFSCB_InitCallBackState), 0);
   data_name = "SRXAFSCB_Probe";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_SRXAFSCB_Probe), 0);
   data_name = "afs_Chunk";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_Chunk), 0);
   data_name = "afs_ChunkBase";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_ChunkBase), 0);
   data_name = "afs_ChunkOffset";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_ChunkOffset), 0);
   data_name = "afs_ChunkSize";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_ChunkSize), 0);
   data_name = "afs_ChunkToBase";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_ChunkToBase), 0);
   data_name = "afs_ChunkToSize";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_ChunkToSize), 0);
   data_name = "afs_SetChunkSize";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_SetChunkSize), 0);
   data_name = "afs_config";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_config), 0);
   data_name = "mem_freebytes";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_mem_freebytes), 0);
   data_name = "mem_getbytes";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_mem_getbytes), 0);
   data_name = "afs_Daemon";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_Daemon), 0);
   data_name = "afs_CheckRootVolume";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_CheckRootVolume), 0);
   data_name = "BPath";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_BPath), 0);
   data_name = "BPrefetch";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_BPrefetch), 0);
   data_name = "BStore";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_BStore), 0);
   data_name = "afs_BBusy";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_BBusy), 0);
   data_name = "afs_BQueue";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_BQueue), 0);
   data_name = "afs_BRelease";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_BRelease), 0);
   data_name = "afs_BackgroundDaemon";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_BackgroundDaemon), 0);
   data_name = "exporter_add";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_exporter_add), 0);
   data_name = "exporter_find";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_exporter_find), 0);
   data_name = "afs_gfs_kalloc";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_gfs_kalloc), 0);
   data_name = "afs_gfs_kfree";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_gfs_kfree), 0);

src/Monitor.xs  view on Meta::CPAN

   data_name = "PSetSysName";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_PSetSysName), 0);
   data_name = "PExportAfs";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_PExportAfs), 0);
   data_name = "HandleClientContext";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_HandleClientContext), 0);
   data_name = "PViceAccess";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_PViceAccess), 0);
   data_name = "PRemoveCallBack";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_PRemoveCallBack), 0);
   data_name = "PRemoveMount";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_PRemoveMount), 0);
   data_name = "PSetVolumeStatus";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_PSetVolumeStatus), 0);
   data_name = "PListCells";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_PListCells), 0);
   data_name = "PNewCell";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_PNewCell), 0);
   data_name = "PGetUserCell";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_PGetUserCell), 0);
   data_name = "PGetCellStatus";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_PGetCellStatus), 0);
   data_name = "PSetCellStatus";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_PSetCellStatus), 0);
   data_name = "PVenusLogging";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_PVenusLogging), 0);
   data_name = "PGetAcl";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_PGetAcl), 0);
   data_name = "PGetFID";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_PGetFID), 0);
   data_name = "PSetAcl";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_PSetAcl), 0);
   data_name = "PGetFileCell";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_PGetFileCell), 0);
   data_name = "PGetWSCell";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_PGetWSCell), 0);
   data_name = "PGetSPrefs";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_PGetSPrefs), 0);
   data_name = "PSetSPrefs";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_PSetSPrefs), 0);
   data_name = "afs_ResetAccessCache";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_ResetAccessCache), 0);
   data_name = "afs_FindUser";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_FindUser), 0);
   data_name = "afs_GetUser";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_GetUser), 0);
   data_name = "afs_GCUserData";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_GCUserData), 0);
   data_name = "afs_PutUser";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_PutUser), 0);
   data_name = "afs_SetPrimary";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_SetPrimary), 0);
   data_name = "afs_ResetUserConns";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_ResetUserConns), 0);
   data_name = "afs_RemoveUserConns";
   hv_store(DATA, "RemoveUserConns", strlen("RemoveUserConns"),
            newSViv(cmp->callInfo.C_RemoveUserConns), 0);
   data_name = "afs_ResourceInit";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_ResourceInit), 0);
   data_name = "afs_GetCell";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_GetCell), 0);
   data_name = "afs_GetCellByIndex";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_GetCellByIndex), 0);
   data_name = "afs_GetCellByName";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_GetCellByName), 0);
#ifdef GETREALCELLBYINDEX
   data_name = "afs_GetRealCellByIndex";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_GetRealCellByIndex), 0);
#endif
   data_name = "afs_NewCell";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_NewCell), 0);
   data_name = "CheckVLDB";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_CheckVLDB), 0);
   data_name = "afs_GetVolume";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_GetVolume), 0);
   data_name = "afs_PutVolume";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_PutVolume), 0);
   data_name = "afs_GetVolumeByName";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_GetVolumeByName), 0);
   data_name = "afs_random";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_random), 0);
   data_name = "InstallVolumeEntry";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_InstallVolumeEntry), 0);
   data_name = "InstallVolumeInfo";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_InstallVolumeInfo), 0);
   data_name = "afs_ResetVolumeInfo";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_ResetVolumeInfo), 0);
   data_name = "afs_FindServer";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_FindServer), 0);
   data_name = "afs_GetServer";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_GetServer), 0);
   data_name = "afs_SortServers";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_SortServers), 0);
   data_name = "afs_CheckServers";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_CheckServers), 0);
   data_name = "ServerDown";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_ServerDown), 0);
   data_name = "afs_Conn";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_Conn), 0);
   data_name = "afs_PutConn";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_PutConn), 0);
   data_name = "afs_ConnByHost";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_ConnByHost), 0);
   data_name = "afs_ConnByMHosts";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_ConnByMHosts), 0);
   data_name = "afs_Analyze";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_Analyze), 0);
   data_name = "afs_CheckLocks";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_CheckLocks), 0);
   data_name = "CheckVLServer";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_CheckVLServer), 0);
   data_name = "afs_CheckCacheResets";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_CheckCacheResets), 0);
   data_name = "afs_CheckVolumeNames";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_CheckVolumeNames), 0);
   data_name = "afs_CheckCode";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_CheckCode), 0);
   data_name = "afs_CopyError";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_CopyError), 0);
   data_name = "afs_FinalizeReq";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_FinalizeReq), 0);
   data_name = "afs_GetVolCache";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_GetVolCache), 0);
   data_name = "afs_GetVolSlot";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_GetVolSlot), 0);
   data_name = "afs_UFSGetVolSlot";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_UFSGetVolSlot), 0);
   data_name = "afs_MemGetVolSlot";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_MemGetVolSlot), 0);
   data_name = "afs_WriteVolCache";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_WriteVolCache), 0);
   data_name = "haveCallbacksfrom";
   hv_store(DATA, "HaveCallBacksFrom", strlen("HaveCallBacksFrom"),
            newSViv(cmp->callInfo.C_HaveCallBacksFrom), 0);
   data_name = "afs_getpage";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_getpage), 0);
   data_name = "afs_putpage";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_putpage), 0);
   data_name = "afs_nfsrdwr";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_nfsrdwr), 0);
   data_name = "afs_map";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_map), 0);
   data_name = "afs_cmp";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_cmp), 0);
   data_name = "afs_PageLeft";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_PageLeft), 0);
   data_name = "afs_mount";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_mount), 0);
   data_name = "afs_unmount";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_unmount), 0);
   data_name = "afs_root";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_root), 0);
   data_name = "afs_statfs";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_statfs), 0);
   data_name = "afs_sync";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_sync), 0);
   data_name = "afs_vget";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_vget), 0);
   data_name = "afs_index";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_index), 0);
   data_name = "afs_setpag";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_setpag), 0);
   data_name = "genpag";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_genpag), 0);
   data_name = "getpag";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_getpag), 0);
   data_name = "genpag";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_genpag), 0);
   data_name = "afs_GetMariner";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_GetMariner), 0);
   data_name = "afs_AddMarinerName";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_AddMarinerName), 0);
   data_name = "afs_open";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_open), 0);
   data_name = "afs_close";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_close), 0);
   data_name = "afs_closex";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_closex), 0);
   data_name = "afs_write";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_write), 0);
   data_name = "afs_UFSwrite";
   hv_store(DATA, "afs_UFSWrite", strlen("afs_UFSWrite"),
            newSViv(cmp->callInfo.C_afs_UFSWrite), 0);
   data_name = "afs_Memwrite";
   hv_store(DATA, "afs_MemWrite", strlen("afs_MemWrite"),
            newSViv(cmp->callInfo.C_afs_MemWrite), 0);
   data_name = "afs_rdwr";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_rdwr), 0);
   data_name = "afs_read";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_read), 0);
   data_name = "afs_UFSread";
   hv_store(DATA, "afs_UFSRead", strlen("afs_UFSRead"),
            newSViv(cmp->callInfo.C_afs_UFSRead), 0);
   data_name = "afs_Memread";
   hv_store(DATA, "afs_MemRead", strlen("afs_MemRead"),
            newSViv(cmp->callInfo.C_afs_MemRead), 0);
   data_name = "afs_CopyOutAttrs";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_CopyOutAttrs), 0);
   data_name = "afs_access";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_access), 0);
   data_name = "afs_getattr";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_getattr), 0);
   data_name = "afs_setattr";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_setattr), 0);
   data_name = "afs_VAttrToAS";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_VAttrToAS), 0);
   data_name = "EvalMountPoint";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_EvalMountPoint), 0);
   data_name = "afs_lookup";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_lookup), 0);
   data_name = "afs_create";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_create), 0);
   data_name = "afs_LocalHero";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_LocalHero), 0);
   data_name = "afs_remove";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_remove), 0);
   data_name = "afs_link";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_link), 0);
   data_name = "afs_rename";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_rename), 0);
   data_name = "afs_InitReq";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_InitReq), 0);
   data_name = "afs_mkdir";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_mkdir), 0);
   data_name = "afs_rmdir";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_rmdir), 0);
   data_name = "afs_readdir";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_readdir), 0);
   data_name = "afs_read1dir";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_read1dir), 0);
   data_name = "afs_readdir_move";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_readdir_move), 0);
   data_name = "afs_readdir_iter";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_readdir_iter), 0);
   data_name = "afs_symlink";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_symlink), 0);
   data_name = "afs_HandleLink";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_HandleLink), 0);
   data_name = "afs_MemHandleLink";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_MemHandleLink), 0);
   data_name = "afs_UFSHandleLink";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_UFSHandleLink), 0);
   data_name = "HandleFlock";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_HandleFlock), 0);

src/Monitor.xs  view on Meta::CPAN

   data_name = "afs_FakeOpen";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_FakeOpen), 0);
   data_name = "afs_FakeClose";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_FakeClose), 0);
   data_name = "afs_StoreOnLastReference";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_StoreOnLastReference), 0);
   data_name = "afs_AccessOK";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_AccessOK), 0);
   data_name = "afs_GetAccessBits";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_GetAccessBits), 0);
   data_name = "afsio_copy";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afsio_copy), 0);
   data_name = "afsio_trim";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afsio_trim), 0);
   data_name = "afsio_skip";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afsio_skip), 0);
   data_name = "afs_page_read";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_page_read), 0);
   data_name = "afs_page_write";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_page_write), 0);
   data_name = "afs_page_read";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_page_read), 0);
   data_name = "afs_get_groups_from_pag";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_get_groups_from_pag), 0);
   data_name = "afs_get_pag_from_groups";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_get_pag_from_groups), 0);
   data_name = "AddPag";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_AddPag), 0);
   data_name = "PagInCred";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_PagInCred), 0);
   data_name = "afs_getgroups";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_getgroups), 0);
   data_name = "afs_page_in";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_page_in), 0);
   data_name = "afs_page_out";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_page_out), 0);
   data_name = "afs_AdvanceFD";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_AdvanceFD), 0);
   data_name = "afs_lockf";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_lockf), 0);
   data_name = "afs_xsetgroups";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_xsetgroups), 0);
   data_name = "afs_nlinks";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_nlinks), 0);
   data_name = "afs_lockctl";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_lockctl), 0);
   data_name = "afs_xflock";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_xflock), 0);
   data_name = "PGetCPrefs";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_PGetCPrefs), 0);
   data_name = "PSetCPrefs";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_PSetCPrefs), 0);
#ifdef	AFS_HPUX_ENV
   data_name = "afs_pagein";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_pagein), 0);
   data_name = "afs_pageout";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_pageout), 0);
   data_name = "afs_hp_strategy";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_afs_hp_strategy), 0);
#endif
   data_name = "PFlushMount";
   hv_store(DATA, data_name, strlen(data_name),
            newSViv(cmp->callInfo.C_PFlushMount), 0);


   hv_store(HOSTINFO, "data", 4, newRV_inc((SV *) DATA), 0);

}


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

void
my_cm_PrintUpDownStats(struct afs_stats_SrvUpDownInfo *a_upDownP, AV *UPDOWN, int index)
{
   HV *INFO = newHV();
   AV *DOWNDURATIONS = newAV();
   AV *DOWNINCIDENTS = newAV();
   int i;

   /*
    * First, print the simple values.
    */
   hv_store(INFO, "numTtlRecords", strlen("numTtlRecords"),
            newSViv(a_upDownP->numTtlRecords), 0);
   hv_store(INFO, "numUpRecords", strlen("numUpRecords"),
            newSViv(a_upDownP->numUpRecords), 0);
   hv_store(INFO, "numDownRecords", strlen("numDownRecords"),
            newSViv(a_upDownP->numDownRecords), 0);
   hv_store(INFO, "sumOfRecordAges", strlen("sumOfRecordAges"),
            newSViv(a_upDownP->sumOfRecordAges), 0);

src/Monitor.xs  view on Meta::CPAN

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

        case 'f':
          if(strncmp(key, "fsname", keylen) == 0 && keylen <= 6) {
            if (SvROK(value))
              host_array = (AV*) SvRV(value);
            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);
      XSRETURN_UNDEF;
    }
    else if (numFSs == 0) {
      sprintf(buffer, "The field 'fsname' isn't completed properly");
      BSETCODE(-1, buffer);
      XSRETURN_UNDEF;
    }
    else if (coll_array == 0) {
      sprintf(buffer, "Missing required parameter 'collID'");
      BSETCODE(-1, buffer);
      XSRETURN_UNDEF;
    }
    else if (numCollIDs == 0) {
      sprintf(buffer, "The field 'collID' isn't completed properly");
      BSETCODE(-1, buffer);
      XSRETURN_UNDEF;
    }

    sktbytes = numFSs * sizeof(struct sockaddr_in);
    FSSktArray = (struct sockaddr_in *) malloc(sktbytes);
    if (FSSktArray == (struct sockaddr_in *) NULL) {
      sprintf(buffer,
              "Can't malloc() %d sockaddrs (%d bytes) for the given file servers",
              numFSs, sktbytes);
      BSETCODE(-1, buffer);
      XSRETURN_UNDEF;
    }
    memset(FSSktArray, 0, sktbytes);

     /*
     * Fill in the socket array for each of the File Servers listed.
     */
    for (currFS = 0; currFS < numFSs; currFS++) {
#if defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
        FSSktArray[currFS].sin_family = AF_INET;        /*Internet family */
#else
        FSSktArray[currFS].sin_family = htons(AF_INET); /*Internet family */
#endif
	FSSktArray[currFS].sin_port   = htons(7000);	/*FileServer port*/
	he = hostutil_GetHostByName((char *) SvPV(*av_fetch(host_array, currFS, 0), PL_na));
	if (he == (struct hostent *) NULL) {
	    sprintf(buffer,
		    "Can't get host info for '%s'",
		    (char *) SvPV(*av_fetch(host_array, currFS, 0), PL_na));
	    BSETCODE(-1, buffer);
            XSRETURN_UNDEF;
	}
	memcpy(&(FSSktArray[currFS].sin_addr.s_addr), he->h_addr, 4);

    } /*Get socket info for each File Server*/

    collIDP = (afs_int32 *) malloc(numCollIDs * sizeof(afs_int32));
    currCollIDP = collIDP;
    for (currCollIDIdx = 0; currCollIDIdx < numCollIDs; currCollIDIdx++) {
	*currCollIDP = (afs_int32) SvIV(*av_fetch(coll_array, currCollIDIdx, 0));
	currCollIDP++;
    }

    code = my_xstat_fs_Init(my_xstat_FS_Handler, numFSs, FSSktArray,
                            numCollIDs, collIDP, buffer, RETVAL);
    if(code) {
       BSETCODE(code, buffer);
       XSRETURN_UNDEF;
    }

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

  }


void
afs_do_scout(args)
    HV* args = (HV*) SvRV($arg);
  PREINIT:
  PPCODE:
  {
    static char rn[] = "afs_do_scout";
    SV *value;
    I32 keylen = 0;
    char *key;
    int num_args = 0;
    char buffer[256] = "";
    struct fsprobe_ProbeResults fsprobe_Results;
    struct fsprobe_ConnectionInfo *fsprobe_ConnInfo; /*Ptr to connection array*/
    char buff2[256] = "";

src/Monitor.xs  view on Meta::CPAN

          if(strncmp(key, "debug", keylen) == 0 && keylen <= 5) {
            debug_filename = (char *) SvPV(value, PL_na);
          } else goto unrecognized;
        break;

        case 's':
          if(strncmp(key, "servers", keylen) == 0 && keylen <= 7) {
            if (SvROK(value))
              host_array = (AV*) SvRV(value);
            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);
      XSRETURN_UNDEF;
    }

    if(debug_filename) {
      scout_debugfd = fopen(debug_filename, "w");
      if(scout_debugfd == (FILE *) NULL) {
        sprintf(buffer, "Can't open debugging file '%s'!", debug_filename);
        BSETCODE(-1, buffer);
        XSRETURN_UNDEF;
      }
      fprintf(scout_debugfd, "[%s] Writing to Scout debugging file '%s'\n",
              rn, debug_filename);
      fflush(scout_debugfd);
    }

    /* execute_scout */

    sktbytes = numservers * sizeof(struct sockaddr_in);
    FSSktArray = (struct sockaddr_in *) malloc(sktbytes);
    if (FSSktArray == (struct sockaddr_in *) NULL) {
      sprintf(buffer,
              "Can't malloc() %d sockaddrs (%d bytes) for the given servers",
              numservers, sktbytes);
      BSETCODE(-1, buffer);
      if (scout_debugfd != (FILE *) NULL) {
        fprintf(scout_debugfd, "[%s] Closing debugging file\n", rn);
        fclose(scout_debugfd);
      }
      XSRETURN_UNDEF;
    }
    memset(FSSktArray, 0, sktbytes);

    curr_skt = FSSktArray;
    for(i=0; i<numservers; i++) {
       if(*basename == '\0')
         sprintf(fullsrvname, "%s", (char *) SvPV(*av_fetch(host_array, i, 0), PL_na));
       else
         sprintf(fullsrvname, "%s.%s", (char *) SvPV(*av_fetch(host_array, i, 0), PL_na), basename);
       he = hostutil_GetHostByName(fullsrvname);
       if(he == (struct hostent *) NULL) {
         sprintf(buffer, "Can't get host info for '%s'", fullsrvname);
         BSETCODE(-1, buffer);
         if (scout_debugfd != (FILE *) NULL) {
           fprintf(scout_debugfd, "[%s] Closing debugging file\n", rn);
           fclose(scout_debugfd);
         }
         XSRETURN_UNDEF;
       }
       memcpy(&(curr_skt->sin_addr.s_addr), he->h_addr, 4);
#if defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
        curr_skt->sin_family = AF_INET;         /*Internet family */
#else
        curr_skt->sin_family = htons(AF_INET);  /*Internet family */
#endif
       curr_skt->sin_port   = htons(7000);       /* FileServer port */
       curr_skt++;
    }
    code = my_fsprobe_Init(&fsprobe_Results, &fsprobe_ConnInfo, numservers,
                           FSSktArray, RETVAL, scout_debugfd, buffer);
    if(code) {
      if(buffer == "") {
        sprintf(buffer, "Error returned by fsprobe_Init: %d", code);
      }
      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);
       fclose(scout_debugfd);
    }

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

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) {
       th = hostutil_GetHostByName(hostName);
       if (!th) {
          sprintf(buffer, "udebug: host %s not found in host table", hostName);
          BSETCODE(1, buffer);
          XSRETURN_UNDEF;
       }
       memcpy(&hostAddr, th->h_addr, sizeof(afs_int32));
    }
    else hostAddr = htonl(0x7f000001);  /* IP localhost */


    if (!portName)
       port = htons(3000);             /* default */
    else {
       port = udebug_PortNumber(portName);
       if (port < 0)
          port = udebug_PortName(portName);
       if (port < 0) {
          sprintf(buffer, "udebug: can't resolve port name %s", portName);
          BSETCODE(1, buffer);
          XSRETURN_UNDEF;
       }
       port = htons(port);
    }

    rx_Init(0);
    sc = rxnull_NewClientSecurityObject();
    tconn = rx_NewConnection(hostAddr, port, VOTE_SERVICE_ID, sc, 0);

    /* now do the main call */
#ifdef USE_VOTEXDEBUG
    code = VOTE_XDebug(tconn, &udebug, &isClone);
    if (code) code = VOTE_Debug(tconn, &udebug);
#else
    code = VOTE_Debug(tconn, &udebug);
#endif
    if (code == RXGEN_OPCODE)
    {  ubik_debug * ptr = &udebug;
       oldServer = 1;             /* talking to a pre 3.5 server */
       memset(&udebug, 0, sizeof(udebug));
       code = VOTE_DebugOld(tconn, (struct ubik_debug_old *) ptr);
    }

    if (code) {
       sprintf(buffer, "return code %d from VOTE_Debug", code);
       BSETCODE(code, buffer);
       XSRETURN_UNDEF;
    }

    /* now print the main info */
    inhostAddr.s_addr = hostAddr;
    if ( !oldServer )
    {
       ADDRESSES = newAV();
       for ( j=0; udebug.interfaceAddr[j] && ( j<UBIK_MAX_INTERFACE_ADDR ); j++) {
          av_store(ADDRESSES, j, newSVpv(afs_inet_ntoa(htonl(udebug.interfaceAddr[j])), 0));
       }
       hv_store(RETVAL, "interfaceAddr", 13, newRV_inc((SV*)ADDRESSES), 0);
    }

    hv_store(RETVAL, "host", 4, newSVpv(inet_ntoa(inhostAddr), 0), 0);
    hv_store(RETVAL, "now", 3, newSViv(udebug.now), 0);

    /* UBIK skips the voting if 1 server - so we fudge it here */
    if ( udebug.amSyncSite && (udebug.nServers == 1) ) {
       udebug.lastYesHost  = hostAddr;
       udebug.lastYesTime  = udebug.now;
       udebug.lastYesState = 1;
       udebug.lastYesClaim = udebug.now;
       udebug.syncVersion.epoch   = udebug.localVersion.epoch;
       udebug.syncVersion.counter = udebug.localVersion.counter;
    }

    /* sockaddr is always in net-order */
    if ( udebug.lastYesHost != 0xffffffff ) {
       inhostAddr.s_addr = htonl(udebug.lastYesHost);
       hv_store(RETVAL, "lastYesHost", 11, newSVpv(inet_ntoa(inhostAddr), 0), 0);
       hv_store(RETVAL, "lastYesTime", 11, newSViv(udebug.lastYesTime), 0);
       hv_store(RETVAL, "lastYesState", 12, newSViv(udebug.lastYesState), 0);
       hv_store(RETVAL, "lastYesClaim", 12, newSViv(udebug.lastYesClaim), 0);
    }

    LOCALVERSION = newHV();
    hv_store(LOCALVERSION, "epoch", 5, newSViv(udebug.localVersion.epoch), 0);
    hv_store(LOCALVERSION, "counter", 7, newSViv(udebug.localVersion.counter), 0);
    hv_store(RETVAL, "localVersion", 12, newRV_inc((SV*)LOCALVERSION), 0);

    hv_store(RETVAL, "amSyncSite", 10, newSViv(udebug.amSyncSite), 0);

    hv_store(RETVAL, "epochTime", 9, newSViv(udebug.epochTime), 0);

    if (udebug.amSyncSite) {
       hv_store(RETVAL, "syncSiteUntil", 13, newSViv(udebug.syncSiteUntil), 0);
       hv_store(RETVAL, "nServers", 8, newSViv(udebug.nServers), 0);
       hv_store(RETVAL, "recoveryState", 13, newSViv(udebug.recoveryState), 0);
       if (udebug.activeWrite) {
          hv_store(RETVAL, "tidCounter", 10, newSViv(udebug.tidCounter), 0);
       }
    }
    else {
       hv_store(RETVAL, "isClone", 7, newSViv(isClone), 0);

       inhostAddr.s_addr = htonl(udebug.lowestHost);
       hv_store(RETVAL, "lowestHost", 10, newSVpv(inet_ntoa(inhostAddr), 0), 0);
       hv_store(RETVAL, "lowestTime", 10, newSViv(udebug.lowestTime), 0);

       inhostAddr.s_addr = htonl(udebug.syncHost);
       hv_store(RETVAL, "syncHost", 8, newSVpv(inet_ntoa(inhostAddr), 0), 0);
       hv_store(RETVAL, "syncTime", 8, newSViv(udebug.syncTime), 0);
    }

    SYNCVERSION = newHV();
    hv_store(SYNCVERSION, "epoch", 5, newSViv(udebug.syncVersion.epoch), 0);
    hv_store(SYNCVERSION, "counter", 7, newSViv(udebug.syncVersion.counter), 0);
    hv_store(RETVAL, "syncVersion", 11, newRV_inc((SV*)SYNCVERSION), 0);

    hv_store(RETVAL, "lockedPages", 11, newSViv(udebug.lockedPages), 0);
    hv_store(RETVAL, "writeLockedPages", 16, newSViv(udebug.writeLockedPages), 0);

    hv_store(RETVAL, "anyReadLocks", 12, newSViv(udebug.anyReadLocks), 0);
    hv_store(RETVAL, "anyWriteLocks", 13, newSViv(udebug.anyWriteLocks), 0);

    hv_store(RETVAL, "currentTrans", 12, newSViv(udebug.currentTrans), 0);
    if (udebug.currentTrans) {
       hv_store(RETVAL, "writeTrans", 10, newSViv(udebug.writeTrans), 0);
       SYNCTID = newHV();
       hv_store(SYNCTID, "epoch", 5, newSViv(udebug.syncTid.epoch), 0);
       hv_store(SYNCTID, "counter", 7, newSViv(udebug.syncTid.counter), 0);
       hv_store(RETVAL, "syncTid", 7, newRV_inc((SV*)SYNCTID), 0);
    }

    if (int32p || udebug.amSyncSite) {
       /* now do the subcalls */
       SERVERS = newAV();

       for ( i=0; ; i++ ) {
#ifdef USE_VOTEXDEBUG
          isClone = 0;
          code = VOTE_XSDebug(tconn, i, &usdebug, &isClone);
          if (code < 0) {
             if ( oldServer ) {                      /* pre 3.5 server */
                ubik_sdebug * ptr = &usdebug;
                memset(&usdebug, 0, sizeof(usdebug));
                code = VOTE_SDebugOld(tconn, i, (struct ubik_sdebug_old *) ptr);
             }
             else
                code = VOTE_SDebug(tconn, i, &usdebug);
          }
#else
          if ( oldServer ) {                      /* pre 3.5 server */
             ubik_sdebug * ptr = &usdebug;
             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();
          for ( j=0;((usdebug.altAddr[j]) && (j<UBIK_MAX_INTERFACE_ADDR-1)); j++) {
             av_store(ALTADDR, j, newSVpv(afs_inet_ntoa(htonl(usdebug.altAddr[j])), 0));
          }
          if (j) hv_store(USDEBUG, "altAddr", 7, newRV_inc((SV*)ALTADDR), 0);

          REMOTEVERSION = newHV();
          hv_store(REMOTEVERSION, "epoch", 5, newSViv(usdebug.remoteVersion.epoch), 0);
          hv_store(REMOTEVERSION, "counter", 7, newSViv(usdebug.remoteVersion.counter), 0);
          hv_store(USDEBUG, "remoteVersion", 13, newRV_inc((SV*)REMOTEVERSION), 0);

          hv_store(USDEBUG, "isClone", 7, newSViv(isClone), 0);

          hv_store(USDEBUG, "lastVoteTime", 12, newSViv(usdebug.lastVoteTime), 0);

          hv_store(USDEBUG, "lastBeaconSent", 14, newSViv(usdebug.lastBeaconSent), 0);
          hv_store(USDEBUG, "lastVote", 8, newSViv(usdebug.lastVote), 0);

          hv_store(USDEBUG, "currentDB", 9, newSViv(usdebug.currentDB), 0);
          hv_store(USDEBUG, "up", 2, newSViv(usdebug.up), 0);
          hv_store(USDEBUG, "beaconSinceDown", 15, newSViv(usdebug.beaconSinceDown), 0);

          av_store(SERVERS, i, newRV_inc((SV*)USDEBUG));
       }
       hv_store(RETVAL, "servers", 7, newRV_inc((SV*)SERVERS), 0);
    }

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

  }

void
afs_do_cmdebug(args)
    HV* args = (HV*) SvRV($arg);
  PREINIT:
  PPCODE:
  {
    SV *value;

src/Monitor.xs  view on Meta::CPAN

            thresh_value = (char *) SvPV(value, PL_na);
          }
        }
        sprintf(buffer, "thresh fs %s %s %s",
                thresh_name, thresh_value, thresh_handler);
        if(!thresh_host) {
          code = my_parse_threshEntry(buffer, &global_fsThreshCount,
                      &global_cmThreshCount, (struct afsmon_hostEntry *) NULL, 0, buff2);
          if (code) {
            sprintf(buffer, "Couldn't parse fsthresh entry. %s", buff2);
            BSETCODE(code, buffer);
            XSRETURN_UNDEF;
          }
        }
        else {
          temp_host = FSnameList;
          found = 0;
          for (j = 0; j < numFS; j++) {
            if(strcmp(thresh_host, temp_host->hostName) == 0) {
              found = 1;
              break;
            }
            temp_host = temp_host->next;
          }
          if(found) {
            code = my_parse_threshEntry(buffer, &global_fsThreshCount,
                                        &global_cmThreshCount, temp_host,
                                        1, buff2);
            if(code) {
              sprintf(buffer, "Couldn't parse fsthresh entry. %s", buff2);
              BSETCODE(code, buffer);
              XSRETURN_UNDEF;
            }
          }
          else {
            sprintf(buffer,
                    "Couldn't parse fsthresh entry for host %s; host not found",
                    thresh_host);
            BSETCODE(-1, buffer);
            XSRETURN_UNDEF;
          }
        }
      }
      if (global_fsThreshCount) {
        temp_host = FSnameList;
        for (i = 0; i < numFS; i++) {
          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;
        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 {
            thresh_name = key;
            thresh_value = (char *) SvPV(value, PL_na);
          }
        }
        if(thresh_host) global_fsThreshCount = 0;
        else global_fsThreshCount = 1;
        code = my_store_threshold(1, thresh_name, thresh_value, thresh_handler,
                           &global_fsThreshCount, FSnameList, thresh_host,
                           numFS, buff2);
        if(code) {
          sprintf(buffer, "Unable to store threshold %s. %s", thresh_name, buff2);
          BSETCODE(code, buffer);
          XSRETURN_UNDEF;
        }
      }
    }

    if (cmthresh_array) {
      if(!numCM) {
        sprintf(buffer, "Cannot use cmthresh option without specifying cmhosts");
        BSETCODE(-1, buffer);
        XSRETURN_UNDEF;
      }
      num = av_len(cmthresh_array);
      for (i=0; i<=num; i++) {
        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) {

src/Monitor.xs  view on Meta::CPAN

            thresh_name = key;
            thresh_value = (char *) SvPV(value, PL_na);
          }
        }
        sprintf(buffer, "thresh cm %s %s %s", thresh_name, thresh_value, thresh_handler);
        if(!thresh_host) {
          code = my_parse_threshEntry(buffer, &global_fsThreshCount,
                      &global_cmThreshCount, (struct afsmon_hostEntry *) NULL, 0, buff2);
          if (code) {
            sprintf(buffer, "Couldn't parse cmthresh entry. %s", buff2);
            BSETCODE(code, buffer);
            XSRETURN_UNDEF;
          }
        }
        else {
          temp_host = CMnameList;
          found = 0;
          for (j = 0; j < numCM; j++) {
            if(strcmp(thresh_host, temp_host->hostName) == 0) {
              found = 1;
              break;
            }
            temp_host = temp_host->next;
          }
          if(found) {
            code = my_parse_threshEntry(buffer, &global_fsThreshCount,
                                        &global_cmThreshCount, temp_host,
                                        2, buff2);
            if(code) {
              sprintf(buffer, "Couldn't parse cmthresh entry. %s", buff2);
              BSETCODE(code, buffer);
              XSRETURN_UNDEF;
            }
          }
          else {
            sprintf(buffer,
                    "Couldn't parse cmthresh entry for host %s; host not found",
                    thresh_host);
            BSETCODE(-1, buffer);
            XSRETURN_UNDEF;
          }
        }
      }
      if (global_cmThreshCount) {
        temp_host = CMnameList;
        for (i = 0; i < numCM; i++) {
          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;
        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 {
            thresh_name = key;
            thresh_value = (char *) SvPV(value, PL_na);
          }
        }
        if(thresh_host) global_cmThreshCount = 0;
        else global_cmThreshCount = 1;
        code = my_store_threshold(2, thresh_name, thresh_value, thresh_handler,
                           &global_cmThreshCount, CMnameList, thresh_host,
                           numCM, buff2);
        if(code) {
          sprintf(buffer, "Unable to store threshold %s. %s", thresh_name, buff2);
          BSETCODE(code, buffer);
          XSRETURN_UNDEF;
        }
      }
    }

    /* process configuration file */
    if(config_filename) {
      code = my_process_config_file(config_filename, &numFS, &numCM, &lastHostType,
                                 &last_hostEntry, &fs_showDefault, &cm_showDefault,
                                 fs_showFlags, cm_showFlags, &FSnameList, &CMnameList);
      if(code == -1)
        XSRETURN_UNDEF;
    }

  /* from afsmon_execute() */

    /* process file server entries */
    if (numFS) {
    /* Allocate an array of sockets for each fileserver we monitor */

      FSsktbytes = numFS * sizeof(struct sockaddr_in);
      FSSktArray = (struct sockaddr_in *) malloc(FSsktbytes);
      if (FSSktArray == (struct sockaddr_in *) NULL) {
        sprintf(buffer,"cannot malloc %d sockaddr_ins for fileservers", numFS);
        BSETCODE(-1, buffer);
        XSRETURN_UNDEF;
      }

      memset(FSSktArray, 0, FSsktbytes);

      /* Fill in the socket information for each fileserve  */

      curr_skt = FSSktArray;
      curr_FS = FSnameList;  /* FS name list header */
      while (curr_FS) {
        strncpy(fullhostname,curr_FS->hostName,sizeof(fullhostname));
        he = GetHostByName(fullhostname);
        if (he == (struct hostent *) NULL) {
          sprintf(buffer,"Cannot get host info for %s", fullhostname);
          BSETCODE(-1, buffer);
          XSRETURN_UNDEF;
        }
        strncpy(curr_FS->hostName,he->h_name,HOST_NAME_LEN); /* complete name*/
        memcpy(&(curr_skt->sin_addr.s_addr), he->h_addr, 4);
#if defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
            curr_skt->sin_family = AF_INET;             /*Internet family */
#else
            curr_skt->sin_family = htons(AF_INET);      /*Internet family */
#endif
        curr_skt->sin_port   = htons(7000);       /*FileServer port*/
#ifdef STRUCT_SOCKADDR_HAS_SA_LEN
        curr_skt->sin_len = sizeof(struct sockaddr_in);
#endif
        /* get the next dude */
        curr_skt++;
        curr_FS = curr_FS->next;
      }

      /* initialize collection IDs. We need only one entry since we collect
         all the information from xstat */

      numCollIDs = 1;
      collIDP = (afs_int32 *) malloc (sizeof (afs_int32));
      if (collIDP == (afs_int32 *) NULL) {
        sprintf(buffer,"failed to allocate a measely afs_int32 word. Argh!");
        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);
      CMSktArray = (struct sockaddr_in *) malloc(CMsktbytes);
      if (CMSktArray == (struct sockaddr_in *) NULL) {
        sprintf(buffer,"cannot malloc %d sockaddr_ins for CM entries", numCM);
        BSETCODE(-1, buffer);
        XSRETURN_UNDEF;
      }

      memset(CMSktArray, 0, CMsktbytes);

      /* Fill in the socket information for each CM  */

      curr_skt = CMSktArray;
      curr_CM = CMnameList;  /* CM name list header */
      while (curr_CM) {
        strncpy(fullhostname,curr_CM->hostName,sizeof(fullhostname));
        he = GetHostByName(fullhostname);
        if (he == (struct hostent *) NULL) {
          sprintf(buffer,"Cannot get host info for %s", fullhostname);
          BSETCODE(-1, buffer);
          XSRETURN_UNDEF;
        }
        strncpy(curr_CM->hostName,he->h_name,HOST_NAME_LEN); /* complete name*/
        memcpy(&(curr_skt->sin_addr.s_addr), he->h_addr, 4);
        curr_skt->sin_family = htons(AF_INET);    /*Internet family*/
        curr_skt->sin_port   = htons(7001);  /*Cache Manager port */
#ifdef STRUCT_SOCKADDR_HAS_SA_LEN
        curr_skt->sin_len = sizeof(struct sockaddr_in);
#endif

        /* get the next dude */
        curr_skt++;
        curr_CM = curr_CM->next;
      }

      /* initialize collection IDs. We need only one entry since we collect
         all the information from xstat */

      numCollIDs = 1;
      collIDP = (afs_int32 *) malloc (sizeof (afs_int32));
      if (collIDP == (afs_int32 *) NULL) {
        sprintf(buffer,"failed to allocate a measely afs_int32 word. Argh!");
        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);

    EXTEND(SP, 2);
    PUSHs(sv_2mortal(newRV_inc((SV*)FILESERV)));
    PUSHs(sv_2mortal(newRV_inc((SV*)CACHEMAN)));
  }


src/Monitor.xs  view on Meta::CPAN

      BSETCODE(code, buffer);
      XSRETURN_UNDEF;
    }

    withSecStats = (supportedDebugValues & RX_SERVER_DEBUG_SEC_STATS);
    withAllConn = (supportedDebugValues & RX_SERVER_DEBUG_ALL_CONN);
    withRxStats = (supportedDebugValues & RX_SERVER_DEBUG_RX_STATS);
    withWaiters = (supportedDebugValues & RX_SERVER_DEBUG_WAITER_CNT);
    withIdleThreads = (supportedDebugValues & RX_SERVER_DEBUG_IDLE_THREADS);
    withPeers = (supportedDebugValues & RX_SERVER_DEBUG_ALL_PEER);

    TSTATS = newHV();
    hv_store(TSTATS, "nFreePackets", 12, newSViv(tstats.nFreePackets), 0);
    hv_store(TSTATS, "packetReclaims", 14, newSViv(tstats.packetReclaims), 0);
    hv_store(TSTATS, "callsExecuted", 13, newSViv(tstats.callsExecuted), 0);
    hv_store(TSTATS, "usedFDs", 7, newSViv(tstats.usedFDs), 0);
    hv_store(TSTATS, "waitingForPackets", 17, newSViv(tstats.waitingForPackets), 0);
    hv_store(TSTATS, "version", 7, newSViv(tstats.version), 0);
    if (withWaiters)
       hv_store(TSTATS, "nWaiting", 8, newSViv(tstats.nWaiting), 0);
    if ( withIdleThreads )
       hv_store(TSTATS, "idleThreads", 11, newSViv(tstats.idleThreads), 0);
    hv_store(RETVAL, "tstats", 6, newRV_inc((SV*)(TSTATS)), 0);

    /* get rxstats if requested, and supported by the server */
    /* hash containing stats added at key 'rxstats' in RETVAL */
    if (rxstats)
    {
      if (!withRxStats)
      {
        noRxStats:
        withRxStats = 0;
        warn("WARNING: Server doesn't support retrieval of Rx statistics\n");
      }
      else {
        struct rx_statistics rxstats;

        /* should gracefully handle the case where rx_statistics grows */
        code = rx_GetServerStats(s, host, port, &rxstats, &supportedStatValues);
        if (code < 0) {
          sprintf(buffer, "rxstats call failed with code %d", code);
          VSETCODE(code, buffer);
          XSRETURN_UNDEF;
        }
        if (code != sizeof(rxstats)) {
          if ((((struct rx_debugIn *)(&rxstats))->type == RX_DEBUGI_BADTYPE))
            goto noRxStats;
          warn("WARNING: returned Rx statistics of unexpected size (got %d)\n", code);
          /* handle other versions?... */
        }

        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();
      index = 0;
      for ( i = 0; ; i++) {
        code = rx_GetServerConnections(s, host, port, &nextconn, allconns,
                      supportedDebugValues, &tconn,
                      &supportedConnValues);
        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;
        if (onlyAuth != 999) {
          if (onlyAuth == -1) {
            if (tconn.securityIndex != 0) continue;
          }
          else {
            if (tconn.securityIndex != 2) continue;
            if (withSecStats && (tconn.secStats.type == 3) &&
             (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);

src/Monitor.xs  view on Meta::CPAN


        BYTESSENT = newHV();
        hv_store(BYTESSENT, "high", 4, newSViv(tpeer.bytesSent.high), 0);
        hv_store(BYTESSENT, "low", 3, newSViv(tpeer.bytesSent.low), 0);
        hv_store(TPEER, "bytesSent", 9, newRV_inc((SV*)(BYTESSENT)), 0);

        BYTESRECEIVED = newHV();
        hv_store(BYTESRECEIVED, "high", 4, newSViv(tpeer.bytesReceived.high), 0);
        hv_store(BYTESRECEIVED, "low", 3, newSViv(tpeer.bytesReceived.low), 0);
        hv_store(TPEER, "bytesReceived", 13, newRV_inc((SV*)(BYTESRECEIVED)), 0);

        hv_store(TPEER, "rtt", 3, newSViv(tpeer.rtt), 0);
        hv_store(TPEER, "rtt_dev", 7, newSViv(tpeer.rtt_dev), 0);

        TIMEOUT = newHV();
        hv_store(TIMEOUT, "sec", 3, newSViv(tpeer.timeout.sec), 0);
        hv_store(TIMEOUT, "usec", 4, newSViv(tpeer.timeout.usec), 0);
        hv_store(TPEER, "timeout", 7, newRV_inc((SV*)(TIMEOUT)), 0);

        if (showLong) {
          hv_store(TPEER, "inPacketSkew", 12,
                   newSViv(tpeer.inPacketSkew), 0);
          hv_store(TPEER, "outPacketSkew", 13,
                   newSViv(tpeer.outPacketSkew), 0);
          hv_store(TPEER, "cwind", 5,
                   newSViv(tpeer.cwind), 0);
          hv_store(TPEER, "MTU", 3,
                   newSViv(tpeer.MTU), 0);
          hv_store(TPEER, "nDgramPackets", 13,
                   newSViv(tpeer.nDgramPackets), 0);
          hv_store(TPEER, "ifDgramPackets", 14,
                   newSViv(tpeer.ifDgramPackets), 0);
          hv_store(TPEER, "maxDgramPackets", 15,
                   newSViv(tpeer.maxDgramPackets), 0);
        }

        av_store(PEERS, index, newRV_inc((SV*)(TPEER)));
        index++;
      }

      hv_store(RETVAL, "peers", 5, newRV_inc((SV*)(PEERS)), 0);
    }

    done:
    /* return RETVAL */
    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
constant(name, arg=0)
	char *	name
        int     arg
   PPCODE:
   {
  ST(0) = sv_newmortal();

  errno = EINVAL;

  switch (name[0]) {
  case 'A':
	switch (name[1]) {
	case 'F':
		switch (name[2]) {
		case 'S':
		if (strEQ(name,"AFSCB_MAX_XSTAT_LONGS"))
                    sv_setiv(ST(0),AFSCB_MAX_XSTAT_LONGS);
		else if (strEQ(name,"AFSCB_XSTATSCOLL_CALL_INFO"))
                    sv_setiv(ST(0),AFSCB_XSTATSCOLL_CALL_INFO);
		else if (strEQ(name,"AFSCB_XSTATSCOLL_FULL_PERF_INFO"))
                    sv_setiv(ST(0),AFSCB_XSTATSCOLL_FULL_PERF_INFO);
		else if (strEQ(name,"AFSCB_XSTATSCOLL_PERF_INFO"))
                    sv_setiv(ST(0),AFSCB_XSTATSCOLL_PERF_INFO);
		else if (strEQ(name,"AFSCB_XSTAT_VERSION"))
                    sv_setiv(ST(0),AFSCB_XSTAT_VERSION);
		else if (strEQ(name,"AFSCONF_VOLUMEPORT"))
                    sv_setiv(ST(0),AFSCONF_VOLUMEPORT);
		else if (strEQ(name,"AFS_MAX_XSTAT_LONGS"))
                    sv_setiv(ST(0),AFS_MAX_XSTAT_LONGS);
		else if (strEQ(name,"AFS_STATS_NUM_CM_RPC_OPS"))
                    sv_setiv(ST(0),AFS_STATS_NUM_CM_RPC_OPS);
		else if (strEQ(name,"AFS_STATS_NUM_FS_RPC_OPS"))
                    sv_setiv(ST(0),AFS_STATS_NUM_FS_RPC_OPS);
		else if (strEQ(name,"AFS_STATS_NUM_FS_XFER_OPS"))
                    sv_setiv(ST(0),AFS_STATS_NUM_FS_XFER_OPS);
		else if (strEQ(name,"AFS_XSTATSCOLL_CALL_INFO"))
                    sv_setiv(ST(0),AFS_XSTATSCOLL_CALL_INFO);
#ifndef NOAFS_XSTATSCOLL_CBSTATS
		else if (strEQ(name,"AFS_XSTATSCOLL_CBSTATS"))
                    sv_setiv(ST(0),AFS_XSTATSCOLL_CBSTATS);
#endif
		else if (strEQ(name,"AFS_XSTATSCOLL_FULL_PERF_INFO"))
                    sv_setiv(ST(0),AFS_XSTATSCOLL_FULL_PERF_INFO);
		else if (strEQ(name,"AFS_XSTATSCOLL_PERF_INFO"))
                    sv_setiv(ST(0),AFS_XSTATSCOLL_PERF_INFO);
		else if (strEQ(name,"AFS_XSTAT_VERSION"))
                    sv_setiv(ST(0),AFS_XSTAT_VERSION);
		else {
		     ST(0) = ST(1) = &PL_sv_undef;
		     return;
		}
		break;
		case '_':
		if (strEQ(name,"AF_INET")) sv_setiv(ST(0),AF_INET);
		else {
		     ST(0) = ST(1) = &PL_sv_undef;
		     return;
		}
		break;
  		default:
  			ST(0) = ST(1) = &PL_sv_undef;
			return;
  		}
  		break;
  	default:
  		ST(0) = ST(1) = &PL_sv_undef;
		return;
  	}
  	break;
  case 'C':
	switch (name[1]) {
	case 'F':
		switch (name[2]) {
		case 'G':
		if (strEQ(name,"CFG_STR_LEN"))
                    sv_setiv(ST(0),CFG_STR_LEN);
		else {
		     ST(0) = ST(1) = &PL_sv_undef;
		     return;
		}
		break;
  		default:
  			ST(0) = ST(1) = &PL_sv_undef;
			return;
  		}
  		break;
	case 'M':
		if (strEQ(name,"CM")) sv_setiv(ST(0),CM);
                else {
		switch (name[2]) {
		case '_':
		if (strEQ(name,"CM_NUM_DATA_CATEGORIES"))
                    sv_setiv(ST(0),CM_NUM_DATA_CATEGORIES);
		else if (strEQ(name,"CM_STAT_STRING_LEN"))
                    sv_setiv(ST(0),CM_STAT_STRING_LEN);
		else {
		     ST(0) = ST(1) = &PL_sv_undef;
		     return;
		}
		break;
  		default:
  			ST(0) = ST(1) = &PL_sv_undef;
			return;
  		}
                }
  		break;
  	default:
  		ST(0) = ST(1) = &PL_sv_undef;
		return;
  	}
  	break;
  case 'F':
	switch (name[1]) {
	case 'S':
		if (strEQ(name,"FS")) sv_setiv(ST(0),FS);
                else {
		switch (name[2]) {
		case 'P':
		if (strEQ(name,"FSPROBE_CBPORT"))
                    sv_setiv(ST(0),FSPROBE_CBPORT);
		else {
		     ST(0) = ST(1) = &PL_sv_undef;
		     return;
		}
		break;
		case '_':
		if (strEQ(name,"FS_NUM_DATA_CATEGORIES"))
                    sv_setiv(ST(0),FS_NUM_DATA_CATEGORIES);
		else if (strEQ(name,"FS_STATS_NUM_RPC_OPS"))
                    sv_setiv(ST(0),FS_STATS_NUM_RPC_OPS);
		else if (strEQ(name,"FS_STATS_NUM_XFER_OPS"))
                    sv_setiv(ST(0),FS_STATS_NUM_XFER_OPS);
		else if (strEQ(name,"FS_STAT_STRING_LEN"))
                    sv_setiv(ST(0),FS_STAT_STRING_LEN);
		else {
		     ST(0) = ST(1) = &PL_sv_undef;
		     return;
		}
		break;
  		default:
  			ST(0) = ST(1) = &PL_sv_undef;
			return;
  		}
                }
  		break;
  	default:
  		ST(0) = ST(1) = &PL_sv_undef;
		return;
  	}
  	break;
  case 'H':
	switch (name[1]) {
	case 'O':
		switch (name[2]) {
		case 'S':
		if (strEQ(name,"HOST_NAME_LEN"))
                    sv_setiv(ST(0),HOST_NAME_LEN);
		else {
		     ST(0) = ST(1) = &PL_sv_undef;
		     return;
		}
		break;
  		default:
  			ST(0) = ST(1) = &PL_sv_undef;
			return;
  		}
  		break;
  	default:
  		ST(0) = ST(1) = &PL_sv_undef;
		return;
  	}
  	break;
  case 'M':
	switch (name[1]) {
	case 'A':
		switch (name[2]) {
		case 'X':
		if (strEQ(name,"MAXSKEW"))
                    sv_setiv(ST(0),MAXSKEW);
		else {
		     ST(0) = ST(1) = &PL_sv_undef;
		     return;
		}
		break;
  		default:
  			ST(0) = ST(1) = &PL_sv_undef;
			return;
  		}
  		break;
  	default:
  		ST(0) = ST(1) = &PL_sv_undef;
		return;
  	}
  	break;
  case 'N':
	switch (name[1]) {
	case 'U':
		switch (name[2]) {
		case 'M':
		if (strEQ(name,"NUM_AFS_STATS_CMPERF_LONGS"))
                    sv_setiv(ST(0),NUM_AFS_STATS_CMPERF_LONGS);
		else if (strEQ(name,"NUM_CM_STAT_ENTRIES"))
                    sv_setiv(ST(0),NUM_CM_STAT_ENTRIES);
		else if (strEQ(name,"NUM_FS_STAT_ENTRIES"))
                    sv_setiv(ST(0),NUM_FS_STAT_ENTRIES);
		else if (strEQ(name,"NUM_XSTAT_FS_AFS_PERFSTATS_LONGS"))
                    sv_setiv(ST(0),NUM_XSTAT_FS_AFS_PERFSTATS_LONGS);
		else {
		     ST(0) = ST(1) = &PL_sv_undef;
		     return;
		}
		break;
  		default:
  			ST(0) = ST(1) = &PL_sv_undef;
			return;
  		}
  		break;
  	default:
  		ST(0) = ST(1) = &PL_sv_undef;
		return;
  	}
  	break;
  case 'P':
	switch (name[1]) {
	case 'A':
		switch (name[2]) {
		case 'R':
		if (strEQ(name,"PARTVALID"))
                    sv_setiv(ST(0),PARTVALID);
		else {
		     ST(0) = ST(1) = &PL_sv_undef;
		     return;
		}
		break;
  		default:
  			ST(0) = ST(1) = &PL_sv_undef;
			return;
  		}
  		break;
  	default:
  		ST(0) = ST(1) = &PL_sv_undef;
		return;
  	}
  	break;
  case 'R':
	switch (name[1]) {
	case 'E':
		switch (name[2]) {
		case 'A':
		if (strEQ(name,"READ_LOCK"))
                    sv_setiv(ST(0),READ_LOCK);
		else {
		     ST(0) = ST(1) = &PL_sv_undef;
		     return;
		}
		break;
  		default:
  			ST(0) = ST(1) = &PL_sv_undef;
			return;
  		}
  		break;
	case 'X':
		switch (name[2]) {
		case 'G':
		if (strEQ(name,"RXGEN_OPCODE"))
                    sv_setiv(ST(0),RXGEN_OPCODE);
		else {
		     ST(0) = ST(1) = &PL_sv_undef;
		     return;
		}
		break;
		case '_':
		if (strEQ(name,"RX_ADDRINUSE"))
                    sv_setiv(ST(0),RX_ADDRINUSE);
		else if (strEQ(name,"RX_CALL_CLEARED"))
                    sv_setiv(ST(0),RX_CALL_CLEARED);
		else if (strEQ(name,"RX_CALL_READER_WAIT"))
                    sv_setiv(ST(0),RX_CALL_READER_WAIT);
		else if (strEQ(name,"RX_CALL_RECEIVE_DONE"))
                    sv_setiv(ST(0),RX_CALL_RECEIVE_DONE);
		else if (strEQ(name,"RX_CALL_WAIT_PACKETS"))
                    sv_setiv(ST(0),RX_CALL_WAIT_PACKETS);
		else if (strEQ(name,"RX_CALL_WAIT_PROC"))
                    sv_setiv(ST(0),RX_CALL_WAIT_PROC);
		else if (strEQ(name,"RX_CALL_WAIT_WINDOW_ALLOC"))
                    sv_setiv(ST(0),RX_CALL_WAIT_WINDOW_ALLOC);
		else if (strEQ(name,"RX_CALL_WAIT_WINDOW_SEND"))
                    sv_setiv(ST(0),RX_CALL_WAIT_WINDOW_SEND);
		else if (strEQ(name,"RX_CLIENT_CONNECTION"))
                    sv_setiv(ST(0),RX_CLIENT_CONNECTION);
		else if (strEQ(name,"RX_CONN_DESTROY_ME"))
                    sv_setiv(ST(0),RX_CONN_DESTROY_ME);
		else if (strEQ(name,"RX_CONN_MAKECALL_WAITING"))
                    sv_setiv(ST(0),RX_CONN_MAKECALL_WAITING);
		else if (strEQ(name,"RX_CONN_USING_PACKET_CKSUM"))
                    sv_setiv(ST(0),RX_CONN_USING_PACKET_CKSUM);
		else if (strEQ(name,"RX_DEBUGI_VERSION_W_NEWPACKETTYPES"))
                    sv_setiv(ST(0),RX_DEBUGI_VERSION_W_NEWPACKETTYPES);
		else if (strEQ(name,"RX_MAXCALLS"))
                    sv_setiv(ST(0),RX_MAXCALLS);
		else if (strEQ(name,"RX_MODE_EOF"))
                    sv_setiv(ST(0),RX_MODE_EOF);
		else if (strEQ(name,"RX_MODE_ERROR"))
                    sv_setiv(ST(0),RX_MODE_ERROR);
		else if (strEQ(name,"RX_MODE_RECEIVING"))
                    sv_setiv(ST(0),RX_MODE_RECEIVING);
		else if (strEQ(name,"RX_MODE_SENDING"))
                    sv_setiv(ST(0),RX_MODE_SENDING);
		else if (strEQ(name,"RX_N_PACKET_TYPES"))
                    sv_setiv(ST(0),RX_N_PACKET_TYPES);
		else if (strEQ(name,"RX_OTHER_IN"))
                    sv_setiv(ST(0),RX_OTHER_IN);
		else if (strEQ(name,"RX_OTHER_OUT"))
                    sv_setiv(ST(0),RX_OTHER_OUT);
		else if (strEQ(name,"RX_SERVER_CONNECTION"))
                    sv_setiv(ST(0),RX_SERVER_CONNECTION);
		else if (strEQ(name,"RX_SERVER_DEBUG_ALL_CONN"))
                    sv_setiv(ST(0),RX_SERVER_DEBUG_ALL_CONN);
		else if (strEQ(name,"RX_SERVER_DEBUG_ALL_PEER"))
                    sv_setiv(ST(0),RX_SERVER_DEBUG_ALL_PEER);
		else if (strEQ(name,"RX_SERVER_DEBUG_IDLE_THREADS"))
                    sv_setiv(ST(0),RX_SERVER_DEBUG_IDLE_THREADS);
		else if (strEQ(name,"RX_SERVER_DEBUG_RX_STATS"))
                    sv_setiv(ST(0),RX_SERVER_DEBUG_RX_STATS);
		else if (strEQ(name,"RX_SERVER_DEBUG_SEC_STATS"))
                    sv_setiv(ST(0),RX_SERVER_DEBUG_SEC_STATS);
		else if (strEQ(name,"RX_SERVER_DEBUG_WAITER_CNT"))
                    sv_setiv(ST(0),RX_SERVER_DEBUG_WAITER_CNT);
		else if (strEQ(name,"RX_STATE_ACTIVE"))
                    sv_setiv(ST(0),RX_STATE_ACTIVE);
		else if (strEQ(name,"RX_STATE_DALLY"))
                    sv_setiv(ST(0),RX_STATE_DALLY);
		else if (strEQ(name,"RX_STATE_HOLD"))
                    sv_setiv(ST(0),RX_STATE_HOLD);
		else if (strEQ(name,"RX_STATE_NOTINIT"))
                    sv_setiv(ST(0),RX_STATE_NOTINIT);
		else if (strEQ(name,"RX_STATE_PRECALL"))
                    sv_setiv(ST(0),RX_STATE_PRECALL);
		else {
		     ST(0) = ST(1) = &PL_sv_undef;
		     return;
		}
		break;
  		default:
  			ST(0) = ST(1) = &PL_sv_undef;
			return;
  		}
  		break;
  	default:
  		ST(0) = ST(1) = &PL_sv_undef;
		return;
  	}
  	break;
  case 'S':
	switch (name[1]) {
	case 'H':
		switch (name[2]) {
		case 'A':
		if (strEQ(name,"SHARED_LOCK"))
                    sv_setiv(ST(0),SHARED_LOCK);
		else {
		     ST(0) = ST(1) = &PL_sv_undef;
		     return;
		}
		break;
  		default:
  			ST(0) = ST(1) = &PL_sv_undef;
			return;
  		}
  		break;
	case 'O':
		switch (name[2]) {
		case 'C':
		if (strEQ(name,"SOCK_DGRAM"))
                    sv_setiv(ST(0),SOCK_DGRAM);
		else {
		     ST(0) = ST(1) = &PL_sv_undef;
		     return;
		}
		break;
  		default:
  			ST(0) = ST(1) = &PL_sv_undef;
			return;
  		}
  		break;
  	default:
  		ST(0) = ST(1) = &PL_sv_undef;
		return;
  	}
  	break;
  case 'T':
	switch (name[1]) {
	case 'H':
		switch (name[2]) {
		case 'R':
		if (strEQ(name,"THRESH_VAR_LEN"))
                    sv_setiv(ST(0),THRESH_VAR_LEN);
		else if (strEQ(name,"THRESH_VAR_NAME_LEN"))
                    sv_setiv(ST(0),THRESH_VAR_NAME_LEN);
		else {
		     ST(0) = ST(1) = &PL_sv_undef;
		     return;
		}
		break;
  		default:
  			ST(0) = ST(1) = &PL_sv_undef;
			return;
  		}
  		break;
  	default:
  		ST(0) = ST(1) = &PL_sv_undef;
		return;
  	}
  	break;
  case 'U':
	switch (name[1]) {
	case 'B':
		switch (name[2]) {
		case 'I':
		if (strEQ(name,"UBIK_MAX_INTERFACE_ADDR"))
                    sv_setiv(ST(0),UBIK_MAX_INTERFACE_ADDR);
		else {
		     ST(0) = ST(1) = &PL_sv_undef;
		     return;
		}
		break;
  		default:
  			ST(0) = ST(1) = &PL_sv_undef;
			return;
  		}
  		break;
  	default:
  		ST(0) = ST(1) = &PL_sv_undef;
		return;
  	}
  	break;
  case 'V':
	switch (name[1]) {
	case 'O':
		switch (name[2]) {
		case 'L':
		if (strEQ(name,"VOLMAXPARTS"))
                    sv_setiv(ST(0),VOLMAXPARTS);
		else if (strEQ(name,"VOLSERVICE_ID"))
                    sv_setiv(ST(0),VOLSERVICE_ID);
		else {
		     ST(0) = ST(1) = &PL_sv_undef;
		     return;
		}
		break;
		case 'T':
		if (strEQ(name,"VOTE_SERVICE_ID"))
                    sv_setiv(ST(0),VOTE_SERVICE_ID);
		else {
		     ST(0) = ST(1) = &PL_sv_undef;
		     return;
		}
		break;
  		default:
  			ST(0) = ST(1) = &PL_sv_undef;
			return;
  		}
  		break;
  	default:
  		ST(0) = ST(1) = &PL_sv_undef;
		return;
  	}
  	break;
  case 'W':
	switch (name[1]) {
	case 'R':
		switch (name[2]) {
		case 'I':
		if (strEQ(name,"WRITE_LOCK"))
                    sv_setiv(ST(0),WRITE_LOCK);
		else {
		     ST(0) = ST(1) = &PL_sv_undef;
		     return;
		}
		break;
  		default:
  			ST(0) = ST(1) = &PL_sv_undef;
			return;
  		}
  		break;
  	default:
  		ST(0) = ST(1) = &PL_sv_undef;
		return;
  	}
  	break;
  case 'X':
	switch (name[1]) {
	case 'S':
		switch (name[2]) {
		case 'T':
		if (strEQ(name,"XSTAT_FS_CBPORT"))
                    sv_setiv(ST(0),XSTAT_FS_CBPORT);
		else {
		     ST(0) = ST(1) = &PL_sv_undef;
		     return;
		}
		break;
  		default:
  			ST(0) = ST(1) = &PL_sv_undef;
			return;
  		}
  		break;
  	default:
  		ST(0) = ST(1) = &PL_sv_undef;
		return;
  	}
  	break;
  default:
  	ST(0) = ST(1) = &PL_sv_undef;
	return;
  }

  errno = 0;
  XSRETURN(1);
  return;
 }



( run in 0.844 second using v1.01-cache-2.11-cpan-39bf76dae61 )