]> git.sur5r.net Git - openldap/blob - servers/slapd/back-monitor/back-monitor.h
HEADS-UP: complete reworking of back-monitor
[openldap] / servers / slapd / back-monitor / back-monitor.h
1 /* back-monitor.h - ldap monitor back-end header file */
2 /*
3  * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
4  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
5  */
6 /*
7  * Copyright 2001, Pierangelo Masarati, All rights reserved. <ando@sys-net.it>
8  * 
9  * This work has beed deveolped for the OpenLDAP Foundation 
10  * in the hope that it may be useful to the Open Source community, 
11  * but WITHOUT ANY WARRANTY.
12  * 
13  * Permission is granted to anyone to use this software for any purpose
14  * on any computer system, and to alter it and redistribute it, subject
15  * to the following restrictions:
16  * 
17  * 1. The author and SysNet s.n.c. are not responsible for the consequences
18  *    of use of this software, no matter how awful, even if they arise from
19  *    flaws in it.
20  * 
21  * 2. The origin of this software must not be misrepresented, either by
22  *    explicit claim or by omission.  Since few users ever read sources,
23  *    credits should appear in the documentation.
24  * 
25  * 3. Altered versions must be plainly marked as such, and must not be
26  *    misrepresented as being the original software.  Since few users
27  *    ever read sources, credits should appear in the documentation.
28  *    SysNet s.n.c. cannot be responsible for the consequences of the
29  *    alterations.
30  * 
31  * 4. This notice may not be removed or altered.
32  */
33
34 #ifndef _BACK_MONITOR_H_
35 #define _BACK_MONITOR_H_
36
37 #include <ldap_pvt.h>
38 #include <ldap_pvt_thread.h>
39 #include <avl.h>
40 #include <slap.h>
41
42 LDAP_BEGIN_DECL
43
44 /*
45  * The cache maps DNs to Entries.
46  * Each entry, on turn, holds the list of its children in the e_private field.
47  * This is used by search operation to perform onelevel and subtree candidate
48  * selection.
49  */
50 struct monitorcache {
51         struct berval           mc_ndn;
52         Entry                   *mc_e;
53 };
54
55 struct monitorentrypriv {
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 monitorsubsys    *mp_info;       /* subsystem info */
60 #define mp_type         mp_info->mss_type
61         int                     mp_flags;       /* flags */
62
63 #define MONITOR_F_NONE          0x00
64 #define MONITOR_F_SUB           0x01            /* subentry of subsystem */
65 #define MONITOR_F_PERSISTENT    0x10            /* persistent entry */
66 #define MONITOR_F_PERSISTENT_CH 0x20            /* subsystem generates 
67                                                    persistent entries */
68 #define MONITOR_F_VOLATILE      0x40            /* volatile entry */
69 #define MONITOR_F_VOLATILE_CH   0x80            /* subsystem generates 
70                                                    volatile entries */
71 };
72
73 struct monitorinfo {
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           l;
85
86         /*
87          * Specific schema entities
88          */
89         ObjectClass *oc_monitor;
90         ObjectClass *oc_monitorServer;
91         ObjectClass *oc_monitorContainer;
92         ObjectClass *oc_monitorCounterObject;
93         ObjectClass *oc_monitorOperation;
94         ObjectClass *oc_monitorConnection;
95         ObjectClass *oc_managedObject;
96         ObjectClass *oc_monitoredObject;
97
98         AttributeDescription *ad_monitoredInfo;
99         AttributeDescription *ad_managedInfo;
100         AttributeDescription *ad_monitorCounter;
101         AttributeDescription *ad_monitorOpCompleted;
102         AttributeDescription *ad_monitorOpInitiated;
103         AttributeDescription *ad_monitorConnectionNumber;
104         AttributeDescription *ad_monitorConnectionAuthzDN;
105         AttributeDescription *ad_monitorConnectionLocalAddress;
106         AttributeDescription *ad_monitorConnectionPeerAddress;
107
108         /*
109          * Generic description attribute
110          */
111         AttributeDescription *ad_description;
112         AttributeDescription *ad_seeAlso;
113 };
114
115 /*
116  * DNs
117  */
118 #define SLAPD_MONITOR_LISTENER          0
119 #define SLAPD_MONITOR_LISTENER_NAME     "Listeners"
120 #define SLAPD_MONITOR_LISTENER_RDN      \
121         "cn=" SLAPD_MONITOR_LISTENER_NAME
122 #define SLAPD_MONITOR_LISTENER_DN       \
123         SLAPD_MONITOR_LISTENER_RDN "," SLAPD_MONITOR_DN
124
125 #define SLAPD_MONITOR_DATABASE          1
126 #define SLAPD_MONITOR_DATABASE_NAME     "Databases"
127 #define SLAPD_MONITOR_DATABASE_RDN      \
128         "cn=" SLAPD_MONITOR_DATABASE_NAME
129 #define SLAPD_MONITOR_DATABASE_DN       \
130         SLAPD_MONITOR_DATABASE_RDN "," SLAPD_MONITOR_DN
131
132 #define SLAPD_MONITOR_BACKEND           2
133 #define SLAPD_MONITOR_BACKEND_NAME      "Backends"
134 #define SLAPD_MONITOR_BACKEND_RDN       \
135         "cn=" SLAPD_MONITOR_BACKEND_NAME
136 #define SLAPD_MONITOR_BACKEND_DN        \
137         SLAPD_MONITOR_BACKEND_RDN "," SLAPD_MONITOR_DN
138
139 #define SLAPD_MONITOR_THREAD            3
140 #define SLAPD_MONITOR_THREAD_NAME       "Threads"
141 #define SLAPD_MONITOR_THREAD_RDN        \
142         "cn=" SLAPD_MONITOR_THREAD_NAME
143 #define SLAPD_MONITOR_THREAD_DN \
144         SLAPD_MONITOR_THREAD_RDN "," SLAPD_MONITOR_DN
145
146 #define SLAPD_MONITOR_SASL              4
147 #define SLAPD_MONITOR_SASL_NAME         "SASL"
148 #define SLAPD_MONITOR_SASL_RDN  \
149         "cn=" SLAPD_MONITOR_SASL_NAME
150 #define SLAPD_MONITOR_SASL_DN   \
151         SLAPD_MONITOR_SASL_RDN "," SLAPD_MONITOR_DN
152
153 #define SLAPD_MONITOR_TLS               5
154 #define SLAPD_MONITOR_TLS_NAME          "TLS"
155 #define SLAPD_MONITOR_TLS_RDN   \
156         "cn=" SLAPD_MONITOR_TLS_NAME
157 #define SLAPD_MONITOR_TLS_DN    \
158         SLAPD_MONITOR_TLS_RDN "," SLAPD_MONITOR_DN
159
160 #define SLAPD_MONITOR_CONN              6
161 #define SLAPD_MONITOR_CONN_NAME         "Connections"
162 #define SLAPD_MONITOR_CONN_RDN  \
163         "cn=" SLAPD_MONITOR_CONN_NAME
164 #define SLAPD_MONITOR_CONN_DN   \
165         SLAPD_MONITOR_CONN_RDN "," SLAPD_MONITOR_DN
166
167 #define SLAPD_MONITOR_RWW               7
168 #define SLAPD_MONITOR_RWW_NAME  "Waiters"
169 #define SLAPD_MONITOR_RWW_RDN   \
170         "cn=" SLAPD_MONITOR_RWW_NAME
171 #define SLAPD_MONITOR_RWW_DN    \
172         SLAPD_MONITOR_RWW_RDN "," SLAPD_MONITOR_DN
173
174 #define SLAPD_MONITOR_LOG               8
175 #define SLAPD_MONITOR_LOG_NAME          "Log"
176 #define SLAPD_MONITOR_LOG_RDN   \
177         "cn=" SLAPD_MONITOR_LOG_NAME
178 #define SLAPD_MONITOR_LOG_DN    \
179         SLAPD_MONITOR_LOG_RDN "," SLAPD_MONITOR_DN
180
181 #define SLAPD_MONITOR_OPS               9
182 #define SLAPD_MONITOR_OPS_NAME          "Operations"
183 #define SLAPD_MONITOR_OPS_RDN   \
184         "cn=" SLAPD_MONITOR_OPS_NAME
185 #define SLAPD_MONITOR_OPS_DN    \
186         SLAPD_MONITOR_OPS_RDN "," SLAPD_MONITOR_DN
187
188 #define SLAPD_MONITOR_SENT              10
189 #define SLAPD_MONITOR_SENT_NAME         "Statistics"
190 #define SLAPD_MONITOR_SENT_RDN  \
191         "cn=" SLAPD_MONITOR_SENT_NAME
192 #define SLAPD_MONITOR_SENT_DN   \
193         SLAPD_MONITOR_SENT_RDN "," SLAPD_MONITOR_DN
194
195 #define SLAPD_MONITOR_TIME              11
196 #define SLAPD_MONITOR_TIME_NAME         "Time"
197 #define SLAPD_MONITOR_TIME_RDN  \
198         "cn=" SLAPD_MONITOR_TIME_NAME
199 #define SLAPD_MONITOR_TIME_DN   \
200         SLAPD_MONITOR_TIME_RDN "," SLAPD_MONITOR_DN
201
202 struct monitorsubsys {
203         int             mss_type;
204         char            *mss_name;
205         struct berval   mss_rdn;
206         struct berval   mss_dn;
207         struct berval   mss_ndn;
208         int             mss_flags;
209
210 #define MONITOR_HAS_VOLATILE_CH( mp ) \
211         ( ( mp )->mp_flags & MONITOR_F_VOLATILE_CH )
212 #define MONITOR_HAS_CHILDREN( mp ) \
213         ( ( mp )->mp_children || MONITOR_HAS_VOLATILE_CH( mp ) )
214
215         /* initialize entry and subentries */
216         int             ( *mss_init )( BackendDB * );
217         /* update existing dynamic entry and subentries */
218         int             ( *mss_update )( Operation *, Entry * );
219         /* create new dynamic subentries */
220         int             ( *mss_create )( Operation *,
221                                 struct berval *ndn, Entry *, Entry ** );
222         /* modify entry and subentries */
223         int             ( *mss_modify )( Operation *, Entry * );
224 };
225
226 extern struct monitorsubsys monitor_subsys[];
227
228 extern BackendDB *be_monitor;
229
230 /*
231  * cache
232  */
233
234 extern int monitor_cache_cmp LDAP_P(( const void *c1, const void *c2 ));
235 extern int monitor_cache_dup LDAP_P(( void *c1, void *c2 ));
236 extern int monitor_cache_add LDAP_P(( struct monitorinfo *mi, Entry *e ));
237 extern int monitor_cache_get LDAP_P(( struct monitorinfo *mi, struct berval *ndn, Entry **ep ));
238 extern int monitor_cache_dn2entry LDAP_P(( Operation *op, struct berval *ndn, Entry **ep, Entry **matched ));
239 extern int monitor_cache_lock LDAP_P(( Entry *e ));
240 extern int monitor_cache_release LDAP_P(( struct monitorinfo *mi, Entry *e ));
241
242 /*
243  * update
244  */
245
246 extern int monitor_entry_update LDAP_P(( Operation *op, Entry *e ));
247 extern int monitor_entry_create LDAP_P(( Operation *op, struct berval *ndn,
248                 Entry *e_parent, Entry **ep ));
249 extern int monitor_entry_modify LDAP_P(( Operation *op, Entry *e ));
250
251 LDAP_END_DECL
252
253 #include "proto-back-monitor.h"
254
255 #endif /* _back_monitor_h_ */
256