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