Back to index

openldap  2.4.31
back-monitor.h
Go to the documentation of this file.
00001 /* back-monitor.h - ldap monitor back-end header file */
00002 /* $OpenLDAP$ */
00003 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
00004  *
00005  * Copyright 2001-2012 The OpenLDAP Foundation.
00006  * Portions Copyright 2001-2003 Pierangelo Masarati.
00007  * All rights reserved.
00008  *
00009  * Redistribution and use in source and binary forms, with or without
00010  * modification, are permitted only as authorized by the OpenLDAP
00011  * Public License.
00012  *
00013  * A copy of this license is available in file LICENSE in the
00014  * top-level directory of the distribution or, alternatively, at
00015  * <http://www.OpenLDAP.org/license.html>.
00016  */
00017 /* ACKNOWLEDGEMENTS:
00018  * This work was initially developed by Pierangelo Masarati for inclusion
00019  * in OpenLDAP Software.
00020  */
00021 
00022 #ifndef _BACK_MONITOR_H_
00023 #define _BACK_MONITOR_H_
00024 
00025 #include <ldap_pvt.h>
00026 #include <ldap_pvt_thread.h>
00027 #include <avl.h>
00028 #include <slap.h>
00029 
00030 LDAP_BEGIN_DECL
00031 
00032 /* define if si_ad_labeledURI is removed from slap_schema */
00033 #undef MONITOR_DEFINE_LABELEDURI
00034 
00035 typedef struct monitor_callback_t {
00036        int                         (*mc_update)( Operation *op, SlapReply *rs, Entry *e, void *priv );
00037                                           /* update callback
00038                                              for user-defined entries */
00039        int                         (*mc_modify)( Operation *op, SlapReply *rs, Entry *e, void *priv );
00040                                           /* modify callback
00041                                              for user-defined entries */
00042        int                         (*mc_free)( Entry *e, void **priv );
00043                                           /* delete callback
00044                                              for user-defined entries */
00045        void                        (*mc_dispose)( void **priv );
00046                                           /* dispose callback
00047                                              to dispose of the callback
00048                                              private data itself */
00049        void                        *mc_private;  /* opaque pointer to
00050                                              private data */
00051        struct monitor_callback_t   *mc_next;
00052 } monitor_callback_t;
00053 
00054 
00055 typedef struct monitor_entry_t {
00056        ldap_pvt_thread_mutex_t     mp_mutex;     /* entry mutex */
00057        Entry                *mp_next;     /* pointer to next sibling */
00058        Entry                *mp_children; /* pointer to first child */
00059        struct monitor_subsys_t     *mp_info;     /* subsystem info */
00060 #define mp_type             mp_info->mss_type
00061        unsigned long        mp_flags;     /* flags */
00062 
00063 #define       MONITOR_F_NONE              0x0000U
00064 #define MONITOR_F_SUB              0x0001U              /* subentry of subsystem */
00065 #define MONITOR_F_PERSISTENT       0x0010U              /* persistent entry */
00066 #define MONITOR_F_PERSISTENT_CH    0x0020U              /* subsystem generates 
00067                                              persistent entries */
00068 #define MONITOR_F_VOLATILE  0x0040U              /* volatile entry */
00069 #define MONITOR_F_VOLATILE_CH      0x0080U              /* subsystem generates 
00070                                              volatile entries */
00071 #define MONITOR_F_EXTERNAL  0x0100U              /* externally added - don't free */
00072 /* NOTE: flags with 0xF0000000U mask are reserved for subsystem internals */
00073 
00074        struct monitor_callback_t   *mp_cb;              /* callback sequence */
00075 } monitor_entry_t;
00076 
00077 struct entry_limbo_t;                     /* in init.c */
00078 
00079 typedef struct monitor_info_t {
00080 
00081        /*
00082         * Internal data
00083         */
00084        Avlnode                     *mi_cache;
00085        ldap_pvt_thread_mutex_t     mi_cache_mutex;
00086 
00087        /*
00088         * Config parameters
00089         */
00090        struct berval        mi_startTime;        /* don't free it! */
00091        struct berval        mi_creatorsName;     /* don't free it! */
00092        struct berval        mi_ncreatorsName;    /* don't free it! */
00093 
00094        /*
00095         * Specific schema entities
00096         */
00097        ObjectClass          *mi_oc_monitor;
00098        ObjectClass          *mi_oc_monitorServer;
00099        ObjectClass          *mi_oc_monitorContainer;
00100        ObjectClass          *mi_oc_monitorCounterObject;
00101        ObjectClass          *mi_oc_monitorOperation;
00102        ObjectClass          *mi_oc_monitorConnection;
00103        ObjectClass          *mi_oc_managedObject;
00104        ObjectClass          *mi_oc_monitoredObject;
00105 
00106        AttributeDescription *mi_ad_monitoredInfo;
00107        AttributeDescription *mi_ad_managedInfo;
00108        AttributeDescription *mi_ad_monitorCounter;
00109        AttributeDescription *mi_ad_monitorOpCompleted;
00110        AttributeDescription *mi_ad_monitorOpInitiated;
00111        AttributeDescription *mi_ad_monitorConnectionNumber;
00112        AttributeDescription *mi_ad_monitorConnectionAuthzDN;
00113        AttributeDescription *mi_ad_monitorConnectionLocalAddress;
00114        AttributeDescription *mi_ad_monitorConnectionPeerAddress;
00115        AttributeDescription *mi_ad_monitorTimestamp;
00116        AttributeDescription *mi_ad_monitorOverlay;
00117        AttributeDescription *mi_ad_monitorConnectionProtocol;
00118        AttributeDescription *mi_ad_monitorConnectionOpsReceived;
00119        AttributeDescription *mi_ad_monitorConnectionOpsExecuting;
00120        AttributeDescription *mi_ad_monitorConnectionOpsPending;
00121        AttributeDescription *mi_ad_monitorConnectionOpsCompleted;
00122        AttributeDescription *mi_ad_monitorConnectionGet;
00123        AttributeDescription *mi_ad_monitorConnectionRead;
00124        AttributeDescription *mi_ad_monitorConnectionWrite;
00125        AttributeDescription *mi_ad_monitorConnectionMask;
00126        AttributeDescription *mi_ad_monitorConnectionListener;
00127        AttributeDescription *mi_ad_monitorConnectionPeerDomain;
00128        AttributeDescription *mi_ad_monitorConnectionStartTime;
00129        AttributeDescription *mi_ad_monitorConnectionActivityTime;
00130        AttributeDescription *mi_ad_monitorIsShadow;
00131        AttributeDescription *mi_ad_monitorUpdateRef;
00132        AttributeDescription *mi_ad_monitorRuntimeConfig;
00133        AttributeDescription *mi_ad_monitorSuperiorDN;
00134 
00135        /*
00136         * Generic description attribute
00137         */
00138        AttributeDescription *mi_ad_readOnly;
00139        AttributeDescription *mi_ad_restrictedOperation;
00140 
00141        struct entry_limbo_t *mi_entry_limbo;
00142 } monitor_info_t;
00143 
00144 /*
00145  * DNs
00146  */
00147 
00148 enum {
00149        SLAPD_MONITOR_BACKEND = 0,
00150        SLAPD_MONITOR_CONN,
00151        SLAPD_MONITOR_DATABASE,
00152        SLAPD_MONITOR_LISTENER,
00153        SLAPD_MONITOR_LOG,
00154        SLAPD_MONITOR_OPS,
00155        SLAPD_MONITOR_OVERLAY,
00156        SLAPD_MONITOR_SASL,
00157        SLAPD_MONITOR_SENT,
00158        SLAPD_MONITOR_THREAD,
00159        SLAPD_MONITOR_TIME,
00160        SLAPD_MONITOR_TLS,
00161        SLAPD_MONITOR_RWW,
00162 
00163        SLAPD_MONITOR_LAST
00164 };
00165 
00166 #define SLAPD_MONITOR_AT           "cn"
00167 
00168 #define SLAPD_MONITOR_BACKEND_NAME "Backends"
00169 #define SLAPD_MONITOR_BACKEND_RDN  \
00170        SLAPD_MONITOR_AT "=" SLAPD_MONITOR_BACKEND_NAME
00171 #define SLAPD_MONITOR_BACKEND_DN   \
00172        SLAPD_MONITOR_BACKEND_RDN "," SLAPD_MONITOR_DN
00173 
00174 #define SLAPD_MONITOR_CONN_NAME           "Connections"
00175 #define SLAPD_MONITOR_CONN_RDN     \
00176        SLAPD_MONITOR_AT "=" SLAPD_MONITOR_CONN_NAME
00177 #define SLAPD_MONITOR_CONN_DN      \
00178        SLAPD_MONITOR_CONN_RDN "," SLAPD_MONITOR_DN
00179 
00180 #define SLAPD_MONITOR_DATABASE_NAME       "Databases"
00181 #define SLAPD_MONITOR_DATABASE_RDN \
00182        SLAPD_MONITOR_AT "=" SLAPD_MONITOR_DATABASE_NAME
00183 #define SLAPD_MONITOR_DATABASE_DN  \
00184        SLAPD_MONITOR_DATABASE_RDN "," SLAPD_MONITOR_DN
00185 
00186 #define SLAPD_MONITOR_LISTENER_NAME       "Listeners"
00187 #define SLAPD_MONITOR_LISTENER_RDN \
00188        SLAPD_MONITOR_AT "=" SLAPD_MONITOR_LISTENER_NAME
00189 #define SLAPD_MONITOR_LISTENER_DN  \
00190        SLAPD_MONITOR_LISTENER_RDN "," SLAPD_MONITOR_DN
00191 
00192 #define SLAPD_MONITOR_LOG_NAME            "Log"
00193 #define SLAPD_MONITOR_LOG_RDN      \
00194        SLAPD_MONITOR_AT "=" SLAPD_MONITOR_LOG_NAME
00195 #define SLAPD_MONITOR_LOG_DN       \
00196        SLAPD_MONITOR_LOG_RDN "," SLAPD_MONITOR_DN
00197 
00198 #define SLAPD_MONITOR_OPS_NAME            "Operations"
00199 #define SLAPD_MONITOR_OPS_RDN      \
00200        SLAPD_MONITOR_AT "=" SLAPD_MONITOR_OPS_NAME
00201 #define SLAPD_MONITOR_OPS_DN       \
00202        SLAPD_MONITOR_OPS_RDN "," SLAPD_MONITOR_DN
00203 
00204 #define SLAPD_MONITOR_OVERLAY_NAME "Overlays"
00205 #define SLAPD_MONITOR_OVERLAY_RDN  \
00206        SLAPD_MONITOR_AT "=" SLAPD_MONITOR_OVERLAY_NAME
00207 #define SLAPD_MONITOR_OVERLAY_DN   \
00208        SLAPD_MONITOR_OVERLAY_RDN "," SLAPD_MONITOR_DN
00209 
00210 #define SLAPD_MONITOR_SASL_NAME           "SASL"
00211 #define SLAPD_MONITOR_SASL_RDN     \
00212        SLAPD_MONITOR_AT "=" SLAPD_MONITOR_SASL_NAME
00213 #define SLAPD_MONITOR_SASL_DN      \
00214        SLAPD_MONITOR_SASL_RDN "," SLAPD_MONITOR_DN
00215 
00216 #define SLAPD_MONITOR_SENT_NAME           "Statistics"
00217 #define SLAPD_MONITOR_SENT_RDN     \
00218        SLAPD_MONITOR_AT "=" SLAPD_MONITOR_SENT_NAME
00219 #define SLAPD_MONITOR_SENT_DN      \
00220        SLAPD_MONITOR_SENT_RDN "," SLAPD_MONITOR_DN
00221 
00222 #define SLAPD_MONITOR_THREAD_NAME  "Threads"
00223 #define SLAPD_MONITOR_THREAD_RDN   \
00224        SLAPD_MONITOR_AT "=" SLAPD_MONITOR_THREAD_NAME
00225 #define SLAPD_MONITOR_THREAD_DN    \
00226        SLAPD_MONITOR_THREAD_RDN "," SLAPD_MONITOR_DN
00227 
00228 #define SLAPD_MONITOR_TIME_NAME           "Time"
00229 #define SLAPD_MONITOR_TIME_RDN  \
00230        SLAPD_MONITOR_AT "=" SLAPD_MONITOR_TIME_NAME
00231 #define SLAPD_MONITOR_TIME_DN   \
00232        SLAPD_MONITOR_TIME_RDN "," SLAPD_MONITOR_DN
00233 
00234 #define SLAPD_MONITOR_TLS_NAME            "TLS"
00235 #define SLAPD_MONITOR_TLS_RDN      \
00236        SLAPD_MONITOR_AT "=" SLAPD_MONITOR_TLS_NAME
00237 #define SLAPD_MONITOR_TLS_DN       \
00238        SLAPD_MONITOR_TLS_RDN "," SLAPD_MONITOR_DN
00239 
00240 #define SLAPD_MONITOR_RWW_NAME            "Waiters"
00241 #define SLAPD_MONITOR_RWW_RDN      \
00242        SLAPD_MONITOR_AT "=" SLAPD_MONITOR_RWW_NAME
00243 #define SLAPD_MONITOR_RWW_DN       \
00244        SLAPD_MONITOR_RWW_RDN "," SLAPD_MONITOR_DN
00245 
00246 typedef struct monitor_subsys_t {
00247        char          *mss_name;
00248        struct berval mss_rdn;
00249        struct berval mss_dn;
00250        struct berval mss_ndn;
00251        struct berval mss_desc[ 3 ];
00252        int           mss_flags;
00253 #define MONITOR_F_OPENED    0x10000000U
00254 
00255 #define MONITOR_HAS_VOLATILE_CH( mp ) \
00256        ( ( mp )->mp_flags & MONITOR_F_VOLATILE_CH )
00257 #define MONITOR_HAS_CHILDREN( mp ) \
00258        ( ( mp )->mp_children || MONITOR_HAS_VOLATILE_CH( mp ) )
00259 
00260        /* initialize entry and subentries */
00261        int           ( *mss_open )( BackendDB *, struct monitor_subsys_t *ms );
00262        /* destroy structure */
00263        int           ( *mss_destroy )( BackendDB *, struct monitor_subsys_t *ms );
00264        /* update existing dynamic entry and subentries */
00265        int           ( *mss_update )( Operation *, SlapReply *, Entry * );
00266        /* create new dynamic subentries */
00267        int           ( *mss_create )( Operation *, SlapReply *,
00268                             struct berval *ndn, Entry *, Entry ** );
00269        /* modify entry and subentries */
00270        int           ( *mss_modify )( Operation *, SlapReply *, Entry * );
00271 } monitor_subsys_t;
00272 
00273 extern BackendDB *be_monitor;
00274 
00275 /* increase this bufsize if entries in string form get too big */
00276 #define BACKMONITOR_BUFSIZE 8192
00277 
00278 typedef int (monitor_cbfunc)( struct berval *ndn, monitor_callback_t *cb,
00279        struct berval *base, int scope, struct berval *filter );
00280 
00281 typedef int (monitor_cbafunc)( struct berval *ndn, Attribute *a,
00282        monitor_callback_t *cb,
00283        struct berval *base, int scope, struct berval *filter );
00284 
00285 typedef struct monitor_extra_t {
00286        int (*is_configured)(void);
00287        monitor_subsys_t * (*get_subsys)( const char *name );
00288        monitor_subsys_t * (*get_subsys_by_dn)( struct berval *ndn, int sub );
00289 
00290        int (*register_subsys)( monitor_subsys_t *ms );
00291        int (*register_backend)( BackendInfo *bi );
00292        int (*register_database)( BackendDB *be, struct berval *ndn_out );
00293        int (*register_overlay_info)( slap_overinst *on );
00294        int (*register_overlay)( BackendDB *be, slap_overinst *on, struct berval *ndn_out );
00295        int (*register_entry)( Entry *e, monitor_callback_t *cb,
00296               monitor_subsys_t *ms, unsigned long flags );
00297        int (*register_entry_parent)( Entry *e, monitor_callback_t *cb,
00298               monitor_subsys_t *ms, unsigned long flags,
00299               struct berval *base, int scope, struct berval *filter );
00300        monitor_cbafunc *register_entry_attrs;
00301        monitor_cbfunc *register_entry_callback;
00302 
00303        int (*unregister_entry)( struct berval *ndn );
00304        monitor_cbfunc *unregister_entry_parent;
00305        monitor_cbafunc *unregister_entry_attrs;
00306        monitor_cbfunc *unregister_entry_callback;
00307 } monitor_extra_t;
00308 
00309 LDAP_END_DECL
00310 
00311 #include "proto-back-monitor.h"
00312 
00313 #endif /* _back_monitor_h_ */
00314