]> 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 972331fd979e7ea326bb4d61031954f676204b8b..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,7 +48,7 @@ monitor_subsys_sent_init(
        
        Entry                   *e, *e_tmp, *e_sent;
        struct monitorentrypriv *mp;
-       char                    buf[1024];
+       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 ) {
@@ -101,7 +105,7 @@ monitor_subsys_sent_init(
        
        bv.bv_val = "0";
        bv.bv_len = 1;
-       attr_merge_one( e, monitor_ad_desc, &bv, NULL );
+       attr_merge_one( e, mi->ad_monitorCounter, &bv, NULL );
        
        mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
        e->e_private = ( void * )mp;
@@ -134,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 ) {
@@ -157,7 +164,7 @@ monitor_subsys_sent_init(
 
        bv.bv_val = "0";
        bv.bv_len = 1;
-       attr_merge_one( e, monitor_ad_desc, &bv, NULL );
+       attr_merge_one( e, mi->ad_monitorCounter, &bv, NULL );
        
        mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
        e->e_private = ( void * )mp;
@@ -190,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 ) {
@@ -213,7 +223,7 @@ monitor_subsys_sent_init(
 
        bv.bv_val = "0";
        bv.bv_len = 1;
-       attr_merge_one( e, monitor_ad_desc, &bv, NULL );
+       attr_merge_one( e, mi->ad_monitorCounter, &bv, NULL );
        
        mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
        e->e_private = ( void * )mp;
@@ -246,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 ) {
@@ -269,7 +282,7 @@ monitor_subsys_sent_init(
 
        bv.bv_val = "0";
        bv.bv_len = 1;
-       attr_merge_one( e, monitor_ad_desc, &bv, NULL );
+       attr_merge_one( e, mi->ad_monitorCounter, &bv, NULL );
        
        mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
        e->e_private = ( void * )mp;
@@ -307,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 );
@@ -343,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 );