]> git.sur5r.net Git - openldap/blob - servers/slapd/back-monitor/back-monitor.h
add back-config suppor to back-monitor; advertize what backends provide back-config...
[openldap] / servers / slapd / back-monitor / back-monitor.h
1 /* back-monitor.h - ldap monitor back-end header file */
2 /* $OpenLDAP$ */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4  *
5  * Copyright 2001-2005 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
30 LDAP_BEGIN_DECL
31
32 /* define if si_ad_labeledURI is removed from slap_schema */
33 #undef MONITOR_DEFINE_LABELEDURI
34
35 typedef 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                                                 /* update callback
44                                                    for user-defined entries */
45         void                            *mc_private;    /* opaque pointer to
46                                                    private data */
47         struct monitor_callback_t       *mc_next;
48 } monitor_callback_t;
49
50
51 typedef struct monitor_entry_t {
52         ldap_pvt_thread_mutex_t mp_mutex;       /* entry mutex */
53         Entry                   *mp_next;       /* pointer to next sibling */
54         Entry                   *mp_children;   /* pointer to first child */
55         struct monitor_subsys_t *mp_info;       /* subsystem info */
56 #define mp_type         mp_info->mss_type
57         unsigned long           mp_flags;       /* flags */
58
59 #define MONITOR_F_NONE          0x0000U
60 #define MONITOR_F_SUB           0x0001U         /* subentry of subsystem */
61 #define MONITOR_F_PERSISTENT    0x0010U         /* persistent entry */
62 #define MONITOR_F_PERSISTENT_CH 0x0020U         /* subsystem generates 
63                                                    persistent entries */
64 #define MONITOR_F_VOLATILE      0x0040U         /* volatile entry */
65 #define MONITOR_F_VOLATILE_CH   0x0080U         /* subsystem generates 
66                                                    volatile entries */
67 #define MONITOR_F_EXTERNAL      0x0100U         /* externally added - don't free */
68 /* NOTE: flags with 0xF0000000U mask are reserved for subsystem internals */
69
70         struct monitor_callback_t       *mp_cb;         /* callback sequence */
71 } monitor_entry_t;
72
73 typedef struct monitor_info_t {
74
75         /*
76          * Internal data
77          */
78         Avlnode                 *mi_cache;
79         ldap_pvt_thread_mutex_t mi_cache_mutex;
80
81         /*
82          * Config parameters
83          */
84         struct berval           mi_startTime;           /* don't free it! */
85         struct berval           mi_creatorsName;        /* don't free it! */
86
87         /*
88          * Specific schema entities
89          */
90         ObjectClass             *mi_oc_monitor;
91         ObjectClass             *mi_oc_monitorServer;
92         ObjectClass             *mi_oc_monitorContainer;
93         ObjectClass             *mi_oc_monitorCounterObject;
94         ObjectClass             *mi_oc_monitorOperation;
95         ObjectClass             *mi_oc_monitorConnection;
96         ObjectClass             *mi_oc_managedObject;
97         ObjectClass             *mi_oc_monitoredObject;
98
99         AttributeDescription    *mi_ad_monitoredInfo;
100         AttributeDescription    *mi_ad_managedInfo;
101         AttributeDescription    *mi_ad_monitorCounter;
102         AttributeDescription    *mi_ad_monitorOpCompleted;
103         AttributeDescription    *mi_ad_monitorOpInitiated;
104         AttributeDescription    *mi_ad_monitorConnectionNumber;
105         AttributeDescription    *mi_ad_monitorConnectionAuthzDN;
106         AttributeDescription    *mi_ad_monitorConnectionLocalAddress;
107         AttributeDescription    *mi_ad_monitorConnectionPeerAddress;
108         AttributeDescription    *mi_ad_monitorTimestamp;
109         AttributeDescription    *mi_ad_monitorOverlay;
110         AttributeDescription    *mi_ad_monitorConnectionProtocol;
111         AttributeDescription    *mi_ad_monitorConnectionOpsReceived;
112         AttributeDescription    *mi_ad_monitorConnectionOpsExecuting;
113         AttributeDescription    *mi_ad_monitorConnectionOpsPending;
114         AttributeDescription    *mi_ad_monitorConnectionOpsCompleted;
115         AttributeDescription    *mi_ad_monitorConnectionGet;
116         AttributeDescription    *mi_ad_monitorConnectionRead;
117         AttributeDescription    *mi_ad_monitorConnectionWrite;
118         AttributeDescription    *mi_ad_monitorConnectionMask;
119         AttributeDescription    *mi_ad_monitorConnectionListener;
120         AttributeDescription    *mi_ad_monitorConnectionPeerDomain;
121         AttributeDescription    *mi_ad_monitorConnectionStartTime;
122         AttributeDescription    *mi_ad_monitorConnectionActivityTime;
123         AttributeDescription    *mi_ad_monitorIsShadow;
124         AttributeDescription    *mi_ad_monitorUpdateRef;
125         AttributeDescription    *mi_ad_monitorRuntimeConfig;
126
127         /*
128          * Generic description attribute
129          */
130         AttributeDescription    *mi_ad_readOnly;
131         AttributeDescription    *mi_ad_restrictedOperation;
132
133         void                    *mi_entry_limbo;
134 } monitor_info_t;
135
136 /*
137  * DNs
138  */
139
140 enum {
141         SLAPD_MONITOR_BACKEND = 0,
142         SLAPD_MONITOR_CONN,
143         SLAPD_MONITOR_DATABASE,
144         SLAPD_MONITOR_LISTENER,
145         SLAPD_MONITOR_LOG,
146         SLAPD_MONITOR_OPS,
147         SLAPD_MONITOR_OVERLAY,
148         SLAPD_MONITOR_SASL,
149         SLAPD_MONITOR_SENT,
150         SLAPD_MONITOR_THREAD,
151         SLAPD_MONITOR_TIME,
152         SLAPD_MONITOR_TLS,
153         SLAPD_MONITOR_RWW,
154
155         SLAPD_MONITOR_LAST
156 };
157
158 #define SLAPD_MONITOR_AT                "cn"
159
160 #define SLAPD_MONITOR_BACKEND_NAME      "Backends"
161 #define SLAPD_MONITOR_BACKEND_RDN       \
162         SLAPD_MONITOR_AT "=" SLAPD_MONITOR_BACKEND_NAME
163 #define SLAPD_MONITOR_BACKEND_DN        \
164         SLAPD_MONITOR_BACKEND_RDN "," SLAPD_MONITOR_DN
165
166 #define SLAPD_MONITOR_CONN_NAME         "Connections"
167 #define SLAPD_MONITOR_CONN_RDN  \
168         SLAPD_MONITOR_AT "=" SLAPD_MONITOR_CONN_NAME
169 #define SLAPD_MONITOR_CONN_DN   \
170         SLAPD_MONITOR_CONN_RDN "," SLAPD_MONITOR_DN
171
172 #define SLAPD_MONITOR_DATABASE_NAME     "Databases"
173 #define SLAPD_MONITOR_DATABASE_RDN      \
174         SLAPD_MONITOR_AT "=" SLAPD_MONITOR_DATABASE_NAME
175 #define SLAPD_MONITOR_DATABASE_DN       \
176         SLAPD_MONITOR_DATABASE_RDN "," SLAPD_MONITOR_DN
177
178 #define SLAPD_MONITOR_LISTENER_NAME     "Listeners"
179 #define SLAPD_MONITOR_LISTENER_RDN      \
180         SLAPD_MONITOR_AT "=" SLAPD_MONITOR_LISTENER_NAME
181 #define SLAPD_MONITOR_LISTENER_DN       \
182         SLAPD_MONITOR_LISTENER_RDN "," SLAPD_MONITOR_DN
183
184 #define SLAPD_MONITOR_LOG_NAME          "Log"
185 #define SLAPD_MONITOR_LOG_RDN   \
186         SLAPD_MONITOR_AT "=" SLAPD_MONITOR_LOG_NAME
187 #define SLAPD_MONITOR_LOG_DN    \
188         SLAPD_MONITOR_LOG_RDN "," SLAPD_MONITOR_DN
189
190 #define SLAPD_MONITOR_OPS_NAME          "Operations"
191 #define SLAPD_MONITOR_OPS_RDN   \
192         SLAPD_MONITOR_AT "=" SLAPD_MONITOR_OPS_NAME
193 #define SLAPD_MONITOR_OPS_DN    \
194         SLAPD_MONITOR_OPS_RDN "," SLAPD_MONITOR_DN
195
196 #define SLAPD_MONITOR_OVERLAY_NAME      "Overlay"
197 #define SLAPD_MONITOR_OVERLAY_RDN  \
198         SLAPD_MONITOR_AT "=" SLAPD_MONITOR_OVERLAY_NAME
199 #define SLAPD_MONITOR_OVERLAY_DN   \
200         SLAPD_MONITOR_OVERLAY_RDN "," SLAPD_MONITOR_DN
201
202 #define SLAPD_MONITOR_SASL_NAME         "SASL"
203 #define SLAPD_MONITOR_SASL_RDN  \
204         SLAPD_MONITOR_AT "=" SLAPD_MONITOR_SASL_NAME
205 #define SLAPD_MONITOR_SASL_DN   \
206         SLAPD_MONITOR_SASL_RDN "," SLAPD_MONITOR_DN
207
208 #define SLAPD_MONITOR_SENT_NAME         "Statistics"
209 #define SLAPD_MONITOR_SENT_RDN  \
210         SLAPD_MONITOR_AT "=" SLAPD_MONITOR_SENT_NAME
211 #define SLAPD_MONITOR_SENT_DN   \
212         SLAPD_MONITOR_SENT_RDN "," SLAPD_MONITOR_DN
213
214 #define SLAPD_MONITOR_THREAD_NAME       "Threads"
215 #define SLAPD_MONITOR_THREAD_RDN        \
216         SLAPD_MONITOR_AT "=" SLAPD_MONITOR_THREAD_NAME
217 #define SLAPD_MONITOR_THREAD_DN \
218         SLAPD_MONITOR_THREAD_RDN "," SLAPD_MONITOR_DN
219
220 #define SLAPD_MONITOR_TIME_NAME         "Time"
221 #define SLAPD_MONITOR_TIME_RDN  \
222         SLAPD_MONITOR_AT "=" SLAPD_MONITOR_TIME_NAME
223 #define SLAPD_MONITOR_TIME_DN   \
224         SLAPD_MONITOR_TIME_RDN "," SLAPD_MONITOR_DN
225
226 #define SLAPD_MONITOR_TLS_NAME          "TLS"
227 #define SLAPD_MONITOR_TLS_RDN   \
228         SLAPD_MONITOR_AT "=" SLAPD_MONITOR_TLS_NAME
229 #define SLAPD_MONITOR_TLS_DN    \
230         SLAPD_MONITOR_TLS_RDN "," SLAPD_MONITOR_DN
231
232 #define SLAPD_MONITOR_RWW_NAME          "Waiters"
233 #define SLAPD_MONITOR_RWW_RDN   \
234         SLAPD_MONITOR_AT "=" SLAPD_MONITOR_RWW_NAME
235 #define SLAPD_MONITOR_RWW_DN    \
236         SLAPD_MONITOR_RWW_RDN "," SLAPD_MONITOR_DN
237
238 typedef struct monitor_subsys_t {
239         char            *mss_name;
240         struct berval   mss_rdn;
241         struct berval   mss_dn;
242         struct berval   mss_ndn;
243         struct berval   mss_desc[ 3 ];
244         int             mss_flags;
245 #define MONITOR_F_OPENED        0x10000000U
246
247 #define MONITOR_HAS_VOLATILE_CH( mp ) \
248         ( ( mp )->mp_flags & MONITOR_F_VOLATILE_CH )
249 #define MONITOR_HAS_CHILDREN( mp ) \
250         ( ( mp )->mp_children || MONITOR_HAS_VOLATILE_CH( mp ) )
251
252         /* initialize entry and subentries */
253         int             ( *mss_open )( BackendDB *, struct monitor_subsys_t *ms );
254         /* update existing dynamic entry and subentries */
255         int             ( *mss_update )( Operation *, SlapReply *, Entry * );
256         /* create new dynamic subentries */
257         int             ( *mss_create )( Operation *, SlapReply *,
258                                 struct berval *ndn, Entry *, Entry ** );
259         /* modify entry and subentries */
260         int             ( *mss_modify )( Operation *, SlapReply *, Entry * );
261 } monitor_subsys_t;
262
263 extern BackendDB *be_monitor;
264
265 /* increase this bufsize if entries in string form get too big */
266 #define BACKMONITOR_BUFSIZE     8192
267
268 LDAP_END_DECL
269
270 #include "proto-back-monitor.h"
271
272 #endif /* _back_monitor_h_ */
273