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