2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
12 * Test of the xstat_fs module.
14 *------------------------------------------------------------------------*/
16 #include <afsconfig.h>
17 #include <afs/param.h>
22 #include "xstat_fs.h" /*Interface for xstat_fs module */
23 #include <cmd.h> /*Command line interpreter */
28 * External routines that don't have explicit include file definitions.
30 extern struct hostent *hostutil_GetHostByName();
33 * Command line parameter indices.
34 * P_FS_NAMES : List of FileServer names.
35 * P_COLL_IDS : List of collection IDs to pick up.
36 * P_ONESHOT : Are we gathering exactly one round of data?
37 * P_DEBUG : Enable debugging output?
49 static int debugging_on = 0; /*Are we debugging? */
50 static int one_shot = 0; /*Single round of data collection? */
52 static char *opNames[] = {
83 static char *xferOpNames[] = {
89 /*------------------------------------------------------------------------
93 * Print out the AFS_XSTATSCOLL_CALL_INFO collection we just
103 * All the info we need is nestled into xstat_fs_Results.
107 *------------------------------------------------------------------------*/
113 static char rn[] = "PrintCallInfo"; /*Routine name */
114 register int i; /*Loop variable */
115 int numInt32s; /*# int32words returned */
116 afs_int32 *currInt32; /*Ptr to current afs_int32 value */
117 char *printableTime; /*Ptr to printable time string */
118 time_t probeTime = xstat_fs_Results.probeTime;
121 * Just print out the results of the particular probe.
123 numInt32s = xstat_fs_Results.data.AFS_CollData_len;
124 currInt32 = (afs_int32 *) (xstat_fs_Results.data.AFS_CollData_val);
125 printableTime = ctime(&probeTime);
126 printableTime[strlen(printableTime) - 1] = '\0';
128 printf("AFS_XSTATSCOLL_CALL_INFO (coll %d) for FS %s\n[Probe %d, %s]\n\n",
129 xstat_fs_Results.collectionNumber,
130 xstat_fs_Results.connP->hostName, xstat_fs_Results.probeNum,
134 printf("\n[%d entries returned at 0x%x]\n\n", numInt32s, currInt32);
136 for (i = 0; i < numInt32s; i++)
137 printf("%d ", *currInt32++);
138 fprintf(stderr, "\n");
143 /*------------------------------------------------------------------------
144 * PrintOverallPerfInfo
147 * Print out overall performance numbers.
150 * a_ovP : Ptr to the overall performance numbers.
156 * Nothing interesting.
160 *------------------------------------------------------------------------*/
163 PrintOverallPerfInfo(struct afs_PerfStats *a_ovP)
165 printf("\t%10d numPerfCalls\n\n", a_ovP->numPerfCalls);
168 * Vnode cache section.
170 printf("\t%10d vcache_L_Entries\n", a_ovP->vcache_L_Entries);
171 printf("\t%10d vcache_L_Allocs\n", a_ovP->vcache_L_Allocs);
172 printf("\t%10d vcache_L_Gets\n", a_ovP->vcache_L_Gets);
173 printf("\t%10d vcache_L_Reads\n", a_ovP->vcache_L_Reads);
174 printf("\t%10d vcache_L_Writes\n\n", a_ovP->vcache_L_Writes);
176 printf("\t%10d vcache_S_Entries\n", a_ovP->vcache_S_Entries);
177 printf("\t%10d vcache_S_Allocs\n", a_ovP->vcache_S_Allocs);
178 printf("\t%10d vcache_S_Gets\n", a_ovP->vcache_S_Gets);
179 printf("\t%10d vcache_S_Reads\n", a_ovP->vcache_S_Reads);
180 printf("\t%10d vcache_S_Writes\n\n", a_ovP->vcache_S_Writes);
182 printf("\t%10d vcache_H_Entries\n", a_ovP->vcache_H_Entries);
183 printf("\t%10d vcache_H_Gets\n", a_ovP->vcache_H_Gets);
184 printf("\t%10d vcache_H_Replacements\n\n", a_ovP->vcache_H_Replacements);
187 * Directory package section.
189 printf("\t%10d dir_Buffers\n", a_ovP->dir_Buffers);
190 printf("\t%10d dir_Calls\n", a_ovP->dir_Calls);
191 printf("\t%10d dir_IOs\n\n", a_ovP->dir_IOs);
196 printf("\t%10d rx_packetRequests\n", a_ovP->rx_packetRequests);
197 printf("\t%10d rx_noPackets_RcvClass\n", a_ovP->rx_noPackets_RcvClass);
198 printf("\t%10d rx_noPackets_SendClass\n", a_ovP->rx_noPackets_SendClass);
199 printf("\t%10d rx_noPackets_SpecialClass\n",
200 a_ovP->rx_noPackets_SpecialClass);
201 printf("\t%10d rx_socketGreedy\n", a_ovP->rx_socketGreedy);
202 printf("\t%10d rx_bogusPacketOnRead\n", a_ovP->rx_bogusPacketOnRead);
203 printf("\t%10d rx_bogusHost\n", a_ovP->rx_bogusHost);
204 printf("\t%10d rx_noPacketOnRead\n", a_ovP->rx_noPacketOnRead);
205 printf("\t%10d rx_noPacketBuffersOnRead\n",
206 a_ovP->rx_noPacketBuffersOnRead);
207 printf("\t%10d rx_selects\n", a_ovP->rx_selects);
208 printf("\t%10d rx_sendSelects\n", a_ovP->rx_sendSelects);
209 printf("\t%10d rx_packetsRead_RcvClass\n",
210 a_ovP->rx_packetsRead_RcvClass);
211 printf("\t%10d rx_packetsRead_SendClass\n",
212 a_ovP->rx_packetsRead_SendClass);
213 printf("\t%10d rx_packetsRead_SpecialClass\n",
214 a_ovP->rx_packetsRead_SpecialClass);
215 printf("\t%10d rx_dataPacketsRead\n", a_ovP->rx_dataPacketsRead);
216 printf("\t%10d rx_ackPacketsRead\n", a_ovP->rx_ackPacketsRead);
217 printf("\t%10d rx_dupPacketsRead\n", a_ovP->rx_dupPacketsRead);
218 printf("\t%10d rx_spuriousPacketsRead\n", a_ovP->rx_spuriousPacketsRead);
219 printf("\t%10d rx_packetsSent_RcvClass\n",
220 a_ovP->rx_packetsSent_RcvClass);
221 printf("\t%10d rx_packetsSent_SendClass\n",
222 a_ovP->rx_packetsSent_SendClass);
223 printf("\t%10d rx_packetsSent_SpecialClass\n",
224 a_ovP->rx_packetsSent_SpecialClass);
225 printf("\t%10d rx_ackPacketsSent\n", a_ovP->rx_ackPacketsSent);
226 printf("\t%10d rx_pingPacketsSent\n", a_ovP->rx_pingPacketsSent);
227 printf("\t%10d rx_abortPacketsSent\n", a_ovP->rx_abortPacketsSent);
228 printf("\t%10d rx_busyPacketsSent\n", a_ovP->rx_busyPacketsSent);
229 printf("\t%10d rx_dataPacketsSent\n", a_ovP->rx_dataPacketsSent);
230 printf("\t%10d rx_dataPacketsReSent\n", a_ovP->rx_dataPacketsReSent);
231 printf("\t%10d rx_dataPacketsPushed\n", a_ovP->rx_dataPacketsPushed);
232 printf("\t%10d rx_ignoreAckedPacket\n", a_ovP->rx_ignoreAckedPacket);
233 printf("\t%10d rx_totalRtt_Sec\n", a_ovP->rx_totalRtt_Sec);
234 printf("\t%10d rx_totalRtt_Usec\n", a_ovP->rx_totalRtt_Usec);
235 printf("\t%10d rx_minRtt_Sec\n", a_ovP->rx_minRtt_Sec);
236 printf("\t%10d rx_minRtt_Usec\n", a_ovP->rx_minRtt_Usec);
237 printf("\t%10d rx_maxRtt_Sec\n", a_ovP->rx_maxRtt_Sec);
238 printf("\t%10d rx_maxRtt_Usec\n", a_ovP->rx_maxRtt_Usec);
239 printf("\t%10d rx_nRttSamples\n", a_ovP->rx_nRttSamples);
240 printf("\t%10d rx_nServerConns\n", a_ovP->rx_nServerConns);
241 printf("\t%10d rx_nClientConns\n", a_ovP->rx_nClientConns);
242 printf("\t%10d rx_nPeerStructs\n", a_ovP->rx_nPeerStructs);
243 printf("\t%10d rx_nCallStructs\n", a_ovP->rx_nCallStructs);
244 printf("\t%10d rx_nFreeCallStructs\n", a_ovP->rx_nFreeCallStructs);
245 printf("\t%10d rx_nBusies\n\n", a_ovP->rx_nBusies);
247 printf("\t%10d fs_nBusies\n", a_ovP->fs_nBusies);
248 printf("\t%10d fs_GetCapabilities\n\n", a_ovP->fs_nGetCaps);
250 * Host module fields.
252 printf("\t%10d host_NumHostEntries\n", a_ovP->host_NumHostEntries);
253 printf("\t%10d host_HostBlocks\n", a_ovP->host_HostBlocks);
254 printf("\t%10d host_NonDeletedHosts\n", a_ovP->host_NonDeletedHosts);
255 printf("\t%10d host_HostsInSameNetOrSubnet\n",
256 a_ovP->host_HostsInSameNetOrSubnet);
257 printf("\t%10d host_HostsInDiffSubnet\n", a_ovP->host_HostsInDiffSubnet);
258 printf("\t%10d host_HostsInDiffNetwork\n",
259 a_ovP->host_HostsInDiffNetwork);
260 printf("\t%10d host_NumClients\n", a_ovP->host_NumClients);
261 printf("\t%10d host_ClientBlocks\n\n", a_ovP->host_ClientBlocks);
263 printf("\t%10d sysname_ID\n", a_ovP->sysname_ID);
267 /*------------------------------------------------------------------------
271 * Print out the contents of an RPC op timing structure.
274 * a_opIdx : Index of the AFS operation we're printing number on.
275 * a_opTimeP : Ptr to the op timing structure to print.
281 * Nothing interesting.
285 *------------------------------------------------------------------------*/
288 PrintOpTiming(int a_opIdx, struct fs_stats_opTimingData *a_opTimeP)
290 double fSumTime, avg;
293 ((double)(a_opTimeP->sumTime.tv_sec)) +
294 (((double)(a_opTimeP->sumTime.tv_usec)) / ((double)(1000000)));
295 /* printf("Double sum time is %f\n", fSumTime);*/
296 avg = fSumTime / ((double)(a_opTimeP->numSuccesses));
299 ("%15s: %d ops (%d OK); sum=%d.%06d, sqr=%d.%06d, min=%d.%06d, max=%d.%06d\n",
300 opNames[a_opIdx], a_opTimeP->numOps, a_opTimeP->numSuccesses,
301 a_opTimeP->sumTime.tv_sec, a_opTimeP->sumTime.tv_usec,
302 a_opTimeP->sqrTime.tv_sec, a_opTimeP->sqrTime.tv_usec,
303 a_opTimeP->minTime.tv_sec, a_opTimeP->minTime.tv_usec,
304 a_opTimeP->maxTime.tv_sec, a_opTimeP->maxTime.tv_usec);
308 /*------------------------------------------------------------------------
312 * Print out the contents of a data transfer structure.
315 * a_opIdx : Index of the AFS operation we're printing number on.
316 * a_xferP : Ptr to the data transfer structure to print.
322 * Nothing interesting.
326 *------------------------------------------------------------------------*/
329 PrintXferTiming(int a_opIdx, struct fs_stats_xferData *a_xferP)
331 double fSumTime, avg;
334 ((double)(a_xferP->sumTime.tv_sec)) +
335 ((double)(a_xferP->sumTime.tv_usec)) / ((double)(1000000));
337 avg = fSumTime / ((double)(a_xferP->numSuccesses));
340 ("%s: %d xfers (%d OK), time sum=%d.%06d, sqr=%d.%06d, min=%d.%06d, max=%d.%06d\n",
341 xferOpNames[a_opIdx], a_xferP->numXfers, a_xferP->numSuccesses,
342 a_xferP->sumTime.tv_sec, a_xferP->sumTime.tv_usec,
343 a_xferP->sqrTime.tv_sec, a_xferP->sqrTime.tv_usec,
344 a_xferP->minTime.tv_sec, a_xferP->minTime.tv_usec,
345 a_xferP->maxTime.tv_sec, a_xferP->maxTime.tv_usec);
346 printf("\t[bytes: sum=%lu, min=%d, max=%d]\n", a_xferP->sumBytes,
347 a_xferP->minBytes, a_xferP->maxBytes);
349 ("\t[buckets: 0: %d, 1: %d, 2: %d, 3: %d, 4: %d, 5: %d, 6: %d, 7: %d, 8: %d]\n",
350 a_xferP->count[0], a_xferP->count[1], a_xferP->count[2],
351 a_xferP->count[3], a_xferP->count[4], a_xferP->count[5],
352 a_xferP->count[6], a_xferP->count[7], a_xferP->count[8]);
356 /*------------------------------------------------------------------------
357 * PrintDetailedPerfInfo
360 * Print out a set of detailed performance numbers.
363 * a_detP : Ptr to detailed perf numbers to print.
369 * Nothing interesting.
373 *------------------------------------------------------------------------*/
376 PrintDetailedPerfInfo(struct fs_stats_DetailedStats *a_detP)
378 int currIdx; /*Loop variable */
380 printf("\t%10d epoch\n", a_detP->epoch);
382 for (currIdx = 0; currIdx < FS_STATS_NUM_RPC_OPS; currIdx++)
383 PrintOpTiming(currIdx, &(a_detP->rpcOpTimes[currIdx]));
385 for (currIdx = 0; currIdx < FS_STATS_NUM_XFER_OPS; currIdx++)
386 PrintXferTiming(currIdx, &(a_detP->xferOpTimes[currIdx]));
390 /*------------------------------------------------------------------------
394 * Print out the AFS_XSTATSCOLL_FULL_PERF_INFO collection we just
404 * All the info we need is nestled into xstat_fs_Results.
408 *------------------------------------------------------------------------*/
414 static char rn[] = "PrintFullPerfInfo"; /*Routine name */
415 static afs_int32 fullPerfInt32s = (sizeof(struct fs_stats_FullPerfStats) >> 2); /*Correct # int32s to rcv */
416 afs_int32 numInt32s; /*# int32words received */
417 struct fs_stats_FullPerfStats *fullPerfP; /*Ptr to full perf stats */
418 char *printableTime; /*Ptr to printable time
420 time_t probeTime = xstat_fs_Results.probeTime;
422 numInt32s = xstat_fs_Results.data.AFS_CollData_len;
423 if (numInt32s != fullPerfInt32s) {
424 printf("** Data size mismatch in full performance collection!");
425 printf("** Expecting %d, got %d\n", fullPerfInt32s, numInt32s);
429 printableTime = ctime(&probeTime);
430 printableTime[strlen(printableTime) - 1] = '\0';
431 fullPerfP = (struct fs_stats_FullPerfStats *)
432 (xstat_fs_Results.data.AFS_CollData_val);
435 ("AFS_XSTATSCOLL_FULL_PERF_INFO (coll %d) for FS %s\n[Probe %d, %s]\n\n",
436 xstat_fs_Results.collectionNumber, xstat_fs_Results.connP->hostName,
437 xstat_fs_Results.probeNum, printableTime);
439 PrintOverallPerfInfo(&(fullPerfP->overall));
440 PrintDetailedPerfInfo(&(fullPerfP->det));
444 /*------------------------------------------------------------------------
448 * Print out the AFS_XSTATSCOLL_PERF_INFO collection we just
458 * All the info we need is nestled into xstat_fs_Results.
462 *------------------------------------------------------------------------*/
467 static char rn[] = "PrintPerfInfo"; /*Routine name */
468 static afs_int32 perfInt32s = (sizeof(struct afs_PerfStats) >> 2); /*Correct # int32s to rcv */
469 afs_int32 numInt32s; /*# int32words received */
470 struct afs_PerfStats *perfP; /*Ptr to performance stats */
471 char *printableTime; /*Ptr to printable time string */
472 time_t probeTime = xstat_fs_Results.probeTime;
474 numInt32s = xstat_fs_Results.data.AFS_CollData_len;
475 if (numInt32s != perfInt32s) {
476 printf("** Data size mismatch in performance collection!");
477 printf("** Expecting %d, got %d\n", perfInt32s, numInt32s);
481 printableTime = ctime(&probeTime);
482 printableTime[strlen(printableTime) - 1] = '\0';
483 perfP = (struct afs_PerfStats *)
484 (xstat_fs_Results.data.AFS_CollData_val);
486 printf("AFS_XSTATSCOLL_PERF_INFO (coll %d) for FS %s\n[Probe %d, %s]\n\n",
487 xstat_fs_Results.collectionNumber,
488 xstat_fs_Results.connP->hostName, xstat_fs_Results.probeNum,
491 PrintOverallPerfInfo(perfP);
494 static char *CbCounterStrings[] = {
500 "DeleteAllCallBacks",
501 "nFEs", "nCBs", "nblks",
504 "GSS1", "GSS2", "GSS3", "GSS4", "GSS5"
510 int numInt32s = sizeof(CbCounterStrings)/sizeof(char *);
512 afs_uint32 *val=xstat_fs_Results.data.AFS_CollData_val;
514 if (numInt32s > xstat_fs_Results.data.AFS_CollData_len)
515 numInt32s = xstat_fs_Results.data.AFS_CollData_len;
517 for (i=0; i<numInt32s; i++) {
518 printf("\t%10u %s\n", val[i], CbCounterStrings[i]);
523 /*------------------------------------------------------------------------
527 * Handler routine passed to the xstat_fs module. This handler is
528 * called immediately after a poll of one of the File Servers has
529 * taken place. All it needs to know is exported by the xstat_fs
530 * module, namely the data structure where the probe results are
541 * See above. All we do now is print out what we got.
545 *------------------------------------------------------------------------*/
550 static char rn[] = "FS_Handler"; /*Routine name */
553 ("\n------------------------------------------------------------\n");
556 * If the probe failed, there isn't much we can do except gripe.
558 if (xstat_fs_Results.probeOK) {
559 printf("%s: Probe %d to File Server '%s' failed, code=%d\n", rn,
560 xstat_fs_Results.probeNum, xstat_fs_Results.connP->hostName,
561 xstat_fs_Results.probeOK);
565 switch (xstat_fs_Results.collectionNumber) {
566 case AFS_XSTATSCOLL_CALL_INFO:
570 case AFS_XSTATSCOLL_PERF_INFO:
574 case AFS_XSTATSCOLL_FULL_PERF_INFO:
578 case AFS_XSTATSCOLL_CBSTATS:
583 printf("** Unknown collection: %d\n",
584 xstat_fs_Results.collectionNumber);
588 * Return the happy news.
594 /*------------------------------------------------------------------------
598 * Given a pointer to the list of File Servers we'll be polling
599 * (or, in fact, any list at all), compute the length of the list.
602 * struct cmd_item *a_firstItem : Ptr to first item in list.
605 * Length of the above list.
608 * Nothing interesting.
612 *------------------------------------------------------------------------*/
615 CountListItems(struct cmd_item *a_firstItem)
618 int list_len; /*List length */
619 struct cmd_item *curr_item; /*Ptr to current item */
622 curr_item = a_firstItem;
629 curr_item = curr_item->next;
639 /*------------------------------------------------------------------------
643 * Routine called by the command line interpreter to execute the
644 * meat of the program. We count the number of File Servers
645 * to watch, allocate enough space to remember all the connection
646 * info for them, then go for it.
650 * a_s : Ptr to the command line syntax descriptor.
653 * 0, but may exit the whole program on an error!
656 * Nothing interesting.
660 *------------------------------------------------------------------------*/
663 RunTheTest(struct cmd_syndesc *a_s)
665 static char rn[] = "RunTheTest"; /*Routine name */
666 int code; /*Return code */
667 int numFSs; /*# File Servers to monitor */
668 int numCollIDs; /*# collections to fetch */
669 int currFS; /*Loop index */
670 int currCollIDIdx; /*Index of current collection ID */
671 afs_int32 *collIDP; /*Ptr to array of collection IDs */
672 afs_int32 *currCollIDP; /*Ptr to current collection ID */
673 struct cmd_item *curr_item; /*Current FS cmd line record */
674 struct sockaddr_in FSSktArray[20]; /*File Server socket array - FIX! */
675 struct hostent *he; /*Host entry */
676 struct timeval tv; /*Time structure */
677 int sleep_secs; /*Number of seconds to sleep */
678 int initFlags; /*Flags passed to the init fcn */
679 int waitCode; /*Result of LWP_WaitProcess() */
680 int freq; /*Frequency of polls */
681 int period; /*Time in minutes of data collection */
684 * Are we doing one-shot measurements?
686 if (a_s->parms[P_ONESHOT].items != 0)
690 * Are we doing debugging output?
692 if (a_s->parms[P_DEBUG].items != 0)
696 * Pull out the number of File Servers to watch and the number of
697 * collections to get.
699 numFSs = CountListItems(a_s->parms[P_FS_NAMES].items);
700 numCollIDs = CountListItems(a_s->parms[P_COLL_IDS].items);
702 /* Get the polling frequency */
703 if (a_s->parms[P_FREQUENCY].items != 0)
704 freq = atoi(a_s->parms[P_FREQUENCY].items->data);
706 freq = 30; /* default to 30 seconds */
708 /* Get the time duration to run the tests */
709 if (a_s->parms[P_PERIOD].items != 0)
710 period = atoi(a_s->parms[P_PERIOD].items->data);
712 period = 10; /* default to 10 minutes */
716 * Fill in the socket array for each of the File Servers listed.
718 curr_item = a_s->parms[P_FS_NAMES].items;
719 for (currFS = 0; currFS < numFSs; currFS++) {
720 #if defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
721 FSSktArray[currFS].sin_family = AF_INET; /*Internet family */
723 FSSktArray[currFS].sin_family = htons(AF_INET); /*Internet family */
725 FSSktArray[currFS].sin_port = htons(7000); /*FileServer port */
726 he = hostutil_GetHostByName(curr_item->data);
728 fprintf(stderr, "[%s] Can't get host info for '%s'\n", rn,
732 memcpy(&(FSSktArray[currFS].sin_addr.s_addr), he->h_addr, 4);
735 * Move to the next File Server name.
737 curr_item = curr_item->next;
739 } /*Get socket info for each File Server */
742 * Create and fill up the array of desired collection IDs.
745 printf("Allocating %d long(s) for coll ID\n", numCollIDs);
746 collIDP = (afs_int32 *) (malloc(numCollIDs * sizeof(afs_int32)));
747 currCollIDP = collIDP;
748 curr_item = a_s->parms[P_COLL_IDS].items;
749 for (currCollIDIdx = 0; currCollIDIdx < numCollIDs; currCollIDIdx++) {
750 *currCollIDP = (afs_int32) (atoi(curr_item->data));
752 printf("CollID at index %d is %d\n", currCollIDIdx, *currCollIDP);
753 curr_item = curr_item->next;
758 * Crank up the File Server prober, then sit back and have fun.
760 printf("\nStarting up the xstat_fs service, ");
763 initFlags |= XSTAT_FS_INITFLAG_DEBUGGING;
764 printf("debugging enabled, ");
766 printf("no debugging, ");
768 initFlags |= XSTAT_FS_INITFLAG_ONE_SHOT;
769 printf("one-shot operation\n");
771 printf("continuous operation\n");
773 code = xstat_fs_Init(numFSs, /*Num servers */
774 FSSktArray, /*File Server socket array */
775 freq, /*Probe frequency */
776 FS_Handler, /*Handler routine */
777 initFlags, /*Initialization flags */
778 numCollIDs, /*Number of collection IDs */
779 collIDP); /*Ptr to collection ID array */
781 fprintf(stderr, "[%s] Error returned by xstat_fs_Init: %d\n", rn,
783 xstat_fs_Cleanup(1); /*Get rid of malloc'ed structures */
789 * One-shot operation; just wait for the collection to be done.
792 printf("[%s] Calling LWP_WaitProcess() on event 0x%x\n", rn,
794 waitCode = LWP_WaitProcess(&terminationEvent);
796 printf("[%s] Returned from LWP_WaitProcess()\n", rn);
800 "[%s] Error %d encountered by LWP_WaitProcess()\n",
805 * Continuous operation.
807 sleep_secs = 60 * period; /*length of data collection */
809 ("xstat_fs service started, main thread sleeping for %d secs.\n",
813 * Let's just fall asleep for a while, then we'll clean up.
815 tv.tv_sec = sleep_secs;
817 code = IOMGR_Select(0, /*Num fds */
818 0, /*Descriptors ready for reading */
819 0, /*Descriptors ready for writing */
820 0, /*Descriptors with exceptional conditions */
821 &tv); /*Timeout structure */
824 "[%s] IOMGR_Select() returned non-zero value: %d\n", rn,
830 * We're all done. Clean up, put the last nail in Rx, then
834 printf("\nYawn, main thread just woke up. Cleaning things out...\n");
836 code = xstat_fs_Cleanup(1); /*Get rid of malloc'ed data */
842 #include "AFS_component_version_number.c"
845 main(int argc, char **argv)
847 static char rn[] = "xstat_fs_test"; /*Routine name */
848 register afs_int32 code; /*Return code */
849 struct cmd_syndesc *ts; /*Ptr to cmd line syntax desc */
852 * Set up the commands we understand.
854 ts = cmd_CreateSyntax("initcmd", RunTheTest, 0, "initialize the program");
855 cmd_AddParm(ts, "-fsname", CMD_LIST, CMD_REQUIRED,
856 "File Server name(s) to monitor");
857 cmd_AddParm(ts, "-collID", CMD_LIST, CMD_REQUIRED,
858 "Collection(s) to fetch");
859 cmd_AddParm(ts, "-onceonly", CMD_FLAG, CMD_OPTIONAL,
860 "Collect results exactly once, then quit");
861 cmd_AddParm(ts, "-frequency", CMD_SINGLE, CMD_OPTIONAL,
862 "poll frequency, in seconds");
863 cmd_AddParm(ts, "-period", CMD_SINGLE, CMD_OPTIONAL,
864 "data collection time, in minutes");
865 cmd_AddParm(ts, "-debug", CMD_FLAG, CMD_OPTIONAL,
866 "turn on debugging output");
869 * Parse command-line switches & execute the test, then get the
872 code = cmd_Dispatch(argc, argv);
874 fprintf(stderr, "[%s] Call to cmd_Dispatch() failed; code is %d\n",