AFS-Monitor
view release on metacpan or search on metacpan
src/Monitor.xs view on Meta::CPAN
void
my_Print_fs_DetailedPerfInfo(a_detP, fs_outFD)
struct fs_stats_DetailedStats *a_detP;
FILE *fs_outFD;
{
int currIdx = 0; /*Loop variable */
fprintf(fs_outFD, "\t%10d epoch\n", a_detP->epoch);
for (currIdx = 0; currIdx < FS_STATS_NUM_RPC_OPS; currIdx++)
my_Print_fs_OpTiming(currIdx, &(a_detP->rpcOpTimes[currIdx]), fs_outFD);
for (currIdx = 0; currIdx < FS_STATS_NUM_XFER_OPS; currIdx++)
my_Print_fs_XferTiming(currIdx, &(a_detP->xferOpTimes[currIdx]),
fs_outFD);
} /* my_Print_fs_DetailedPerfInfo() */
/*
* from src/afsmonitor/afsmon-output.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_Print_fs_FullPerfInfo(a_fs_Results, fs_outFD)
struct xstat_fs_ProbeResults *a_fs_Results;
FILE *fs_outFD;
{
/*Correct # longs to rcv */
static afs_int32 fullPerfLongs = (sizeof(struct fs_stats_FullPerfStats) >> 2);
afs_int32 numLongs = 0; /*# longwords received */
struct fs_stats_FullPerfStats *fullPerfP = 0; /*Ptr to full perf stats */
char *printableTime = 0; /*Ptr to printable time string */
numLongs = a_fs_Results->data.AFS_CollData_len;
if (numLongs != fullPerfLongs) {
fprintf(fs_outFD,
" ** Data size mismatch in full performance collection!\n");
fprintf(fs_outFD, " ** Expecting %d, got %d\n", fullPerfLongs,
numLongs);
return;
}
printableTime = ctime((time_t *) & (a_fs_Results->probeTime));
printableTime[strlen(printableTime) - 1] = '\0';
fullPerfP = (struct fs_stats_FullPerfStats *)
(a_fs_Results->data.AFS_CollData_val);
fprintf(fs_outFD,
"AFS_XSTATSCOLL_FULL_PERF_INFO (coll %d) for FS %s\n[Probe %d, %s]\n\n",
a_fs_Results->collectionNumber, a_fs_Results->connP->hostName,
a_fs_Results->probeNum, printableTime);
my_Print_fs_OverallPerfInfo(&(fullPerfP->overall), fs_outFD);
my_Print_fs_DetailedPerfInfo(&(fullPerfP->det), fs_outFD);
}
/*
* from src/afsmonitor/afsmon-output.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_afsmon_fsOutput(a_outfile, a_detOutput, xstat_fs_Results)
char *a_outfile; /* ptr to output file name */
int a_detOutput; /* detailed output ? */
struct xstat_fs_ProbeResults xstat_fs_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 *fs_outFD = 0;
fs_outFD = fopen(a_outfile, "a");
if (fs_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_fs_Results.probeTime));
printTime[strlen(printTime) - 1] = '\0';
hostname = xstat_fs_Results.connP->hostName;
/* print "time hostname FS" */
fprintf(fs_outFD, "\n%s %s FS ", printTime, hostname);
/* if probe failed print -1 and return */
if (xstat_fs_Results.probeOK) {
fprintf(fs_outFD, "-1\n");
fclose(fs_outFD);
return;
}
/* print out the probe information as long words */
numLongs = xstat_fs_Results.data.AFS_CollData_len;
currLong = (afs_int32 *) (xstat_fs_Results.data.AFS_CollData_val);
for (i = 0; i < numLongs; i++) {
fprintf(fs_outFD, "%d ", *currLong++);
}
fprintf(fs_outFD, "\n\n");
/* print detailed information */
if (a_detOutput) {
my_Print_fs_FullPerfInfo(&xstat_fs_Results, fs_outFD);
fflush(fs_outFD);
}
fclose(fs_outFD);
} /* my_afsmon_fsOutput() */
/*
* 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_fs_Results_ltoa(a_fsData, a_fsResults)
struct fs_Display_Data *a_fsData; /* target buffer */
struct xstat_fs_ProbeResults *a_fsResults; /* ptr to xstat fs Results */
{
afs_int32 *srcbuf;
struct fs_stats_FullPerfStats *fullPerfP;
int idx;
int i, j;
afs_int32 *tmpbuf;
fullPerfP = (struct fs_stats_FullPerfStats *)
(a_fsResults->data.AFS_CollData_val);
src/Monitor.xs view on Meta::CPAN
* 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);
/* add everything to data structure */
code =
my_save_FS_data_forDisplay(&xstat_fs_Results, HOSTINFO, numFS,
FSnameList, fs_showFlags, fs_showDefault,
buffer);
if (code) {
return (code);
}
/* 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.
*/
src/Monitor.xs view on Meta::CPAN
fprintf(cm_outFD, " ** Expecting %d, got %d\n", fullPerfLongs,
numLongs);
return;
}
printableTime = ctime((time_t *) & (xstat_cm_Results.probeTime));
printableTime[strlen(printableTime) - 1] = '\0';
fullP = (struct afs_stats_CMFullPerf *)
(xstat_cm_Results.data.AFSCB_CollData_val);
fprintf(cm_outFD,
"AFSCB_XSTATSCOLL_FULL_PERF_INFO (coll %d) for CM %s\n[Probe %d, %s]\n\n",
xstat_cm_Results.collectionNumber,
xstat_cm_Results.connP->hostName, xstat_cm_Results.probeNum,
printableTime);
/*
* Print the overall numbers first, followed by all of the RPC numbers,
* then each of the other groupings.
*/
fprintf(cm_outFD,
"Overall Performance Info:\n-------------------------\n");
my_Print_cm_OverallPerfInfo(&(fullP->perf), cm_outFD);
fprintf(cm_outFD, "\n");
my_Print_cm_RPCPerfInfo(&(fullP->rpc), cm_outFD);
authentP = &(fullP->authent);
fprintf(cm_outFD, "\nAuthentication info:\n--------------------\n");
fprintf(cm_outFD,
"\t%d PAGS, %d records (%d auth, %d unauth), %d max in PAG, chain max: %d\n",
authentP->curr_PAGs, authentP->curr_Records,
authentP->curr_AuthRecords, authentP->curr_UnauthRecords,
authentP->curr_MaxRecordsInPAG, authentP->curr_LongestChain);
fprintf(cm_outFD, "\t%d PAG creations, %d tkt updates\n",
authentP->PAGCreations, authentP->TicketUpdates);
fprintf(cm_outFD,
"\t[HWMs: %d PAGS, %d records, %d max in PAG, chain max: %d]\n",
authentP->HWM_PAGs, authentP->HWM_Records,
authentP->HWM_MaxRecordsInPAG, authentP->HWM_LongestChain);
accessinfP = &(fullP->accessinf);
fprintf(cm_outFD,
"\n[Un]replicated accesses:\n------------------------\n");
fprintf(cm_outFD,
"\t%d unrep, %d rep, %d reps accessed, %d max reps/ref, %d first OK\n\n",
accessinfP->unreplicatedRefs, accessinfP->replicatedRefs,
accessinfP->numReplicasAccessed, accessinfP->maxReplicasPerRef,
accessinfP->refFirstReplicaOK);
/* There really isn't any authorship info
* authorP = &(fullP->author); */
} /* my_Print_cm_FullPerfInfo() */
/*
* from src/afsmonitor/afsmon-output.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_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;
src/Monitor.xs view on Meta::CPAN
/* 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;
{
int code = 0;
char *outputfile = va_arg(argp, char *);
int detailed = va_arg(argp, int);
AV *CACHEMAN = va_arg(argp, AV *);
struct afsmon_hostEntry *CMnameList =
va_arg(argp, struct afsmon_hostEntry *);
short *cm_showFlags = va_arg(argp, short *);
int cm_showDefault = va_arg(argp, int);
HV *HOSTINFO = newHV();
if (outputfile) {
my_afsmon_cmOutput(outputfile, detailed, xstat_cm_Results);
}
/* add everything to data structure */
code =
my_save_CM_data_forDisplay(&xstat_cm_Results, HOSTINFO, numCM,
CMnameList, cm_showFlags, cm_showDefault,
buffer);
if (code) {
return (code);
}
/* 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.
*/
( run in 0.595 second using v1.01-cache-2.11-cpan-39bf76dae61 )