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 fsprobe module.
14 *------------------------------------------------------------------------*/
16 #include <afsconfig.h>
17 #include <afs/param.h>
29 #include <fsprobe.h> /*Interface for fsprobe module*/
32 * External routines that don't have explicit include file definitions.
34 extern struct hostent *hostutil_GetHostByName();
36 /*------------------------------------------------------------------------
40 * Handler routine passed to the fsprobe module. This handler is
41 * called immediately after a poll of all the FileServers has taken
42 * place. All it needs to know is exported by the fsprobe module,
43 * namely the data structure where the probe results are stored.
53 * See above. All we do now is print out what we got.
57 *------------------------------------------------------------------------*/
63 static char rn[] = "FS_Handler"; /*Routine name*/
64 struct ProbeViceStatistics *curr_stats;/*Ptr to current stats*/
65 int curr_srvidx, i; /*Current server index*/
66 int *curr_probeOK; /*Ptr to current probeOK value*/
68 printf("[%s] Called; results of poll %d are:\n", rn, fsprobe_Results.probeNum);
69 curr_stats = fsprobe_Results.stats;
70 curr_probeOK = fsprobe_Results.probeOK;
72 for (curr_srvidx = 0; curr_srvidx < 3; curr_srvidx++) {
73 printf("\nServer %s:\n", (fsprobe_ConnInfo+curr_srvidx)->hostName);
74 printf("\tValue of probeOK for this server: %d\n", *curr_probeOK);
75 printf("\tCurrentMsgNumber:\t%d\n", curr_stats->CurrentMsgNumber);
76 printf("\tOldestMsgNumber:\t%d\n", curr_stats->OldestMsgNumber);
77 printf("\tCurrentTime:\t%d\n", curr_stats->CurrentTime);
78 printf("\tBootTime:\t%d\n", curr_stats->BootTime);
79 printf("\tStartTime:\t%d\n", curr_stats->StartTime);
80 printf("\tCurrentConnections:\t%d\n", curr_stats->CurrentConnections);
81 printf("\tTotalViceCalls:\t%d\n", curr_stats->TotalViceCalls);
82 printf("\tTotalFetchs:\t%d\n", curr_stats->TotalFetchs);
83 printf("\tFetchDatas:\t%d\n", curr_stats->FetchDatas);
84 printf("\tFetchedBytes:\t%d\n", curr_stats->FetchedBytes);
85 printf("\tFetchDataRate:\t%d\n", curr_stats->FetchDataRate);
86 printf("\tTotalStores:\t%d\n", curr_stats->TotalStores);
87 printf("\tStoreDatas:\t%d\n", curr_stats->StoreDatas);
88 printf("\tStoredBytes:\t%d\n", curr_stats->StoredBytes);
89 printf("\tStoreDataRate:\t%d\n", curr_stats->StoreDataRate);
90 printf("\tTotalRPCBytesSent:\t%d\n", curr_stats->TotalRPCBytesSent);
91 printf("\tTotalRPCBytesReceived:\t%d\n", curr_stats->TotalRPCBytesReceived);
92 printf("\tTotalRPCPacketsSent:\t%d\n", curr_stats->TotalRPCPacketsSent);
93 printf("\tTotalRPCPacketsReceived:\t%d\n", curr_stats->TotalRPCPacketsReceived);
94 printf("\tTotalRPCPacketsLost:\t%d\n", curr_stats->TotalRPCPacketsLost);
95 printf("\tTotalRPCBogusPackets:\t%d\n", curr_stats->TotalRPCBogusPackets);
96 printf("\tSystemCPU:\t%d\n", curr_stats->SystemCPU);
97 printf("\tUserCPU:\t%d\n", curr_stats->UserCPU);
98 printf("\tNiceCPU:\t%d\n", curr_stats->NiceCPU);
99 printf("\tIdleCPU:\t%d\n", curr_stats->IdleCPU);
100 printf("\tTotalIO:\t%d\n", curr_stats->TotalIO);
101 printf("\tActiveVM:\t%d\n", curr_stats->ActiveVM);
102 printf("\tTotalVM:\t%d\n", curr_stats->TotalVM);
103 printf("\tEtherNetTotalErrors:\t%d\n", curr_stats->EtherNetTotalErrors);
104 printf("\tEtherNetTotalWrites:\t%d\n", curr_stats->EtherNetTotalWrites);
105 printf("\tEtherNetTotalInterupts:\t%d\n", curr_stats->EtherNetTotalInterupts);
106 printf("\tEtherNetGoodReads:\t%d\n", curr_stats->EtherNetGoodReads);
107 printf("\tEtherNetTotalBytesWritten:\t%d\n", curr_stats->EtherNetTotalBytesWritten);
108 printf("\tEtherNetTotalBytesRead:\t%d\n", curr_stats->EtherNetTotalBytesRead);
109 printf("\tProcessSize:\t%d\n", curr_stats->ProcessSize);
110 printf("\tWorkStations:\t%d\n", curr_stats->WorkStations);
111 printf("\tActiveWorkStations:\t%d\n", curr_stats->ActiveWorkStations);
112 printf("\tSpare1:\t%d\n", curr_stats->Spare1);
113 printf("\tSpare2:\t%d\n", curr_stats->Spare2);
114 printf("\tSpare3:\t%d\n", curr_stats->Spare3);
115 printf("\tSpare4:\t%d\n", curr_stats->Spare4);
116 printf("\tSpare5:\t%d\n", curr_stats->Spare5);
117 printf("\tSpare6:\t%d\n", curr_stats->Spare6);
118 printf("\tSpare7:\t%d\n", curr_stats->Spare7);
119 printf("\tSpare8:\t%d\n", curr_stats->Spare8);
121 for (i=0; i < 26; i++) {
122 printf("\tDisk %d: blocks avail=%d, ttl blocks=%d, name=%s\n",
123 i, curr_stats->Disk[i].BlocksAvailable,
124 curr_stats->Disk[i].TotalBlocks, curr_stats->Disk[i].Name);
127 * Bump out statistics pointer to the next server's region. Ditto
133 } /*For each server*/
136 * Return the happy news.
142 #include "AFS_component_version_number.c"
150 static char rn[] = "fsprobe_test"; /*Routine name*/
151 register afs_int32 code; /*Return code*/
152 struct sockaddr_in FSSktArray[3]; /*Transarc socket array*/
153 struct hostent *he; /*Host entry*/
154 struct timeval tv; /*Time structure*/
155 int sleep_secs; /*Number of seconds to sleep*/
157 printf("\n\nTest of the fsprobe facility.\n\n");
160 * Fill in the socket array for bigbird, vice1, and vice2.
162 FSSktArray[0].sin_family = htons(AF_INET); /*Internet family*/
163 FSSktArray[0].sin_port = htons(7000); /*FileServer port*/
164 he = hostutil_GetHostByName("servername1");
166 fprintf(stderr, "[%s] Can't get host info for servername1\n", rn);
169 memcpy(&(FSSktArray[0].sin_addr.s_addr), he->h_addr, 4);
171 FSSktArray[1].sin_family = htons(AF_INET); /*Internet address family*/
172 FSSktArray[1].sin_port = htons(7000); /*FileServer port*/
173 he = hostutil_GetHostByName("servername2");
175 fprintf(stderr, "[%s] Can't get host info for servername2\n", rn);
178 memcpy(&(FSSktArray[1].sin_addr.s_addr), he->h_addr, 4);
180 FSSktArray[2].sin_family = htons(AF_INET); /*Internet address family*/
181 FSSktArray[2].sin_port = htons(7000); /*FileServer port*/
182 he = hostutil_GetHostByName("servername3");
184 fprintf(stderr, "[%s] Can't get host info for servername3\n", rn);
187 memcpy(&(FSSktArray[2].sin_addr.s_addr), he->h_addr, 4);
189 printf("Sockets for the 3 AFS FileServers to be probed:\n");
190 printf("\t Host servername1: IP addr 0x%lx, port %d\n",
191 FSSktArray[0].sin_addr.s_addr,
192 FSSktArray[0].sin_port);
193 printf("\t Host servername2: IP addr 0x%lx, port %d\n",
194 FSSktArray[1].sin_addr.s_addr,
195 FSSktArray[1].sin_port);
196 printf("\t Host servername3: IP addr 0x%lx, port %d\n",
197 FSSktArray[2].sin_addr.s_addr,
198 FSSktArray[2].sin_port);
201 * Crank up the FileServer prober, then sit back and have fun.
203 printf("Starting up the fsprobe service\n");
204 code = fsprobe_Init(3, /*Num servers*/
205 FSSktArray, /*FileServer socket array*/
206 30, /*Probe every 30 seconds*/
207 FS_Handler, /*Handler routine*/
208 1); /*Turn debugging output on*/
210 fprintf(stderr, "[%s] Error returned by fsprobe_Init: %d\n", rn, code);
211 fsprobe_Cleanup(1); /*Get rid of malloc'ed structures*/
214 sleep_secs = 60*10; /*Allow 10 minutes of data collection*/
215 printf("Fsprobe service started, main thread sleeping for %d seconds...\n", sleep_secs);
218 * Let's just fall asleep for a while, then we'll clean up.
220 tv.tv_sec = sleep_secs;
222 code = IOMGR_Select(0, /*Num fds*/
223 0, /*Descriptors ready for reading*/
224 0, /*Descriptors ready for writing*/
225 0, /*Descriptors with exceptional conditions*/
226 &tv); /*Timeout structure*/
228 fprintf(stderr, "[%s] IOMGR_Select() returned non-zero value: %d\n", rn, code);
232 * We're all done. Clean up, put the last nail in Rx, then
235 printf("Yawn, main thread just woke up. Cleaning things out...\n");
236 code = fsprobe_Cleanup(1); /*Get rid of malloc'ed data*/