AFS-Monitor

 view release on metacpan or  search on metacpan

src/Monitor.xs  view on Meta::CPAN

 *    ("$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_afsmon_cmOutput(a_outfile, a_detOutput, xstat_cm_Results)
   char *a_outfile;             /* ptr to output file name */
   int a_detOutput;             /* detailed output ? */
   struct xstat_cm_ProbeResults xstat_cm_Results;
{

   char *printTime = 0;         /* ptr to time string */
   char *hostname = 0;          /* fileserner name */
   afs_int32 numLongs = 0;      /* longwords in result */
   afs_int32 *currLong = 0;     /* ptr to longwords in result */
   int i = 0;
   FILE *cm_outFD = 0;

   cm_outFD = fopen(a_outfile, "a");
   if (cm_outFD == (FILE *) NULL) {
      warn("failed to open output file %s", a_outfile);
      return;
   }

   /* get the probe time and strip the \n at the end */
   printTime = ctime((time_t *) & (xstat_cm_Results.probeTime));
   printTime[strlen(printTime) - 1] = '\0';
   hostname = xstat_cm_Results.connP->hostName;

   /* print "time hostname CM" prefix */
   fprintf(cm_outFD, "\n%s %s CM ", printTime, hostname);

   /* if probe failed print -1 and vanish */
   if (xstat_cm_Results.probeOK) {
      fprintf(cm_outFD, "-1\n");
      fclose(cm_outFD);
      return;
   }

   /* print out the probe information as  long words */
   numLongs = xstat_cm_Results.data.AFSCB_CollData_len;
   currLong = (afs_int32 *) (xstat_cm_Results.data.AFSCB_CollData_val);

   for (i = 0; i < numLongs; i++) {
      fprintf(cm_outFD, "%d ", *currLong++);
   }
   fprintf(cm_outFD, "\n\n");

   /* print detailed information */
   if (a_detOutput) {
      my_Print_cm_FullPerfInfo(xstat_cm_Results, cm_outFD);
      fflush(cm_outFD);
   }

   fclose(cm_outFD);

}   /* my_afsmon_cmOutput() */



/*
 * unchanged except for removing debugging print statements at beginning, and one
 * correction (replacing xstat_cm_Results with a_cmResults)
 *
 * 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_cm_Results_ltoa(a_cmData, a_cmResults)
   struct cm_Display_Data *a_cmData;    /* target buffer */
   struct xstat_cm_ProbeResults *a_cmResults;   /* ptr to xstat cm Results */
{
   struct afs_stats_CMFullPerf *fullP;  /* ptr to complete CM stats */
   afs_int32 *srcbuf;
   afs_int32 *tmpbuf;
   int i, j;
   int idx;
   afs_int32 numLongs;


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

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


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


   /* we skip the 19 entry, ProtServAddr, so the index must account for this */
   for (i = 0; i < NUM_AFS_STATS_CMPERF_LONGS + 1; i++) {
      if (i == 19) {
         srcbuf++;
         continue;  /* skip ProtServerAddr */
      }
      sprintf(a_cmData->data[idx], "%d", *srcbuf);
      idx++;
      srcbuf++;
   }

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

   /* server up/down statistics */
   /* copy file server up/down stats */
   srcbuf = (afs_int32 *) (fullP->perf.fs_UpDown);
   numLongs =
      2 * (sizeof(struct afs_stats_SrvUpDownInfo) / sizeof(afs_int32));
   for (i = 0; i < numLongs; i++) {
      sprintf(a_cmData->data[idx], "%d", *srcbuf);
      idx++;
      srcbuf++;
   }



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