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
11 #define _xstat_cm_h_ 1
13 /*------------------------------------------------------------------------
16 * Interface to the AFS Cache Manager extended statistics facility. With
17 * the routines defined here, the importer can gather extended statistics
18 * from the given group of Cache Managers at regular intervals, or force
19 * immediate collection.
21 *------------------------------------------------------------------------*/
23 #include <sys/types.h> /*Basic system types */
26 #include <netinet/in.h> /*Internet definitions */
31 #include <netdb.h> /*Network database library */
36 #include <sys/socket.h> /*Socket definitions */
38 #endif /* AFS_NT40_ENV */
40 #include <rx/rx.h> /*Rx definitions */
41 #include <afs/afscbint.h> /*AFS CM callback interface */
42 #define FSINT_COMMON_XG /* to allow the inclusion of
43 * xstat_cm.h with this file in an application. */
44 #include <afs/afs_stats.h> /*AFS statistics interface */
47 * ---------------------- Exported definitions ------------------------
50 * Define the initialization flags used within the xstat_fs_Init() call.
51 * XSTAT_CM_INITFLAG_DEBUGGING Turn debugging output on?
52 * XSTAT_CM_INITFLAG_ONE_SHOT Do a one-shot collection?
54 #define XSTAT_CM_INITFLAG_DEBUGGING 0x1
55 #define XSTAT_CM_INITFLAG_ONE_SHOT 0x2
59 * ----------------------- Exported structures ------------------------
62 * Connection information per Cache Manager host being probed.
64 struct xstat_cm_ConnectionInfo {
65 struct sockaddr_in skt; /*Socket info */
66 struct rx_connection *rxconn; /*Rx connection */
67 char hostName[256]; /*Computed hostname */
71 * The results of a probe of one of the Cache Managers in the set being
74 struct xstat_cm_ProbeResults {
75 int probeNum; /*Probe number */
76 afs_int32 probeTime; /*Time probe initiated */
77 struct xstat_cm_ConnectionInfo *connP; /*Connection polled */
78 afs_int32 collectionNumber; /*Collection received */
79 AFSCB_CollData data; /*Ptr to data collected */
80 int probeOK; /*Latest probe successful? */
84 * ------------------- Externally-visible variables -------------------
86 extern int xstat_cm_numServers; /*# connected servers */
87 extern struct xstat_cm_ConnectionInfo
88 *xstat_cm_ConnInfo; /*Ptr to connections */
89 extern int numCollections; /*Num data collections */
90 extern struct xstat_cm_ProbeResults
91 xstat_cm_Results; /*Latest probe results */
92 extern char terminationEvent; /*One-shot termination event */
95 * ------------------------ Exported functions ------------------------
97 extern int xstat_cm_Init(int, struct sockaddr_in *, int,
98 int (*a_ProbeHandler)(void),
99 int, int, afs_int32 *);
102 * Initialize the xstat_cm module: set up Rx connections to the
103 * given set of Cache Managers, start up the probe LWP, and
104 * associate the routine to be called when a probe completes.
105 * Also, let it know which collections you're interested in.
108 * int a_numServers : Num. servers to connect.
109 * struct sockaddr_in *a_socketArray : Array of server sockets.
110 * int a_ProbeFreqInSecs : Probe frequency in seconds.
111 * int (*a_ProbeHandler)() : Ptr to probe handler fcn.
112 * int a_flags : Various flags.
113 * int a_numCollections : Number of collections desired.
114 * afs_int32 *a_collIDP : Ptr to collection IDs.
118 * Error value otherwise.
121 extern int xstat_cm_ForceProbeNow(void);
124 * Force an immediate probe to the connected Cache Managers.
131 * Error value otherwise.
134 extern int xstat_cm_Cleanup(int);
137 * Clean up our memory and connection state.
140 * int a_releaseMem : Should we free up malloc'ed areas?
143 * 0 on total success,
144 * -1 if the module was never initialized, or there was a problem
145 * with the xstat_cm connection array.
148 extern int xstat_cm_Wait(int sleep_secs);
151 * Wait for the collection to complete.
154 * int sleep_secs : time to wait in seconds when running
155 * in continuous mode. 0 means wait forever.
161 #endif /* _xstat_cm_h_ */