reindent-20030715
[openafs.git] / src / xstat / xstat_cm.h
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
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
8  */
9
10 #ifndef _xstat_cm_h_
11 #define _xstat_cm_h_  1
12
13 /*------------------------------------------------------------------------
14  * xstat_cm.h
15  *
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.
20  *
21  *------------------------------------------------------------------------*/
22
23 #include <sys/types.h>          /*Basic system types */
24 #ifndef IPPROTO_IP
25 #include <netinet/in.h>         /*Internet definitions */
26 #endif
27
28 #ifndef _netdb_h_
29 #define _netdb_h_
30 #include <netdb.h>              /*Network database library */
31 #endif
32
33 #ifndef _socket_h_
34 #define _socket_h_
35 #include <sys/socket.h>         /*Socket definitions */
36 #endif
37
38 #include <rx/rx.h>              /*Rx definitions */
39 #include <afs/afscbint.h>       /*AFS CM callback interface */
40 #define FSINT_COMMON_XG         /* to allow the inclusion of
41                                  * xstat_cm.h with this file in an application. */
42 #include <afs/afs_stats.h>      /*AFS statistics interface */
43
44 /*
45  * ---------------------- Exported definitions ------------------------
46  */
47 /*
48  * Define the initialization flags used within the xstat_fs_Init() call.
49  *      XSTAT_CM_INITFLAG_DEBUGGING     Turn debugging output on?
50  *      XSTAT_CM_INITFLAG_ONE_SHOT      Do a one-shot collection?
51  */
52 #define XSTAT_CM_INITFLAG_DEBUGGING     0x1
53 #define XSTAT_CM_INITFLAG_ONE_SHOT      0x2
54
55
56 /*
57  * ----------------------- Exported structures ------------------------
58  */
59 /*
60  * Connection information per Cache Manager host being probed.
61  */
62 struct xstat_cm_ConnectionInfo {
63     struct sockaddr_in skt;     /*Socket info */
64     struct rx_connection *rxconn;       /*Rx connection */
65     char hostName[256];         /*Computed hostname */
66 };
67
68 /*
69  * The results of a probe of one of the Cache Managers in the set being
70  * watched.
71  */
72 struct xstat_cm_ProbeResults {
73     int probeNum;               /*Probe number */
74     afs_int32 probeTime;        /*Time probe initiated */
75     struct xstat_cm_ConnectionInfo *connP;      /*Connection polled */
76     afs_int32 collectionNumber; /*Collection received */
77     AFSCB_CollData data;        /*Ptr to data collected */
78     int probeOK;                /*Latest probe successful? */
79 };
80
81 /*
82  * ------------------- Externally-visible variables -------------------
83  */
84 extern int xstat_cm_numServers; /*# connected servers */
85 extern struct xstat_cm_ConnectionInfo
86  *xstat_cm_ConnInfo;            /*Ptr to connections */
87 extern int numCollections;      /*Num data collections */
88 extern struct xstat_cm_ProbeResults
89   xstat_cm_Results;             /*Latest probe results */
90 extern char terminationEvent;   /*One-shot termination event */
91
92 /*
93  * ------------------------ Exported functions ------------------------
94  */
95 extern int xstat_cm_Init();
96     /*
97      * Summary:
98      *    Initialize the xstat_cm module: set up Rx connections to the
99      *    given set of Cache Managers, start up the probe LWP, and
100      *    associate the routine to be called when a probe completes.
101      *    Also, let it know which collections you're interested in.
102      *
103      * Args:
104      *    int a_numServers                  : Num. servers to connect.
105      *    struct sockaddr_in *a_socketArray : Array of server sockets.
106      *    int a_ProbeFreqInSecs             : Probe frequency in seconds.
107      *    int (*a_ProbeHandler)()           : Ptr to probe handler fcn.
108      *    int a_flags                       : Various flags.
109      *    int a_numCollections              : Number of collections desired.
110      *    afs_int32 *a_collIDP              : Ptr to collection IDs.
111      *
112      * Returns:
113      *    0 on success,
114      *    Error value otherwise.
115      */
116
117 extern int xstat_cm_ForceProbeNow();
118     /*
119      * Summary:
120      *    Force an immediate probe to the connected Cache Managers.
121      *
122      * Args:
123      *    None.
124      *
125      * Returns:
126      *    0 on success,
127      *    Error value otherwise.
128      */
129
130 extern int xstat_cm_Cleanup();
131     /*
132      * Summary:
133      *    Clean up our memory and connection state.
134      *
135      * Args:
136      *    int a_releaseMem : Should we free up malloc'ed areas?
137      *
138      * Returns:
139      *    0 on total success,
140      *    -1 if the module was never initialized, or there was a problem
141      *          with the xstat_cm connection array.
142      */
143
144 #endif /* _xstat_cm_h_ */