backport to buster
[hcoop/debian/openafs.git] / src / xstat / xstat_cm.h
CommitLineData
805e021f
CE
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 AFS_NT40_ENV
25#ifndef IPPROTO_IP
26#include <netinet/in.h> /*Internet definitions */
27#endif
28
29#ifndef _netdb_h_
30#define _netdb_h_
31#include <netdb.h> /*Network database library */
32#endif
33
34#ifndef _socket_h_
35#define _socket_h_
36#include <sys/socket.h> /*Socket definitions */
37#endif
38#endif /* AFS_NT40_ENV */
39
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 */
45
46/*
47 * ---------------------- Exported definitions ------------------------
48 */
49/*
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?
53 */
54#define XSTAT_CM_INITFLAG_DEBUGGING 0x1
55#define XSTAT_CM_INITFLAG_ONE_SHOT 0x2
56
57
58/*
59 * ----------------------- Exported structures ------------------------
60 */
61/*
62 * Connection information per Cache Manager host being probed.
63 */
64struct xstat_cm_ConnectionInfo {
65 struct sockaddr_in skt; /*Socket info */
66 struct rx_connection *rxconn; /*Rx connection */
67 char hostName[256]; /*Computed hostname */
68};
69
70/*
71 * The results of a probe of one of the Cache Managers in the set being
72 * watched.
73 */
74struct 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? */
81};
82
83/*
84 * ------------------- Externally-visible variables -------------------
85 */
86extern int xstat_cm_numServers; /*# connected servers */
87extern struct xstat_cm_ConnectionInfo
88 *xstat_cm_ConnInfo; /*Ptr to connections */
89extern int numCollections; /*Num data collections */
90extern struct xstat_cm_ProbeResults
91 xstat_cm_Results; /*Latest probe results */
92extern char terminationEvent; /*One-shot termination event */
93
94/*
95 * ------------------------ Exported functions ------------------------
96 */
97extern int xstat_cm_Init(int, struct sockaddr_in *, int,
98 int (*a_ProbeHandler)(void),
99 int, int, afs_int32 *);
100 /*
101 * Summary:
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.
106 *
107 * Args:
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.
115 *
116 * Returns:
117 * 0 on success,
118 * Error value otherwise.
119 */
120
121extern int xstat_cm_ForceProbeNow(void);
122 /*
123 * Summary:
124 * Force an immediate probe to the connected Cache Managers.
125 *
126 * Args:
127 * None.
128 *
129 * Returns:
130 * 0 on success,
131 * Error value otherwise.
132 */
133
134extern int xstat_cm_Cleanup(int);
135 /*
136 * Summary:
137 * Clean up our memory and connection state.
138 *
139 * Args:
140 * int a_releaseMem : Should we free up malloc'ed areas?
141 *
142 * Returns:
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.
146 */
147
148#endif /* _xstat_cm_h_ */