backport to buster
[hcoop/debian/openafs.git] / src / xstat / xstat_fs.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_fs_h_
11#define _xstat_fs_h_ 1
12
13/*------------------------------------------------------------------------
14 * xstat_fs.h
15 *
16 * Interface to the AFS File Server extended statistics facility. With
17 * the routines defined here, the importer can gather extended statistics
18 * from the given group of File Servers 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/afsint.h> /*AFS FileServer interface */
42#define FSINT_COMMON_XG /* to allow the inclusion of
43 * xstat_cm.h with this file in an application. */
44#include <afs/fs_stats.h> /*AFS FileServer statistics interface */
45
46
47/*
48 * ---------------------- Exported definitions ------------------------
49 */
50/*
51 * Define the initialization flags used within the xstat_fs_Init() call.
52 * XSTAT_FS_INITFLAG_DEBUGGING Turn debugging output on?
53 * XSTAT_FS_INITFLAG_ONE_SHOT Do a one-shot collection?
54 */
55#define XSTAT_FS_INITFLAG_DEBUGGING 0x1
56#define XSTAT_FS_INITFLAG_ONE_SHOT 0x2
57
58
59/*
60 * ----------------------- Exported structures ------------------------
61 */
62/*
63 * Connection information per File Server host being probed.
64 */
65struct xstat_fs_ConnectionInfo {
66 struct sockaddr_in skt; /*Socket info */
67 struct rx_connection *rxconn; /*Rx connection */
68 char hostName[256]; /*Computed hostname */
69};
70
71/*
72 * The results of a probe of one of the File Servers in the set being
73 * watched.
74 */
75struct xstat_fs_ProbeResults {
76 int probeNum; /*Probe number */
77 afs_int32 probeTime; /*Time probe initiated */
78 struct xstat_fs_ConnectionInfo *connP; /*Connection polled */
79 afs_int32 collectionNumber; /*Collection received */
80 AFS_CollData data; /*Ptr to data collected */
81 int probeOK; /*Latest probe successful? */
82};
83
84/*
85 * ------------------- Externally-visible variables -------------------
86 */
87extern int xstat_fs_numServers; /*# connected servers */
88extern struct xstat_fs_ConnectionInfo
89 *xstat_fs_ConnInfo; /*Ptr to connections */
90extern int numCollections; /*Num data collections */
91extern struct xstat_fs_ProbeResults
92 xstat_fs_Results; /*Latest probe results */
93extern char terminationEvent; /*One-shot termination event */
94
95/*
96 * ------------------------ Exported functions ------------------------
97 */
98extern int xstat_fs_Init(int, struct sockaddr_in *, int, int (*)(void),
99 int, int, afs_int32 *);
100 /*
101 * Summary:
102 * Initialize the xstat_fs module: set up Rx connections to the
103 * given set of File Servers, start up the probe and callback LWPs,
104 * and 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)(void) : 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_fs_ForceProbeNow(void);
122 /*
123 * Summary:
124 * Force an immediate probe to the connected File Servers.
125 *
126 * Args:
127 * None.
128 *
129 * Returns:
130 * 0 on success,
131 * Error value otherwise.
132 */
133
134extern int xstat_fs_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_fs connection array.
146 */
147
148/*
149 * Decode the full performance statistics collection data.
150 */
151extern int xstat_fs_DecodeFullPerfStats(struct fs_stats_FullPerfStats **stats,
152 afs_int32 * ain, afs_int32 alen,
153 struct fs_stats_FullPerfStats
154 *buffer);
155
156#endif /* _xstat_fs_h_ */