]> git.sur5r.net Git - openldap/blob - servers/slapd/back-monitor/back-monitor.h
notices
[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 1998-2003 The OpenLDAP Foundation.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted only as authorized by the OpenLDAP
10  * Public License.
11  *
12  * A copy of this license is available in file LICENSE in the
13  * top-level directory of the distribution or, alternatively, at
14  * <http://www.OpenLDAP.org/license.html>.
15  */
16 /* ACKNOWLEDGEMENTS:
17  * This work was initially developed by Pierangelo Masarati for inclusion
18  * in OpenLDAP Software.
19  */
20 /* This is an altered version */
21 /*
22  * Copyright 2001, Pierangelo Masarati, All rights reserved. <ando@sys-net.it>
23  * 
24  * This work has beed deveolped for the OpenLDAP Foundation 
25  * in the hope that it may be useful to the Open Source community, 
26  * but WITHOUT ANY WARRANTY.
27  * 
28  * Permission is granted to anyone to use this software for any purpose
29  * on any computer system, and to alter it and redistribute it, subject
30  * to the following restrictions:
31  * 
32  * 1. The author and SysNet s.n.c. are not responsible for the consequences
33  *    of use of this software, no matter how awful, even if they arise from
34  *    flaws in it.
35  * 
36  * 2. The origin of this software must not be misrepresented, either by
37  *    explicit claim or by omission.  Since few users ever read sources,
38  *    credits should appear in the documentation.
39  * 
40  * 3. Altered versions must be plainly marked as such, and must not be
41  *    misrepresented as being the original software.  Since few users
42  *    ever read sources, credits should appear in the documentation.
43  *    SysNet s.n.c. cannot be responsible for the consequences of the
44  *    alterations.
45  * 
46  * 4. This notice may not be removed or altered.
47  */
48
49 #ifndef _BACK_MONITOR_H_
50 #define _BACK_MONITOR_H_
51
52 #include <ldap_pvt.h>
53 #include <ldap_pvt_thread.h>
54 #include <avl.h>
55 #include <slap.h>
56
57 LDAP_BEGIN_DECL
58
59 /*
60  * The cache maps DNs to Entries.
61  * Each entry, on turn, holds the list of its children in the e_private field.
62  * This is used by search operation to perform onelevel and subtree candidate
63  * selection.
64  */
65 struct monitorcache {
66         struct berval           mc_ndn;
67         Entry                   *mc_e;
68 };
69
70 struct monitorentrypriv {
71         ldap_pvt_thread_mutex_t mp_mutex;       /* entry mutex */
72         Entry                   *mp_next;       /* pointer to next sibling */
73         Entry                   *mp_children;   /* pointer to first child */
74         struct monitorsubsys    *mp_info;       /* subsystem info */
75 #define mp_type         mp_info->mss_type
76         int                     mp_flags;       /* flags */
77
78 #define MONITOR_F_NONE          0x00
79 #define MONITOR_F_SUB           0x01            /* subentry of subsystem */
80 #define MONITOR_F_PERSISTENT    0x10            /* persistent entry */
81 #define MONITOR_F_PERSISTENT_CH 0x20            /* subsystem generates 
82                                                    persistent entries */
83 #define MONITOR_F_VOLATILE      0x40            /* volatile entry */
84 #define MONITOR_F_VOLATILE_CH   0x80            /* subsystem generates 
85                                                    volatile entries */
86 };
87
88 struct monitorinfo {
89
90         /*
91          * Internal data
92          */
93         Avlnode                 *mi_cache;
94         ldap_pvt_thread_mutex_t mi_cache_mutex;
95
96         /*
97          * Config parameters
98          */
99         struct berval           mi_l;
100         struct berval           mi_startTime;   /* don't free it */
101
102         /*
103          * Specific schema entities
104          */
105         ObjectClass *mi_oc_monitor;
106         ObjectClass *mi_oc_monitorServer;
107         ObjectClass *mi_oc_monitorContainer;
108         ObjectClass *mi_oc_monitorCounterObject;
109         ObjectClass *mi_oc_monitorOperation;
110         ObjectClass *mi_oc_monitorConnection;
111         ObjectClass *mi_oc_managedObject;
112         ObjectClass *mi_oc_monitoredObject;
113
114         AttributeDescription *mi_ad_monitoredInfo;
115         AttributeDescription *mi_ad_managedInfo;
116         AttributeDescription *mi_ad_monitorCounter;
117         AttributeDescription *mi_ad_monitorOpCompleted;
118         AttributeDescription *mi_ad_monitorOpInitiated;
119         AttributeDescription *mi_ad_monitorConnectionNumber;
120         AttributeDescription *mi_ad_monitorConnectionAuthzDN;
121         AttributeDescription *mi_ad_monitorConnectionLocalAddress;
122         AttributeDescription *mi_ad_monitorConnectionPeerAddress;
123         AttributeDescription *mi_ad_monitorTimestamp;
124
125         /*
126          * Generic description attribute
127          */
128         AttributeDescription *mi_ad_description;
129         AttributeDescription *mi_ad_seeAlso;
130         AttributeDescription *mi_ad_l;
131 };
132
133 /*
134  * DNs
135  */
136 #define SLAPD_MONITOR_LISTENER          0
137 #define SLAPD_MONITOR_LISTENER_NAME     "Listeners"
138 #define SLAPD_MONITOR_LISTENER_RDN      \
139         "cn=" SLAPD_MONITOR_LISTENER_NAME
140 #define SLAPD_MONITOR_LISTENER_DN       \
141         SLAPD_MONITOR_LISTENER_RDN "," SLAPD_MONITOR_DN
142
143 #define SLAPD_MONITOR_DATABASE          1
144 #define SLAPD_MONITOR_DATABASE_NAME     "Databases"
145 #define SLAPD_MONITOR_DATABASE_RDN      \
146         "cn=" SLAPD_MONITOR_DATABASE_NAME
147 #define SLAPD_MONITOR_DATABASE_DN       \
148         SLAPD_MONITOR_DATABASE_RDN "," SLAPD_MONITOR_DN
149
150 #define SLAPD_MONITOR_BACKEND           2
151 #define SLAPD_MONITOR_BACKEND_NAME      "Backends"
152 #define SLAPD_MONITOR_BACKEND_RDN       \
153         "cn=" SLAPD_MONITOR_BACKEND_NAME
154 #define SLAPD_MONITOR_BACKEND_DN        \
155         SLAPD_MONITOR_BACKEND_RDN "," SLAPD_MONITOR_DN
156
157 #define SLAPD_MONITOR_THREAD            3
158 #define SLAPD_MONITOR_THREAD_NAME       "Threads"
159 #define SLAPD_MONITOR_THREAD_RDN        \
160         "cn=" SLAPD_MONITOR_THREAD_NAME
161 #define SLAPD_MONITOR_THREAD_DN \
162         SLAPD_MONITOR_THREAD_RDN "," SLAPD_MONITOR_DN
163
164 #define SLAPD_MONITOR_SASL              4
165 #define SLAPD_MONITOR_SASL_NAME         "SASL"
166 #define SLAPD_MONITOR_SASL_RDN  \
167         "cn=" SLAPD_MONITOR_SASL_NAME
168 #define SLAPD_MONITOR_SASL_DN   \
169         SLAPD_MONITOR_SASL_RDN "," SLAPD_MONITOR_DN
170
171 #define SLAPD_MONITOR_TLS               5
172 #define SLAPD_MONITOR_TLS_NAME          "TLS"
173 #define SLAPD_MONITOR_TLS_RDN   \
174         "cn=" SLAPD_MONITOR_TLS_NAME
175 #define SLAPD_MONITOR_TLS_DN    \
176         SLAPD_MONITOR_TLS_RDN "," SLAPD_MONITOR_DN
177
178 #define SLAPD_MONITOR_CONN              6
179 #define SLAPD_MONITOR_CONN_NAME         "Connections"
180 #define SLAPD_MONITOR_CONN_RDN  \
181         "cn=" SLAPD_MONITOR_CONN_NAME
182 #define SLAPD_MONITOR_CONN_DN   \
183         SLAPD_MONITOR_CONN_RDN "," SLAPD_MONITOR_DN
184
185 #define SLAPD_MONITOR_RWW               7
186 #define SLAPD_MONITOR_RWW_NAME  "Waiters"
187 #define SLAPD_MONITOR_RWW_RDN   \
188         "cn=" SLAPD_MONITOR_RWW_NAME
189 #define SLAPD_MONITOR_RWW_DN    \
190         SLAPD_MONITOR_RWW_RDN "," SLAPD_MONITOR_DN
191
192 #define SLAPD_MONITOR_LOG               8
193 #define SLAPD_MONITOR_LOG_NAME          "Log"
194 #define SLAPD_MONITOR_LOG_RDN   \
195         "cn=" SLAPD_MONITOR_LOG_NAME
196 #define SLAPD_MONITOR_LOG_DN    \
197         SLAPD_MONITOR_LOG_RDN "," SLAPD_MONITOR_DN
198
199 #define SLAPD_MONITOR_OPS               9
200 #define SLAPD_MONITOR_OPS_NAME          "Operations"
201 #define SLAPD_MONITOR_OPS_RDN   \
202         "cn=" SLAPD_MONITOR_OPS_NAME
203 #define SLAPD_MONITOR_OPS_DN    \
204         SLAPD_MONITOR_OPS_RDN "," SLAPD_MONITOR_DN
205
206 #define SLAPD_MONITOR_SENT              10
207 #define SLAPD_MONITOR_SENT_NAME         "Statistics"
208 #define SLAPD_MONITOR_SENT_RDN  \
209         "cn=" SLAPD_MONITOR_SENT_NAME
210 #define SLAPD_MONITOR_SENT_DN   \
211         SLAPD_MONITOR_SENT_RDN "," SLAPD_MONITOR_DN
212
213 #define SLAPD_MONITOR_TIME              11
214 #define SLAPD_MONITOR_TIME_NAME         "Time"
215 #define SLAPD_MONITOR_TIME_RDN  \
216         "cn=" SLAPD_MONITOR_TIME_NAME
217 #define SLAPD_MONITOR_TIME_DN   \
218         SLAPD_MONITOR_TIME_RDN "," SLAPD_MONITOR_DN
219
220 struct monitorsubsys {
221         int             mss_type;
222         char            *mss_name;
223         struct berval   mss_rdn;
224         struct berval   mss_dn;
225         struct berval   mss_ndn;
226         int             mss_flags;
227
228 #define MONITOR_HAS_VOLATILE_CH( mp ) \
229         ( ( mp )->mp_flags & MONITOR_F_VOLATILE_CH )
230 #define MONITOR_HAS_CHILDREN( mp ) \
231         ( ( mp )->mp_children || MONITOR_HAS_VOLATILE_CH( mp ) )
232
233         /* initialize entry and subentries */
234         int             ( *mss_init )( BackendDB * );
235         /* update existing dynamic entry and subentries */
236         int             ( *mss_update )( Operation *, Entry * );
237         /* create new dynamic subentries */
238         int             ( *mss_create )( Operation *,
239                                 struct berval *ndn, Entry *, Entry ** );
240         /* modify entry and subentries */
241         int             ( *mss_modify )( Operation *, Entry * );
242 };
243
244 extern struct monitorsubsys monitor_subsys[];
245
246 extern BackendDB *be_monitor;
247
248 /* increase this bufsize if entries in string form get too big */
249 #define BACKMONITOR_BUFSIZE     1024
250
251 /*
252  * cache
253  */
254
255 extern int monitor_cache_cmp LDAP_P(( const void *c1, const void *c2 ));
256 extern int monitor_cache_dup LDAP_P(( void *c1, void *c2 ));
257 extern int monitor_cache_add LDAP_P(( struct monitorinfo *mi, Entry *e ));
258 extern int monitor_cache_get LDAP_P(( struct monitorinfo *mi, struct berval *ndn, Entry **ep ));
259 extern int monitor_cache_dn2entry LDAP_P(( Operation *op, struct berval *ndn, Entry **ep, Entry **matched ));
260 extern int monitor_cache_lock LDAP_P(( Entry *e ));
261 extern int monitor_cache_release LDAP_P(( struct monitorinfo *mi, Entry *e ));
262
263 /*
264  * update
265  */
266
267 extern int monitor_entry_update LDAP_P(( Operation *op, Entry *e ));
268 extern int monitor_entry_create LDAP_P(( Operation *op, struct berval *ndn,
269                 Entry *e_parent, Entry **ep ));
270 extern int monitor_entry_modify LDAP_P(( Operation *op, Entry *e ));
271
272 LDAP_END_DECL
273
274 #include "proto-back-monitor.h"
275
276 #endif /* _back_monitor_h_ */
277