]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-monitor/sent.c
#include <ac/string.h>, to get strlen(), strncmp() and strncasecmp().
[openldap] / servers / slapd / back-monitor / sent.c
index 137e8efb8ce60b64756e721b44143d1f403a69e1..3637f4fd39e7d5e7ca922f5c412dbdbfdb5e7123 100644 (file)
@@ -34,6 +34,7 @@
 #include "portable.h"
 
 #include <stdio.h>
+#include <ac/string.h>
 
 #include "slap.h"
 #include "back-monitor.h"
@@ -47,8 +48,8 @@ monitor_subsys_sent_init(
        
        Entry                   *e, *e_tmp, *e_sent;
        struct monitorentrypriv *mp;
-       char                    buf[1024];
-       struct berval           bv[2];
+       char                    buf[ BACKMONITOR_BUFSIZE ];
+       struct berval           bv;
 
        assert( be != NULL );
 
@@ -78,9 +79,12 @@ monitor_subsys_sent_init(
         */
        snprintf( buf, sizeof( buf ),
                        "dn: cn=Entries,%s\n"
-                       SLAPD_MONITOR_OBJECTCLASSES
+                       "objectClass: %s\n"
+                       "structuralObjectClass: %s\n"
                        "cn: Entries\n",
-                       monitor_subsys[SLAPD_MONITOR_SENT].mss_dn.bv_val );
+                       monitor_subsys[SLAPD_MONITOR_SENT].mss_dn.bv_val,
+                       mi->oc_monitorCounterObject->soc_cname.bv_val,
+                       mi->oc_monitorCounterObject->soc_cname.bv_val );
 
        e = str2entry( buf );
        if ( e == NULL ) {
@@ -99,10 +103,9 @@ monitor_subsys_sent_init(
                return( -1 );
        }
        
-       bv[1].bv_val = NULL;
-       bv[0].bv_val = "0";
-       bv[0].bv_len = 1;
-       attr_mergeit( e, monitor_ad_desc, bv );
+       bv.bv_val = "0";
+       bv.bv_len = 1;
+       attr_merge_one( e, mi->ad_monitorCounter, &bv, NULL );
        
        mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
        e->e_private = ( void * )mp;
@@ -135,9 +138,12 @@ monitor_subsys_sent_init(
         */
        snprintf( buf, sizeof( buf ),
                        "dn: cn=Referrals,%s\n"
-                       SLAPD_MONITOR_OBJECTCLASSES
+                       "objectClass: %s\n"
+                       "structuralObjectClass: %s\n"
                        "cn: Referrals\n",
-                       monitor_subsys[SLAPD_MONITOR_SENT].mss_dn.bv_val );
+                       monitor_subsys[SLAPD_MONITOR_SENT].mss_dn.bv_val,
+                       mi->oc_monitorCounterObject->soc_cname.bv_val,
+                       mi->oc_monitorCounterObject->soc_cname.bv_val );
 
        e = str2entry( buf );
        if ( e == NULL ) {
@@ -156,9 +162,9 @@ monitor_subsys_sent_init(
                return( -1 );
        }
 
-       bv[0].bv_val = "0";
-       bv[0].bv_len = 1;
-       attr_mergeit( e, monitor_ad_desc, bv );
+       bv.bv_val = "0";
+       bv.bv_len = 1;
+       attr_merge_one( e, mi->ad_monitorCounter, &bv, NULL );
        
        mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
        e->e_private = ( void * )mp;
@@ -191,9 +197,12 @@ monitor_subsys_sent_init(
         */
        snprintf( buf, sizeof( buf ),
                        "dn: cn=PDU,%s\n"
-                       SLAPD_MONITOR_OBJECTCLASSES
+                       "objectClass: %s\n"
+                       "structuralObjectClass: %s\n"
                        "cn: PDU\n",
-                       monitor_subsys[SLAPD_MONITOR_SENT].mss_dn.bv_val );
+                       monitor_subsys[SLAPD_MONITOR_SENT].mss_dn.bv_val,
+                       mi->oc_monitorCounterObject->soc_cname.bv_val,
+                       mi->oc_monitorCounterObject->soc_cname.bv_val );
 
        e = str2entry( buf );
        if ( e == NULL ) {
@@ -212,9 +221,9 @@ monitor_subsys_sent_init(
                return( -1 );
        }
 
-       bv[0].bv_val = "0";
-       bv[0].bv_len = 1;
-       attr_mergeit( e, monitor_ad_desc, bv );
+       bv.bv_val = "0";
+       bv.bv_len = 1;
+       attr_merge_one( e, mi->ad_monitorCounter, &bv, NULL );
        
        mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
        e->e_private = ( void * )mp;
@@ -247,9 +256,12 @@ monitor_subsys_sent_init(
         */
        snprintf( buf, sizeof( buf ),
                        "dn: cn=Bytes,%s\n"
-                       SLAPD_MONITOR_OBJECTCLASSES
+                       "objectClass: %s\n"
+                       "structuralObjectClass: %s\n"
                        "cn: Bytes\n",
-                       monitor_subsys[SLAPD_MONITOR_SENT].mss_dn.bv_val );
+                       monitor_subsys[SLAPD_MONITOR_SENT].mss_dn.bv_val,
+                       mi->oc_monitorCounterObject->soc_cname.bv_val,
+                       mi->oc_monitorCounterObject->soc_cname.bv_val );
 
        e = str2entry( buf );
        if ( e == NULL ) {
@@ -268,9 +280,9 @@ monitor_subsys_sent_init(
                return( -1 );
        }
 
-       bv[0].bv_val = "0";
-       bv[0].bv_len = 1;
-       attr_mergeit( e, monitor_ad_desc, bv );
+       bv.bv_val = "0";
+       bv.bv_len = 1;
+       attr_merge_one( e, mi->ad_monitorCounter, &bv, NULL );
        
        mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
        e->e_private = ( void * )mp;
@@ -308,10 +320,11 @@ monitor_subsys_sent_init(
 
 int
 monitor_subsys_sent_update(
-       struct monitorinfo      *mi,
+       Operation               *op,
        Entry                   *e
 )
 {
+       struct monitorinfo *mi = (struct monitorinfo *)op->o_bd->be_private;
        long            n = -1;
 
        assert( mi );
@@ -344,16 +357,16 @@ monitor_subsys_sent_update(
 
        if ( n != -1 ) {
                Attribute       *a;
-               char            buf[16];
+               char            buf[] = "+9223372036854775807L";
 
-               a = attr_find( e->e_attrs, monitor_ad_desc );
+               a = attr_find( e->e_attrs, mi->ad_monitorCounter);
                if ( a == NULL ) {
                        return( -1 );
                }
 
                snprintf( buf, sizeof( buf ), "%ld", n );
                free( a->a_vals[ 0 ].bv_val );
-               ber_str2bv( buf, 0, 1, a->a_vals );
+               ber_str2bv( buf, 0, 1, &a->a_vals[ 0 ] );
        }
 
        return( 0 );