]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/monitor.c
Add reference to slapd.conf(5) and recommendation to avoid cleartext passwords.
[openldap] / servers / slapd / monitor.c
index 66c6494e5c11d3ad172226f8e29b09cd9c94cf71..9efffc788e8c14a743b425b5ef86e92f3f204cd8 100644 (file)
 #include "portable.h"
 
 #include <stdio.h>
-#include <string.h>
-#include <time.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include "slap.h"
-#include "ldapconfig.h"
-
-#if defined( SLAPD_MONITOR_DN )
 
-extern int             nbackends;
-extern Backend         *backends;
-extern int             active_threads;
-extern int             dtblsize;
-extern Connection      *c;
-extern long            ops_initiated;
-extern long            ops_completed;
-extern long            num_entries_sent;
-extern long            num_bytes_sent;
-extern time_t          currenttime;
-extern time_t          starttime;
-extern int             num_conns;
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/time.h>
 
-extern pthread_mutex_t new_conn_mutex;
-extern pthread_mutex_t currenttime_mutex;
+#include "ldapconfig.h"
+#include "slap.h"
 
-extern char Versionstr[];
+#if defined( SLAPD_MONITOR_DN )
 
 void
 monitor_info( Connection *conn, Operation *op )
@@ -65,7 +48,8 @@ monitor_info( Connection *conn, Operation *op )
        /* initialize reader/writer lock */
        entry_rdwr_init(e);
        e->e_attrs = NULL;
-       e->e_dn = strdup( SLAPD_MONITOR_DN );
+       e->e_dn = ch_strdup( SLAPD_MONITOR_DN );
+       e->e_ndn = NULL;
 
        val.bv_val = Versionstr;
        if (( p = strchr( Versionstr, '\n' )) == NULL ) {
@@ -95,16 +79,17 @@ monitor_info( Connection *conn, Operation *op )
                                nreadwaiters++;
                        }
                        pthread_mutex_lock( &currenttime_mutex );
-                       ltm = localtime( &c[i].c_starttime );
-#ifdef LDAP_Y2K
+#ifndef LDAP_LOCALTIME
+                       ltm = gmtime( &c[i].c_starttime );
                        strftime( buf2, sizeof(buf2), "%Y%m%d%H%M%SZ", ltm );
 #else
+                       ltm = localtime( &c[i].c_starttime );
                        strftime( buf2, sizeof(buf2), "%y%m%d%H%M%SZ", ltm );
 #endif
                        pthread_mutex_unlock( &currenttime_mutex );
 
                        pthread_mutex_lock( &c[i].c_dnmutex );
-                       sprintf( buf, "%d : %s : %ld : %ld : %s : %s%s", i,
+                       sprintf( buf, "%d : %s : %d : %d : %s : %s%s", i,
                            buf2, c[i].c_opsinitiated, c[i].c_opscompleted,
                            c[i].c_dn ? c[i].c_dn : "NULLDN",
                            c[i].c_gettingber ? "r" : "",
@@ -163,10 +148,11 @@ monitor_info( Connection *conn, Operation *op )
        attr_merge( e, "bytessent", vals );
 
        pthread_mutex_lock( &currenttime_mutex );
-       ltm = localtime( &currenttime );
-#ifdef LDAP_Y2K
+#ifndef LDAP_LOCALTIME
+       ltm = gmtime( &currenttime );
        strftime( buf, sizeof(buf), "%Y%m%d%H%M%SZ", ltm );
 #else
+       ltm = localtime( &currenttime );
        strftime( buf, sizeof(buf), "%y%m%d%H%M%SZ", ltm );
 #endif
        pthread_mutex_unlock( &currenttime_mutex );
@@ -175,10 +161,11 @@ monitor_info( Connection *conn, Operation *op )
        attr_merge( e, "currenttime", vals );
 
        pthread_mutex_lock( &currenttime_mutex );
-       ltm = localtime( &starttime );
-#ifdef LDAP_Y2K
+#ifndef LDAP_LOCALTIME
+       ltm = gmtime( &starttime );
        strftime( buf, sizeof(buf), "%Y%m%d%H%M%SZ", ltm );
 #else
+       ltm = localtime( &starttime );
        strftime( buf, sizeof(buf), "%y%m%d%H%M%SZ", ltm );
 #endif
        pthread_mutex_unlock( &currenttime_mutex );
@@ -191,7 +178,7 @@ monitor_info( Connection *conn, Operation *op )
        val.bv_len = strlen( buf );
        attr_merge( e, "nbackends", vals );
 
-#ifdef THREAD_SUNOS5_LWP
+#ifdef HAVE_THR
        sprintf( buf, "%d", thr_getconcurrency() );
        val.bv_val = buf;
        val.bv_len = strlen( buf );