back-monitor.h revision 1.1.1.1
1/* back-monitor.h - ldap monitor back-end header file */
2/* $OpenLDAP: pkg/ldap/servers/slapd/back-monitor/back-monitor.h,v 1.52.2.5 2008/02/11 23:26:47 kurt Exp $ */
3/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 *
5 * Copyright 2001-2008 The OpenLDAP Foundation.
6 * Portions Copyright 2001-2003 Pierangelo Masarati.
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted only as authorized by the OpenLDAP
11 * Public License.
12 *
13 * A copy of this license is available in file LICENSE in the
14 * top-level directory of the distribution or, alternatively, at
15 * <http://www.OpenLDAP.org/license.html>.
16 */
17/* ACKNOWLEDGEMENTS:
18 * This work was initially developed by Pierangelo Masarati for inclusion
19 * in OpenLDAP Software.
20 */
21
22#ifndef _BACK_MONITOR_H_
23#define _BACK_MONITOR_H_
24
25#include <ldap_pvt.h>
26#include <ldap_pvt_thread.h>
27#include <avl.h>
28#include <slap.h>
29
30LDAP_BEGIN_DECL
31
32/* define if si_ad_labeledURI is removed from slap_schema */
33#undef MONITOR_DEFINE_LABELEDURI
34
35typedef struct monitor_callback_t {
36	int				(*mc_update)( Operation *op, SlapReply *rs, Entry *e, void *priv );
37						/* update callback
38						   for user-defined entries */
39	int				(*mc_modify)( Operation *op, SlapReply *rs, Entry *e, void *priv );
40						/* modify callback
41						   for user-defined entries */
42	int				(*mc_free)( Entry *e, void **priv );
43						/* delete callback
44						   for user-defined entries */
45	void				(*mc_dispose)( void **priv );
46						/* dispose callback
47						   to dispose of the callback
48						   private data itself */
49	void				*mc_private;	/* opaque pointer to
50						   private data */
51	struct monitor_callback_t	*mc_next;
52} monitor_callback_t;
53
54
55typedef struct monitor_entry_t {
56	ldap_pvt_thread_mutex_t	mp_mutex;	/* entry mutex */
57	Entry			*mp_next;	/* pointer to next sibling */
58	Entry			*mp_children;	/* pointer to first child */
59	struct monitor_subsys_t	*mp_info;	/* subsystem info */
60#define mp_type		mp_info->mss_type
61	unsigned long		mp_flags;	/* flags */
62
63#define	MONITOR_F_NONE		0x0000U
64#define MONITOR_F_SUB		0x0001U		/* subentry of subsystem */
65#define MONITOR_F_PERSISTENT	0x0010U		/* persistent entry */
66#define MONITOR_F_PERSISTENT_CH	0x0020U		/* subsystem generates
67						   persistent entries */
68#define MONITOR_F_VOLATILE	0x0040U		/* volatile entry */
69#define MONITOR_F_VOLATILE_CH	0x0080U		/* subsystem generates
70						   volatile entries */
71#define MONITOR_F_EXTERNAL	0x0100U		/* externally added - don't free */
72/* NOTE: flags with 0xF0000000U mask are reserved for subsystem internals */
73
74	struct monitor_callback_t	*mp_cb;		/* callback sequence */
75} monitor_entry_t;
76
77struct entry_limbo_t;			/* in init.c */
78
79typedef struct monitor_info_t {
80
81	/*
82	 * Internal data
83	 */
84	Avlnode			*mi_cache;
85	ldap_pvt_thread_mutex_t	mi_cache_mutex;
86
87	/*
88	 * Config parameters
89	 */
90	struct berval		mi_startTime;		/* don't free it! */
91	struct berval		mi_creatorsName;	/* don't free it! */
92	struct berval		mi_ncreatorsName;	/* don't free it! */
93
94	/*
95	 * Specific schema entities
96	 */
97	ObjectClass		*mi_oc_monitor;
98	ObjectClass		*mi_oc_monitorServer;
99	ObjectClass		*mi_oc_monitorContainer;
100	ObjectClass		*mi_oc_monitorCounterObject;
101	ObjectClass		*mi_oc_monitorOperation;
102	ObjectClass		*mi_oc_monitorConnection;
103	ObjectClass		*mi_oc_managedObject;
104	ObjectClass		*mi_oc_monitoredObject;
105
106	AttributeDescription	*mi_ad_monitoredInfo;
107	AttributeDescription	*mi_ad_managedInfo;
108	AttributeDescription	*mi_ad_monitorCounter;
109	AttributeDescription	*mi_ad_monitorOpCompleted;
110	AttributeDescription	*mi_ad_monitorOpInitiated;
111	AttributeDescription	*mi_ad_monitorConnectionNumber;
112	AttributeDescription	*mi_ad_monitorConnectionAuthzDN;
113	AttributeDescription	*mi_ad_monitorConnectionLocalAddress;
114	AttributeDescription	*mi_ad_monitorConnectionPeerAddress;
115	AttributeDescription	*mi_ad_monitorTimestamp;
116	AttributeDescription	*mi_ad_monitorOverlay;
117	AttributeDescription	*mi_ad_monitorConnectionProtocol;
118	AttributeDescription	*mi_ad_monitorConnectionOpsReceived;
119	AttributeDescription	*mi_ad_monitorConnectionOpsExecuting;
120	AttributeDescription	*mi_ad_monitorConnectionOpsPending;
121	AttributeDescription	*mi_ad_monitorConnectionOpsCompleted;
122	AttributeDescription	*mi_ad_monitorConnectionGet;
123	AttributeDescription	*mi_ad_monitorConnectionRead;
124	AttributeDescription	*mi_ad_monitorConnectionWrite;
125	AttributeDescription	*mi_ad_monitorConnectionMask;
126	AttributeDescription	*mi_ad_monitorConnectionListener;
127	AttributeDescription	*mi_ad_monitorConnectionPeerDomain;
128	AttributeDescription	*mi_ad_monitorConnectionStartTime;
129	AttributeDescription	*mi_ad_monitorConnectionActivityTime;
130	AttributeDescription	*mi_ad_monitorIsShadow;
131	AttributeDescription	*mi_ad_monitorUpdateRef;
132	AttributeDescription	*mi_ad_monitorRuntimeConfig;
133
134	/*
135	 * Generic description attribute
136	 */
137	AttributeDescription	*mi_ad_readOnly;
138	AttributeDescription	*mi_ad_restrictedOperation;
139
140	struct entry_limbo_t	*mi_entry_limbo;
141} monitor_info_t;
142
143/*
144 * DNs
145 */
146
147enum {
148	SLAPD_MONITOR_BACKEND = 0,
149	SLAPD_MONITOR_CONN,
150	SLAPD_MONITOR_DATABASE,
151	SLAPD_MONITOR_LISTENER,
152	SLAPD_MONITOR_LOG,
153	SLAPD_MONITOR_OPS,
154	SLAPD_MONITOR_OVERLAY,
155	SLAPD_MONITOR_SASL,
156	SLAPD_MONITOR_SENT,
157	SLAPD_MONITOR_THREAD,
158	SLAPD_MONITOR_TIME,
159	SLAPD_MONITOR_TLS,
160	SLAPD_MONITOR_RWW,
161
162	SLAPD_MONITOR_LAST
163};
164
165#define SLAPD_MONITOR_AT		"cn"
166
167#define SLAPD_MONITOR_BACKEND_NAME	"Backends"
168#define SLAPD_MONITOR_BACKEND_RDN	\
169	SLAPD_MONITOR_AT "=" SLAPD_MONITOR_BACKEND_NAME
170#define SLAPD_MONITOR_BACKEND_DN	\
171	SLAPD_MONITOR_BACKEND_RDN "," SLAPD_MONITOR_DN
172
173#define SLAPD_MONITOR_CONN_NAME		"Connections"
174#define SLAPD_MONITOR_CONN_RDN	\
175	SLAPD_MONITOR_AT "=" SLAPD_MONITOR_CONN_NAME
176#define SLAPD_MONITOR_CONN_DN	\
177	SLAPD_MONITOR_CONN_RDN "," SLAPD_MONITOR_DN
178
179#define SLAPD_MONITOR_DATABASE_NAME	"Databases"
180#define SLAPD_MONITOR_DATABASE_RDN	\
181	SLAPD_MONITOR_AT "=" SLAPD_MONITOR_DATABASE_NAME
182#define SLAPD_MONITOR_DATABASE_DN	\
183	SLAPD_MONITOR_DATABASE_RDN "," SLAPD_MONITOR_DN
184
185#define SLAPD_MONITOR_LISTENER_NAME	"Listeners"
186#define SLAPD_MONITOR_LISTENER_RDN	\
187	SLAPD_MONITOR_AT "=" SLAPD_MONITOR_LISTENER_NAME
188#define SLAPD_MONITOR_LISTENER_DN	\
189	SLAPD_MONITOR_LISTENER_RDN "," SLAPD_MONITOR_DN
190
191#define SLAPD_MONITOR_LOG_NAME		"Log"
192#define SLAPD_MONITOR_LOG_RDN	\
193	SLAPD_MONITOR_AT "=" SLAPD_MONITOR_LOG_NAME
194#define SLAPD_MONITOR_LOG_DN	\
195	SLAPD_MONITOR_LOG_RDN "," SLAPD_MONITOR_DN
196
197#define SLAPD_MONITOR_OPS_NAME		"Operations"
198#define SLAPD_MONITOR_OPS_RDN	\
199	SLAPD_MONITOR_AT "=" SLAPD_MONITOR_OPS_NAME
200#define SLAPD_MONITOR_OPS_DN	\
201	SLAPD_MONITOR_OPS_RDN "," SLAPD_MONITOR_DN
202
203#define SLAPD_MONITOR_OVERLAY_NAME	"Overlays"
204#define SLAPD_MONITOR_OVERLAY_RDN  \
205	SLAPD_MONITOR_AT "=" SLAPD_MONITOR_OVERLAY_NAME
206#define SLAPD_MONITOR_OVERLAY_DN   \
207	SLAPD_MONITOR_OVERLAY_RDN "," SLAPD_MONITOR_DN
208
209#define SLAPD_MONITOR_SASL_NAME		"SASL"
210#define SLAPD_MONITOR_SASL_RDN	\
211	SLAPD_MONITOR_AT "=" SLAPD_MONITOR_SASL_NAME
212#define SLAPD_MONITOR_SASL_DN	\
213	SLAPD_MONITOR_SASL_RDN "," SLAPD_MONITOR_DN
214
215#define SLAPD_MONITOR_SENT_NAME		"Statistics"
216#define SLAPD_MONITOR_SENT_RDN	\
217	SLAPD_MONITOR_AT "=" SLAPD_MONITOR_SENT_NAME
218#define SLAPD_MONITOR_SENT_DN	\
219	SLAPD_MONITOR_SENT_RDN "," SLAPD_MONITOR_DN
220
221#define SLAPD_MONITOR_THREAD_NAME	"Threads"
222#define SLAPD_MONITOR_THREAD_RDN	\
223	SLAPD_MONITOR_AT "=" SLAPD_MONITOR_THREAD_NAME
224#define SLAPD_MONITOR_THREAD_DN	\
225	SLAPD_MONITOR_THREAD_RDN "," SLAPD_MONITOR_DN
226
227#define SLAPD_MONITOR_TIME_NAME		"Time"
228#define SLAPD_MONITOR_TIME_RDN  \
229	SLAPD_MONITOR_AT "=" SLAPD_MONITOR_TIME_NAME
230#define SLAPD_MONITOR_TIME_DN   \
231	SLAPD_MONITOR_TIME_RDN "," SLAPD_MONITOR_DN
232
233#define SLAPD_MONITOR_TLS_NAME		"TLS"
234#define SLAPD_MONITOR_TLS_RDN	\
235	SLAPD_MONITOR_AT "=" SLAPD_MONITOR_TLS_NAME
236#define SLAPD_MONITOR_TLS_DN	\
237	SLAPD_MONITOR_TLS_RDN "," SLAPD_MONITOR_DN
238
239#define SLAPD_MONITOR_RWW_NAME		"Waiters"
240#define SLAPD_MONITOR_RWW_RDN	\
241	SLAPD_MONITOR_AT "=" SLAPD_MONITOR_RWW_NAME
242#define SLAPD_MONITOR_RWW_DN	\
243	SLAPD_MONITOR_RWW_RDN "," SLAPD_MONITOR_DN
244
245typedef struct monitor_subsys_t {
246	char		*mss_name;
247	struct berval	mss_rdn;
248	struct berval	mss_dn;
249	struct berval	mss_ndn;
250	struct berval	mss_desc[ 3 ];
251	int		mss_flags;
252#define MONITOR_F_OPENED	0x10000000U
253
254#define MONITOR_HAS_VOLATILE_CH( mp ) \
255	( ( mp )->mp_flags & MONITOR_F_VOLATILE_CH )
256#define MONITOR_HAS_CHILDREN( mp ) \
257	( ( mp )->mp_children || MONITOR_HAS_VOLATILE_CH( mp ) )
258
259	/* initialize entry and subentries */
260	int		( *mss_open )( BackendDB *, struct monitor_subsys_t *ms );
261	/* destroy structure */
262	int		( *mss_destroy )( BackendDB *, struct monitor_subsys_t *ms );
263	/* update existing dynamic entry and subentries */
264	int		( *mss_update )( Operation *, SlapReply *, Entry * );
265	/* create new dynamic subentries */
266	int		( *mss_create )( Operation *, SlapReply *,
267				struct berval *ndn, Entry *, Entry ** );
268	/* modify entry and subentries */
269	int		( *mss_modify )( Operation *, SlapReply *, Entry * );
270} monitor_subsys_t;
271
272extern BackendDB *be_monitor;
273
274/* increase this bufsize if entries in string form get too big */
275#define BACKMONITOR_BUFSIZE	8192
276
277typedef int (monitor_cbfunc)( struct berval *ndn, monitor_callback_t *cb,
278	struct berval *base, int scope, struct berval *filter );
279
280typedef int (monitor_cbafunc)( struct berval *ndn, Attribute *a,
281	monitor_callback_t *cb,
282	struct berval *base, int scope, struct berval *filter );
283
284typedef struct monitor_extra_t {
285	int (*is_configured)(void);
286	monitor_subsys_t * (*get_subsys)( const char *name );
287	monitor_subsys_t * (*get_subsys_by_dn)( struct berval *ndn, int sub );
288
289	int (*register_subsys)( monitor_subsys_t *ms );
290	int (*register_backend)( BackendInfo *bi );
291	int (*register_database)( BackendDB *be, struct berval *ndn );
292	int (*register_overlay_info)( slap_overinst *on );
293	int (*register_overlay)( BackendDB *be );
294	int (*register_entry)( Entry *e, monitor_callback_t *cb,
295		monitor_subsys_t *ms, unsigned long flags );
296	int (*register_entry_parent)( Entry *e, monitor_callback_t *cb,
297		monitor_subsys_t *ms, unsigned long flags,
298		struct berval *base, int scope, struct berval *filter );
299	monitor_cbafunc *register_entry_attrs;
300	monitor_cbfunc *register_entry_callback;
301
302	int (*unregister_entry)( struct berval *ndn );
303	monitor_cbfunc *unregister_entry_parent;
304	monitor_cbafunc *unregister_entry_attrs;
305	monitor_cbfunc *unregister_entry_callback;
306} monitor_extra_t;
307
308LDAP_END_DECL
309
310#include "proto-back-monitor.h"
311
312#endif /* _back_monitor_h_ */
313
314