Branch '389-ds-base-1.3.1' - ldap/servers
by Richard Allen Megginson
ldap/servers/slapd/daemon.c | 16 ++++------------
ldap/servers/slapd/libglobs.c | 34 +++++++++++++++++++++++++++++++++-
ldap/servers/slapd/proto-slap.h | 2 ++
ldap/servers/slapd/slap.h | 10 ++++++++++
4 files changed, 49 insertions(+), 13 deletions(-)
New commits:
commit 5fae016b4bf70bac303b1a4477ccf5e53aabc89b
Author: Rich Megginson <rmeggins(a)redhat.com>
Date: Tue Apr 16 08:26:03 2013 -0600
Ticket #47377 - make listen backlog size configurable
https://fedorahosted.org/389/ticket/47377
Reviewed by: nkinder (Thanks!)
Branch: 389-ds-base-1.3.1
Fix Description: Add the attribute nsslapd-listen-backlog-size - this controls
the listening socket connection backlog maximum size. This corresponds to
the backlog parameter of the listen() system call. The default value is 128.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: yes - need to doc the new attribute
diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c
index eadb4b5..ea31e30 100644
--- a/ldap/servers/slapd/daemon.c
+++ b/ldap/servers/slapd/daemon.c
@@ -101,14 +101,6 @@
#include "getsocketpeer.h"
#endif /* ENABLE_LDAPI */
-/*
- * Define the backlog number for use in listen() call.
- * We use the same definition as in ldapserver/include/base/systems.h
- */
-#ifndef DAEMON_LISTEN_SIZE
-#define DAEMON_LISTEN_SIZE 128
-#endif
-
#if defined (LDAP_IOCP)
#define SLAPD_WAKEUP_TIMER 250
#else
@@ -1085,7 +1077,7 @@ void slapd_daemon( daemon_ports_t *ports )
/* We are now ready to accept incoming connections */
#if defined( XP_WIN32 )
if ( n_tcps != SLAPD_INVALID_SOCKET
- && listen( n_tcps, DAEMON_LISTEN_SIZE ) == -1 ) {
+ && listen( n_tcps, config_get_listen_backlog_size() ) == -1 ) {
int oserr = errno;
char addrbuf[ 256 ];
@@ -1101,7 +1093,7 @@ void slapd_daemon( daemon_ports_t *ports )
PRFileDesc **fdesp;
PRNetAddr **nap = ports->n_listenaddr;
for (fdesp = n_tcps; fdesp && *fdesp; fdesp++, nap++) {
- if ( PR_Listen( *fdesp, DAEMON_LISTEN_SIZE ) == PR_FAILURE ) {
+ if ( PR_Listen( *fdesp, config_get_listen_backlog_size() ) == PR_FAILURE ) {
PRErrorCode prerr = PR_GetError();
char addrbuf[ 256 ];
@@ -1121,7 +1113,7 @@ void slapd_daemon( daemon_ports_t *ports )
PRFileDesc **fdesp;
PRNetAddr **sap = ports->s_listenaddr;
for (fdesp = s_tcps; fdesp && *fdesp; fdesp++, sap++) {
- if ( PR_Listen( *fdesp, DAEMON_LISTEN_SIZE ) == PR_FAILURE ) {
+ if ( PR_Listen( *fdesp, config_get_listen_backlog_size() ) == PR_FAILURE ) {
PRErrorCode prerr = PR_GetError();
char addrbuf[ 256 ];
@@ -1142,7 +1134,7 @@ void slapd_daemon( daemon_ports_t *ports )
PRFileDesc **fdesp;
PRNetAddr **iap = ports->i_listenaddr;
for (fdesp = i_unix; fdesp && *fdesp; fdesp++, iap++) {
- if ( PR_Listen(*fdesp, DAEMON_LISTEN_SIZE) == PR_FAILURE) {
+ if ( PR_Listen(*fdesp, config_get_listen_backlog_size()) == PR_FAILURE) {
PRErrorCode prerr = PR_GetError();
slapi_log_error(SLAPI_LOG_FATAL, "slapd_daemon",
"listen() on %s failed: error %d (%s)\n",
diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c
index 67f0b3a..dbdf5c2 100644
--- a/ldap/servers/slapd/libglobs.c
+++ b/ldap/servers/slapd/libglobs.c
@@ -256,6 +256,7 @@ slapi_onoff_t init_ndn_cache_enabled;
slapi_onoff_t init_sasl_mapping_fallback;
slapi_onoff_t init_return_orig_type;
slapi_onoff_t init_enable_turbo_mode;
+slapi_int_t init_listen_backlog_size;
#ifdef MEMPOOL_EXPERIMENTAL
slapi_onoff_t init_mempool_switch;
#endif
@@ -1042,7 +1043,11 @@ static struct config_get_and_set {
{CONFIG_ENABLE_TURBO_MODE, config_set_enable_turbo_mode,
NULL, 0,
(void**)&global_slapdFrontendConfig.enable_turbo_mode,
- CONFIG_ON_OFF, (ConfigGetFunc)config_get_enable_turbo_mode, &init_enable_turbo_mode}
+ CONFIG_ON_OFF, (ConfigGetFunc)config_get_enable_turbo_mode, &init_enable_turbo_mode},
+ {CONFIG_LISTEN_BACKLOG_SIZE, config_set_listen_backlog_size,
+ NULL, 0,
+ (void**)&global_slapdFrontendConfig.listen_backlog_size, CONFIG_INT,
+ (ConfigGetFunc)config_get_listen_backlog_size, &init_listen_backlog_size}
#ifdef MEMPOOL_EXPERIMENTAL
,{CONFIG_MEMPOOL_SWITCH_ATTRIBUTE, config_set_mempool_switch,
NULL, 0,
@@ -1482,6 +1487,7 @@ FrontendConfig_init () {
init_return_orig_type = cfg->return_orig_type = LDAP_OFF;
init_enable_turbo_mode = cfg->enable_turbo_mode = LDAP_ON;
+ init_listen_backlog_size = cfg->listen_backlog_size = DAEMON_LISTEN_SIZE;
#ifdef MEMPOOL_EXPERIMENTAL
init_mempool_switch = cfg->mempool_switch = LDAP_ON;
cfg->mempool_maxfreelist = 1024;
@@ -6912,6 +6918,32 @@ config_set_enable_turbo_mode( const char *attrname, char *value,
return retVal;
}
+int
+config_set_listen_backlog_size( const char *attrname, char *value,
+ char *errorbuf, int apply )
+{
+ slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
+
+ if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
+ return LDAP_OPERATIONS_ERROR;
+ }
+
+ if ( apply ) {
+ PR_AtomicSet(&slapdFrontendConfig->listen_backlog_size, atoi(value));
+ }
+ return LDAP_SUCCESS;
+}
+
+int
+config_get_listen_backlog_size()
+{
+ slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
+ int retVal;
+
+ retVal = slapdFrontendConfig->listen_backlog_size;
+ return retVal;
+}
+
/*
* This function is intended to be used from the dse code modify callback. It
* is "optimized" for that case because it takes a berval** of values, which is
diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h
index fff3e7c..2b973be 100644
--- a/ldap/servers/slapd/proto-slap.h
+++ b/ldap/servers/slapd/proto-slap.h
@@ -401,6 +401,7 @@ int config_set_ndn_cache_max_size(const char *attrname, char *value, char *error
int config_set_unhashed_pw_switch(const char *attrname, char *value, char *errorbuf, int apply);
int config_set_return_orig_type_switch(const char *attrname, char *value, char *errorbuf, int apply);
int config_set_sasl_maxbufsize(const char *attrname, char *value, char *errorbuf, int apply );
+int config_set_listen_backlog_size(const char *attrname, char *value, char *errorbuf, int apply);
#if !defined(_WIN32) && !defined(AIX)
int config_set_maxdescriptors( const char *attrname, char *value, char *errorbuf, int apply );
@@ -570,6 +571,7 @@ int config_get_unhashed_pw_switch();
int config_get_sasl_maxbufsize();
int config_get_enable_turbo_mode();
int config_set_enable_turbo_mode(const char *attrname, char *value, char *errorbuf, int apply);
+int config_get_listen_backlog_size(void);
PLHashNumber hashNocaseString(const void *key);
PRIntn hashNocaseCompare(const void *v1, const void *v2);
diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h
index 2d4b108..1420316 100644
--- a/ldap/servers/slapd/slap.h
+++ b/ldap/servers/slapd/slap.h
@@ -2077,6 +2077,15 @@ typedef struct _slapdEntryPoints {
#define CONFIG_SASL_MAXBUFSIZE "nsslapd-sasl-max-buffer-size"
#define CONFIG_SEARCH_RETURN_ORIGINAL_TYPE "nsslapd-search-return-original-type-switch"
#define CONFIG_ENABLE_TURBO_MODE "nsslapd-enable-turbo-mode"
+#define CONFIG_LISTEN_BACKLOG_SIZE "nsslapd-listen-backlog-size"
+
+/*
+ * Define the backlog number for use in listen() call.
+ * We use the same definition as in ldapserver/include/base/systems.h
+ */
+#ifndef DAEMON_LISTEN_SIZE
+#define DAEMON_LISTEN_SIZE 128
+#endif
#ifdef MEMPOOL_EXPERIMENTAL
#define CONFIG_MEMPOOL_SWITCH_ATTRIBUTE "nsslapd-mempool"
@@ -2284,6 +2293,7 @@ typedef struct _slapdFrontendConfig {
slapi_onoff_t minssf_exclude_rootdse; /* ON: minssf is ignored when searching rootdse */
size_t maxsasliosize; /* limit incoming SASL IO packet size */
char *anon_limits_dn; /* template entry for anonymous resource limits */
+ slapi_int_t listen_backlog_size; /* size of backlog parameter to PR_Listen */
#ifndef _WIN32
struct passwd *localuserinfo; /* userinfo of localuser */
#endif /* _WIN32 */
10 years, 10 months
Branch '389-ds-base-1.2.11' - ldap/servers
by Richard Allen Megginson
ldap/servers/slapd/daemon.c | 16 ++++------------
ldap/servers/slapd/libglobs.c | 31 +++++++++++++++++++++++++++++++
ldap/servers/slapd/proto-slap.h | 2 ++
ldap/servers/slapd/slap.h | 10 ++++++++++
4 files changed, 47 insertions(+), 12 deletions(-)
New commits:
commit 18ff7203323fef9c7bd01222c6775e82ff979922
Author: Rich Megginson <rmeggins(a)redhat.com>
Date: Tue Apr 16 08:26:03 2013 -0600
Ticket #47377 - make listen backlog size configurable
https://fedorahosted.org/389/ticket/47377
Reviewed by: nkinder (Thanks!)
Branch: 389-ds-base-1.2.11
Fix Description: Add the attribute nsslapd-listen-backlog-size - this controls
the listening socket connection backlog maximum size. This corresponds to
the backlog parameter of the listen() system call. The default value is 128.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: yes - need to doc the new attribute
diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c
index 5bc5fc0..21fe644 100644
--- a/ldap/servers/slapd/daemon.c
+++ b/ldap/servers/slapd/daemon.c
@@ -99,14 +99,6 @@
#include "getsocketpeer.h"
#endif /* ENABLE_LDAPI */
-/*
- * Define the backlog number for use in listen() call.
- * We use the same definition as in ldapserver/include/base/systems.h
- */
-#ifndef DAEMON_LISTEN_SIZE
-#define DAEMON_LISTEN_SIZE 128
-#endif
-
#if defined (LDAP_IOCP)
#define SLAPD_WAKEUP_TIMER 250
#else
@@ -1083,7 +1075,7 @@ void slapd_daemon( daemon_ports_t *ports )
/* We are now ready to accept incoming connections */
#if defined( XP_WIN32 )
if ( n_tcps != SLAPD_INVALID_SOCKET
- && listen( n_tcps, DAEMON_LISTEN_SIZE ) == -1 ) {
+ && listen( n_tcps, config_get_listen_backlog_size() ) == -1 ) {
int oserr = errno;
char addrbuf[ 256 ];
@@ -1099,7 +1091,7 @@ void slapd_daemon( daemon_ports_t *ports )
PRFileDesc **fdesp;
PRNetAddr **nap = ports->n_listenaddr;
for (fdesp = n_tcps; fdesp && *fdesp; fdesp++, nap++) {
- if ( PR_Listen( *fdesp, DAEMON_LISTEN_SIZE ) == PR_FAILURE ) {
+ if ( PR_Listen( *fdesp, config_get_listen_backlog_size() ) == PR_FAILURE ) {
PRErrorCode prerr = PR_GetError();
char addrbuf[ 256 ];
@@ -1119,7 +1111,7 @@ void slapd_daemon( daemon_ports_t *ports )
PRFileDesc **fdesp;
PRNetAddr **sap = ports->s_listenaddr;
for (fdesp = s_tcps; fdesp && *fdesp; fdesp++, sap++) {
- if ( PR_Listen( *fdesp, DAEMON_LISTEN_SIZE ) == PR_FAILURE ) {
+ if ( PR_Listen( *fdesp, config_get_listen_backlog_size() ) == PR_FAILURE ) {
PRErrorCode prerr = PR_GetError();
char addrbuf[ 256 ];
@@ -1140,7 +1132,7 @@ void slapd_daemon( daemon_ports_t *ports )
PRFileDesc **fdesp;
PRNetAddr **iap = ports->i_listenaddr;
for (fdesp = i_unix; fdesp && *fdesp; fdesp++, iap++) {
- if ( PR_Listen(*fdesp, DAEMON_LISTEN_SIZE) == PR_FAILURE) {
+ if ( PR_Listen(*fdesp, config_get_listen_backlog_size()) == PR_FAILURE) {
PRErrorCode prerr = PR_GetError();
slapi_log_error(SLAPI_LOG_FATAL, "slapd_daemon",
"listen() on %s failed: error %d (%s)\n",
diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c
index c8e16fb..dab5275 100644
--- a/ldap/servers/slapd/libglobs.c
+++ b/ldap/servers/slapd/libglobs.c
@@ -693,6 +693,10 @@ static struct config_get_and_set {
NULL, 0,
(void**)&global_slapdFrontendConfig.sasl_max_bufsize,
CONFIG_INT, (ConfigGetFunc)config_get_sasl_maxbufsize},
+ {CONFIG_LISTEN_BACKLOG_SIZE, config_set_listen_backlog_size,
+ NULL, 0,
+ (void**)&global_slapdFrontendConfig.listen_backlog_size, CONFIG_INT,
+ (ConfigGetFunc)config_get_listen_backlog_size}
#ifdef MEMPOOL_EXPERIMENTAL
,{CONFIG_MEMPOOL_SWITCH_ATTRIBUTE, config_set_mempool_switch,
NULL, 0,
@@ -1095,6 +1099,7 @@ FrontendConfig_init () {
cfg->disk_logging_critical = LDAP_OFF;
cfg->sasl_max_bufsize = SLAPD_DEFAULT_SASL_MAXBUFSIZE;
+ cfg->listen_backlog_size = DAEMON_LISTEN_SIZE;
#ifdef MEMPOOL_EXPERIMENTAL
cfg->mempool_switch = LDAP_ON;
cfg->mempool_maxfreelist = 1024;
@@ -6183,6 +6188,32 @@ config_set_default_naming_context(const char *attrname,
return LDAP_SUCCESS;
}
+int
+config_set_listen_backlog_size( const char *attrname, char *value,
+ char *errorbuf, int apply )
+{
+ slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
+
+ if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
+ return LDAP_OPERATIONS_ERROR;
+ }
+
+ if ( apply ) {
+ slapdFrontendConfig->listen_backlog_size = atoi(value);
+ }
+ return LDAP_SUCCESS;
+}
+
+int
+config_get_listen_backlog_size()
+{
+ slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
+ int retVal;
+
+ retVal = slapdFrontendConfig->listen_backlog_size;
+ return retVal;
+}
+
/*
* This function is intended to be used from the dse code modify callback. It
* is "optimized" for that case because it takes a berval** of values, which is
diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h
index 6a9dd3b..08edeb0 100644
--- a/ldap/servers/slapd/proto-slap.h
+++ b/ldap/servers/slapd/proto-slap.h
@@ -392,6 +392,7 @@ int config_set_disk_grace_period( const char *attrname, char *value, char *error
int config_set_disk_logging_critical( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_auditlog_unhashed_pw(const char *attrname, char *value, char *errorbuf, int apply);
int config_set_sasl_maxbufsize(const char *attrname, char *value, char *errorbuf, int apply );
+int config_set_listen_backlog_size(const char *attrname, char *value, char *errorbuf, int apply);
#if !defined(_WIN32) && !defined(AIX)
int config_set_maxdescriptors( const char *attrname, char *value, char *errorbuf, int apply );
@@ -547,6 +548,7 @@ long config_get_disk_threshold();
int config_get_disk_grace_period();
int config_get_disk_logging_critical();
int config_get_sasl_maxbufsize();
+int config_get_listen_backlog_size(void);
int is_abspath(const char *);
char* rel2abspath( char * );
diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h
index 9197011..f1dbbec 100644
--- a/ldap/servers/slapd/slap.h
+++ b/ldap/servers/slapd/slap.h
@@ -2005,6 +2005,15 @@ typedef struct _slapdEntryPoints {
#define CONFIG_DISK_GRACE_PERIOD "nsslapd-disk-monitoring-grace-period"
#define CONFIG_DISK_LOGGING_CRITICAL "nsslapd-disk-monitoring-logging-critical"
#define CONFIG_SASL_MAXBUFSIZE "nsslapd-sasl-max-buffer-size"
+#define CONFIG_LISTEN_BACKLOG_SIZE "nsslapd-listen-backlog-size"
+
+/*
+ * Define the backlog number for use in listen() call.
+ * We use the same definition as in ldapserver/include/base/systems.h
+ */
+#ifndef DAEMON_LISTEN_SIZE
+#define DAEMON_LISTEN_SIZE 128
+#endif
#ifdef MEMPOOL_EXPERIMENTAL
#define CONFIG_MEMPOOL_SWITCH_ATTRIBUTE "nsslapd-mempool"
@@ -2218,6 +2227,7 @@ typedef struct _slapdFrontendConfig {
int minssf_exclude_rootdse; /* ON: minssf is ignored when searching rootdse */
size_t maxsasliosize; /* limit incoming SASL IO packet size */
char *anon_limits_dn; /* template entry for anonymous resource limits */
+ int listen_backlog_size; /* size of backlog parameter to PR_Listen */
#ifndef _WIN32
struct passwd *localuserinfo; /* userinfo of localuser */
#endif /* _WIN32 */
10 years, 10 months
Branch '389-ds-base-1.3.1' - ldap/servers
by Noriko Hosoi
ldap/servers/slapd/entrywsi.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
New commits:
commit 539419f3453d3620f56995026431de82a2ce017c
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Wed Jun 12 16:58:31 2013 -0700
Trac Ticket #402 - nhashed#user#password in entry extension
Description: commit 091c749adcc53ef3332cab6d34b25dadcb69c696
had a logic flaw: entry_apply_mod_wsi checks whether modify
candidate attribute is to be stored in an entry extension or
not. If it is supposed to be in the entry extension, it removes
the attribute from the entry attribute list (e_attrs), and put
it into the entry extension. The steps have to be done under
any condition, but entry_apply_mod_wsi used to check if the
entry extension was configured properly and the attribute
existed in the extension, first. If both were not satisfied,
the attribute was not removed from the attribute list.
This patch eliminated the check and the attribute to be stored
in the entry extension is always removed from the attribute
list in the entry.
Reviewed by Nathan (Thank you!!)
https://fedorahosted.org/389/ticket/402
(cherry picked from commit c4667c08c36294e460a43a378a5f426c841c850c)
diff --git a/ldap/servers/slapd/entrywsi.c b/ldap/servers/slapd/entrywsi.c
index 578cb4f..1b16c65 100644
--- a/ldap/servers/slapd/entrywsi.c
+++ b/ldap/servers/slapd/entrywsi.c
@@ -767,27 +767,24 @@ entry_apply_mod_wsi(Slapi_Entry *e, const LDAPMod *mod, const CSN *csn, int urp)
for (aiep = attrs_in_extension; aiep && aiep->ext_type; aiep++) {
if (0 == strcasecmp(mod->mod_type, aiep->ext_type)) {
Slapi_Attr *a;
- int rc;
- Slapi_Value **ext_vals = NULL;
- rc = slapi_pw_get_entry_ext(e, &ext_vals);
- if (rc) {
- continue; /* skip it. */
- }
+ /* remove the attribute from the attr list */
a = attrlist_remove(&e->e_attrs, mod->mod_type);
if (a && a->a_present_values.va) {
/* a->a_present_values.va is consumed if successful. */
- rc = slapi_pw_set_entry_ext(e, a->a_present_values.va,
- SLAPI_EXT_SET_REPLACE);
+ int rc = slapi_pw_set_entry_ext(e, a->a_present_values.va,
+ SLAPI_EXT_SET_REPLACE);
if (LDAP_SUCCESS == rc) {
/* va is set to entry extension; just release the rest */
a->a_present_values.va = NULL;
}
slapi_attr_free(&a);
} else {
+ Slapi_Value **ext_vals = NULL;
+ slapi_pw_get_entry_ext(e, &ext_vals);
if (ext_vals) {
/* slapi_pw_set_entry_ext frees the stored extension */
- rc = slapi_pw_set_entry_ext(e, NULL, SLAPI_EXT_SET_REPLACE);
+ slapi_pw_set_entry_ext(e, NULL, SLAPI_EXT_SET_REPLACE);
ext_vals = NULL;
}
}
10 years, 10 months
ldap/servers
by Noriko Hosoi
ldap/servers/slapd/entrywsi.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
New commits:
commit c4667c08c36294e460a43a378a5f426c841c850c
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Wed Jun 12 16:58:31 2013 -0700
Trac Ticket #402 - nhashed#user#password in entry extension
Description: commit 091c749adcc53ef3332cab6d34b25dadcb69c696
had a logic flaw: entry_apply_mod_wsi checks whether modify
candidate attribute is to be stored in an entry extension or
not. If it is supposed to be in the entry extension, it removes
the attribute from the entry attribute list (e_attrs), and put
it into the entry extension. The steps have to be done under
any condition, but entry_apply_mod_wsi used to check if the
entry extension was configured properly and the attribute
existed in the extension, first. If both were not satisfied,
the attribute was not removed from the attribute list.
This patch eliminated the check and the attribute to be stored
in the entry extension is always removed from the attribute
list in the entry.
Reviewed by Nathan (Thank you!!)
https://fedorahosted.org/389/ticket/402
diff --git a/ldap/servers/slapd/entrywsi.c b/ldap/servers/slapd/entrywsi.c
index 00de193..200743d 100644
--- a/ldap/servers/slapd/entrywsi.c
+++ b/ldap/servers/slapd/entrywsi.c
@@ -952,27 +952,24 @@ entry_apply_mod_wsi(Slapi_Entry *e, const LDAPMod *mod, const CSN *csn, int urp)
for (aiep = attrs_in_extension; aiep && aiep->ext_type; aiep++) {
if (0 == strcasecmp(mod->mod_type, aiep->ext_type)) {
Slapi_Attr *a;
- int rc;
- Slapi_Value **ext_vals = NULL;
- rc = slapi_pw_get_entry_ext(e, &ext_vals);
- if (rc) {
- continue; /* skip it. */
- }
+ /* remove the attribute from the attr list */
a = attrlist_remove(&e->e_attrs, mod->mod_type);
if (a && a->a_present_values.va) {
/* a->a_present_values.va is consumed if successful. */
- rc = slapi_pw_set_entry_ext(e, a->a_present_values.va,
- SLAPI_EXT_SET_REPLACE);
+ int rc = slapi_pw_set_entry_ext(e, a->a_present_values.va,
+ SLAPI_EXT_SET_REPLACE);
if (LDAP_SUCCESS == rc) {
/* va is set to entry extension; just release the rest */
a->a_present_values.va = NULL;
}
slapi_attr_free(&a);
} else {
+ Slapi_Value **ext_vals = NULL;
+ slapi_pw_get_entry_ext(e, &ext_vals);
if (ext_vals) {
/* slapi_pw_set_entry_ext frees the stored extension */
- rc = slapi_pw_set_entry_ext(e, NULL, SLAPI_EXT_SET_REPLACE);
+ slapi_pw_set_entry_ext(e, NULL, SLAPI_EXT_SET_REPLACE);
ext_vals = NULL;
}
}
10 years, 10 months
ldap/admin
by Richard Allen Megginson
ldap/admin/src/logconv.pl | 1650 ++++++++++++++++++----------------------------
1 file changed, 665 insertions(+), 985 deletions(-)
New commits:
commit 0d97d630df4999db609ff08238c442dfc390473f
Author: Rich Megginson <rmeggins(a)redhat.com>
Date: Mon Jun 10 20:04:20 2013 -0600
Ticket #47387 - improve logconv.pl performance with large access logs
https://fedorahosted.org/389/ticket/47387
Reviewed by: mreynolds (Thanks!)
Branch: master
Fix Description: The primary fix is to use tied hashes and arrays backed by
DB_File database files. Hashes use DB_HASH and arrays use DB_RECNO. These
fixes cut down the time by a factor of 10 or more, and considerably reduce
the size of the disk files. There is still room for optimization as given
by the Devel::NYTProf package, but this should at least give us acceptable
performance.
I also did some perl "linting" - running with use warnings and use strict -
which revealed a lot of code which was cleaned up.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
diff --git a/ldap/admin/src/logconv.pl b/ldap/admin/src/logconv.pl
index bac28ef..bfca678 100755
--- a/ldap/admin/src/logconv.pl
+++ b/ldap/admin/src/logconv.pl
@@ -43,9 +43,14 @@
#
# Check for usage
#
+use strict;
+use warnings;
+use warnings 'untie';
use Time::Local;
use IO::File;
use Getopt::Long;
+use DB_File;
+use sigtrap qw(die normal-signals);
Getopt::Long::Configure ("bundling");
Getopt::Long::Configure ("permute");
@@ -60,19 +65,43 @@ if ($#ARGV < 0){;
# #
#######################################
-$file_count = 0;
-$arg_count = 0;
-$logversion = "7.0";
-$sizeCount = "20";
-$startFlag = 0;
-$startTime = 0;
-$endFlag = 0;
-$endTime = 0;
-$reportStats = "";
-$dataLocation = "/tmp";
-$startTLSoid = "1.3.6.1.4.1.1466.20037";
-$s_stats = new_stats_block( );
-$m_stats = new_stats_block( );
+my $file_count = 0;
+my $arg_count = 0;
+my $logversion = "7.0";
+my $sizeCount = "20";
+my $startFlag = 0;
+my $startTime = 0;
+my $endFlag = 0;
+my $endTime = 0;
+my $reportStats = "";
+my $dataLocation = "/tmp";
+my $startTLSoid = "1.3.6.1.4.1.1466.20037";
+my $s_stats = new_stats_block( );
+my $m_stats = new_stats_block( );
+my $verb = "no";
+my @excludeIP;
+my $xi = 0;
+my $bindReportDN;
+my $usage = "";
+my @latency;
+my @openConnection;
+my @errorCode;
+my @errtext;
+my @errornum;
+my @errornum2;
+my $ds6x = "false";
+my $connCodeCount = 0;
+my %connList;
+my %bindReport;
+my @vlvconn;
+my @vlvop;
+my @start_time_of_connection;
+my @end_time_of_connection;
+my @fds;
+my $fdds = 0;
+my $reportBinds = "no";
+my $rootDN = "";
+my $needCleanup = 0;
GetOptions(
'd|rootDN=s' => \$rootDN,
@@ -129,6 +158,7 @@ if($rootDN eq ""){
#
# get the logs
#
+my @files = ();
while($arg_count <= $#ARGV){
$files[$file_count] = $ARGV[$arg_count];
$file_count++;
@@ -155,127 +185,93 @@ if ($sizeCount eq "all"){$sizeCount = "100000";}
print "\nAccess Log Analyzer $logversion\n";
print "\nCommand: logconv.pl @ARGV\n\n";
-$rootDNBindCount = 0;
-$anonymousBindCount = 0;
-$unindexedSrchCountNotesA = 0;
-$unindexedSrchCountNotesU = 0;
-$vlvNotesACount= 0;
-$vlvNotesUCount= 0;
-$srchCount = 0;
-$fdTaken = 0;
-$fdReturned = 0;
-$highestFdTaken = 0;
-$unbindCount = 0;
-$cmpCount = 0;
-$modCount = 0;
-$delCount = 0;
-$addCount = 0;
-$modrdnCount = 0;
-$abandonCount = 0;
-$extopCount = 0;
-$vlvCount = 0;
-$errorCount = 0;
-$proxiedAuthCount = 0;
-$serverRestartCount = 0;
-$resourceUnavailCount = 0;
-$brokenPipeCount = 0;
-$v2BindCount = 0;
-$v3BindCount = 0;
-$vlvSortCount = 0;
-$connResetByPeerCount = 0;
-$isVlvNotes = 0;
-$successCount = 0;
-$sslCount = 0;
-$sslClientBindCount = 0;
-$sslClientFailedCount = 0;
-$objectclassTopCount= 0;
-$pagedSearchCount = 0;
-$bindCount = 0;
-$filterCount = 0;
-$baseCount = 0;
-$scopeCount = 0;
-$allOps = 0;
-$allResults = 0;
-$badPwdCount = 0;
-$saslBindCount = 0;
-$internalOpCount = 0;
-$entryOpCount = 0;
-$referralCount = 0;
-$anyAttrs = 0;
-$persistentSrchCount = 0;
-$maxBerSizeCount = 0;
-$connectionCount = 0;
-$timerange = 0;
-$simConnection = 0;
-$maxsimConnection = 0;
-$firstFile = 1;
-$elapsedDays = 0;
-$logCount = 0;
-$startTLSCount = 0;
-$ldapiCount = 0;
-$autobindCount = 0;
-$limit = 25000; # number of lines processed to trigger output
-
-# hash files
-$ATTR = "$dataLocation/attr.logconv";
-$RC = "$dataLocation/rc.logconv";
-$SRC = "$dataLocation/src.logconv";
-$RSRC = "$dataLocation/rsrc.logconv";
-$EXCOUNT = "$dataLocation/excount.logconv";
-$CONN_HASH = "$dataLocation/conn_hash.logconv";
-$IP_HASH = "$dataLocation/ip_hash.logconv";
-$CONNCOUNT = "$dataLocation/conncount.logconv";
-$NENTRIES = "$dataLocation/nentries.logconv";
-$FILTER = "$dataLocation/filter.logconv";
-$BASE = "$dataLocation/base.logconv";
-$DS6XBADPWD = "$dataLocation/ds6xbadpwd.logconv";
-$SASLMECH = "$dataLocation/saslmech.logconv";
-$BINDLIST = "$dataLocation/bindlist.logconv";
-$ETIME = "$dataLocation/etime.logconv";
-$OID = "$dataLocation/oid.logconv";
-
-# array files
-$SRCH_CONN = "$dataLocation/srchconn.logconv";
-$SRCH_OP = "$dataLocation/srchop.logconv";
-$DEL_CONN = "$dataLocation/delconn.logconv";
-$DEL_OP = "$dataLocation/delop.logconv";
-$MOD_CONN = "$dataLocation/modconn.logconv";
-$MOD_OP = "$dataLocation/modop.logconv";
-$ADD_CONN = "$dataLocation/addconn.logconv";
-$ADD_OP = "$dataLocation/addop.logconv";
-$MODRDN_CONN = "$dataLocation/modrdnconn.logconv";
-$MODRDN_OP = "$dataLocation/modrdnop.logconv";
-$CMP_CONN = "$dataLocation/cmpconn.logconv";
-$CMP_OP = "$dataLocation/cmpop.logconv";
-$TARGET_CONN = "$dataLocation/targetconn.logconv";
-$TARGET_OP = "$dataLocation/targetop.logconv";
-$MSGID = "$dataLocation/msgid.logconv";
-$BIND_CONN = "$dataLocation/bindconn.logconv";
-$BIND_OP = "$dataLocation/bindop.logconv";
-$UNBIND_CONN = "$dataLocation/unbindconn.logconv";
-$UNBIND_OP = "$dataLocation/unbindop.logconv";
-$EXT_CONN = "$dataLocation/extconn.logconv";
-$EXT_OP = "$dataLocation/extop.logconv";
-$NOTES_A_ETIME = "$dataLocation/notesAetime.logconv";
-$NOTES_A_CONN = "$dataLocation/notesAconn.logconv";
-$NOTES_A_OP = "$dataLocation/notesAop.logconv";
-$NOTES_A_TIME = "$dataLocation/notesAtime.logconv";
-$NOTES_A_NENTRIES = "$dataLocation/notesAnentries.logconv";
-$NOTES_U_ETIME = "$dataLocation/notesUetime.logconv";
-$NOTES_U_CONN = "$dataLocation/notesUconn.logconv";
-$NOTES_U_OP = "$dataLocation/notesUop.logconv";
-$NOTES_U_TIME = "$dataLocation/notesUtime.logconv";
-$NOTES_U_NENTRIES = "$dataLocation/notesUnentries.logconv";
-$BADPWDCONN = "$dataLocation/badpwdconn.logconv";
-$BADPWDOP = "$dataLocation/badpwdop.logconv";
-$BADPWDIP = "$dataLocation/badpwdip.logconv";
-
-# info files
-$BINDINFO = "$dataLocation/bindinfo.logconv";
-$BASEINFO = "$dataLocation/baseinfo.logconv";
-$FILTERINFO = "$dataLocation/filterinfo.logconv";
-$SCOPEINFO = "$dataLocation/scopeinfo.logconv";
-
+my $rootDNBindCount = 0;
+my $anonymousBindCount = 0;
+my $unindexedSrchCountNotesA = 0;
+my $unindexedSrchCountNotesU = 0;
+my $vlvNotesACount= 0;
+my $vlvNotesUCount= 0;
+my $srchCount = 0;
+my $fdTaken = 0;
+my $fdReturned = 0;
+my $highestFdTaken = 0;
+my $unbindCount = 0;
+my $cmpCount = 0;
+my $modCount = 0;
+my $delCount = 0;
+my $addCount = 0;
+my $modrdnCount = 0;
+my $abandonCount = 0;
+my $extopCount = 0;
+my $vlvCount = 0;
+my $errorCount = 0;
+my $proxiedAuthCount = 0;
+my $serverRestartCount = 0;
+my $resourceUnavailCount = 0;
+my $brokenPipeCount = 0;
+my $v2BindCount = 0;
+my $v3BindCount = 0;
+my $vlvSortCount = 0;
+my $connResetByPeerCount = 0;
+my $isVlvNotes = 0;
+my $successCount = 0;
+my $sslCount = 0;
+my $sslClientBindCount = 0;
+my $sslClientFailedCount = 0;
+my $objectclassTopCount= 0;
+my $pagedSearchCount = 0;
+my $bindCount = 0;
+my $filterCount = 0;
+my $baseCount = 0;
+my $scopeCount = 0;
+my $allOps = 0;
+my $allResults = 0;
+my $badPwdCount = 0;
+my $saslBindCount = 0;
+my $internalOpCount = 0;
+my $entryOpCount = 0;
+my $referralCount = 0;
+my $anyAttrs = 0;
+my $persistentSrchCount = 0;
+my $maxBerSizeCount = 0;
+my $connectionCount = 0;
+my $timerange = 0;
+my $simConnection = 0;
+my $maxsimConnection = 0;
+my $firstFile = 1;
+my $elapsedDays = 0;
+my $logCount = 0;
+my $startTLSCount = 0;
+my $ldapiCount = 0;
+my $autobindCount = 0;
+my $limit = 25000; # number of lines processed to trigger output
+
+my @removefiles = ();
+
+my @conncodes = qw(A1 B1 B4 T1 T2 B2 B3 R1 P1 P2 U1);
+my %conn = ();
+map {$conn{$_} = $_} @conncodes;
+
+# hash db-backed hashes
+my @hashnames = qw(attr rc src rsrc excount conn_hash ip_hash conncount nentries
+ filter base ds6xbadpwd saslmech bindlist etime oid);
+# need per connection code ip address counts - so use a hash table
+# for each connection code - key is ip, val is count
+push @hashnames, @conncodes;
+my $hashes = openHashFiles($dataLocation, @hashnames);
+
+# recno db-backed arrays/lists
+my @arraynames = qw(srchconn srchop delconn delop modconn modop addconn addop modrdnconn modrdnop
+ cmpconn cmpop targetconn targetop msgid bindconn bindop binddn unbindconn unbindop
+ extconn extop notesAetime notesAconn notesAop notesAtime notesAnentries
+ notesUetime notesUconn notesUop notesUtime notesUnentries badpwdconn
+ badpwdop badpwdip baseval baseconn baseop scopeval scopeconn scopeop
+ filterval filterconn filterop);
+my $arrays = openArrayFiles($dataLocation, @arraynames);
+
+$needCleanup = 1;
+
+my @err;
$err[0] = "Successful Operations\n";
$err[1] = "Operations Error(s)\n";
$err[2] = "Protocal Errors\n";
@@ -338,19 +334,7 @@ $err[95] = "More Results To Return\n";
$err[96] = "Client Loop\n";
$err[97] = "Referral Limit Exceeded\n";
-
-$conn{"A1"} = "A1";
-$conn{"B1"} = "B1";
-$conn{"B4"} = "B4";
-$conn{"T1"} = "T1";
-$conn{"T2"} = "T2";
-$conn{"B2"} = "B2";
-$conn{"B3"} = "B3";
-$conn{"R1"} = "R1";
-$conn{"P1"} = "P1";
-$conn{"P2"} = "P2";
-$conn{"U1"} = "U1";
-
+my %connmsg;
$connmsg{"A1"} = "Client Aborted Connections";
$connmsg{"B1"} = "Bad Ber Tag Encountered";
$connmsg{"B4"} = "Server failed to flush data (response) back to Client";
@@ -363,7 +347,7 @@ $connmsg{"P1"} = "Plugin";
$connmsg{"P2"} = "Poll";
$connmsg{"U1"} = "Cleanly Closed Connections";
-%monthname = (
+my %monthname = (
"Jan" => 0,
"Feb" => 1,
"Mar" => 2,
@@ -379,7 +363,17 @@ $connmsg{"U1"} = "Cleanly Closed Connections";
);
-openDataFiles();
+my $linesProcessed;
+my $lineBlockCount;
+my $cursize = 0;
+sub statusreport {
+ if ($lineBlockCount > $limit) {
+ my $curpos = tell(LOG);
+ my $percent = $curpos/$cursize*100.0;
+ print sprintf "%10d Lines Processed %12d of %12d bytes (%.3f%%)\n",--$linesProcessed,$curpos,$cursize,$percent;
+ $lineBlockCount = 0;
+ }
+}
##########################################
# #
@@ -394,6 +388,7 @@ print "Processing $file_count Access Log(s)...\n\n";
#print "Filename\t\t\t Total Lines\n";
#print "--------------------------------------------------\n";
+my $skipFirstFile = 0;
if ($file_count > 1 && $files[0] =~ /\/access$/){
$files[$file_count] = $files[0];
$file_count++;
@@ -401,25 +396,30 @@ if ($file_count > 1 && $files[0] =~ /\/access$/){
}
$logCount = $file_count;
-for ($count=0; $count < $file_count; $count++){
+my $logline;
+my $totalLineCount = 0;
+
+for (my $count=0; $count < $file_count; $count++){
# we moved access to the end of the list, so if its the first file skip it
if($file_count > 1 && $count == 0 && $skipFirstFile == 1){
next;
}
- $logsize = `wc -l $files[$count]`;
- $logsize =~ /([0-9]+)/;
$linesProcessed = 0; $lineBlockCount = 0;
$logCount--;
+ my $logCountStr;
if($logCount < 10 ){
# add a zero for formatting purposes
$logCountStr = "0" . $logCount;
} else {
$logCountStr = $logCount;
}
- print sprintf "[%s] %-30s\tlines: %7s\n",$logCountStr, $files[$count], $1;
+ my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$atime,$mtime,$ctime,$blksize,$blocks);
+ ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$cursize,
+ $atime,$mtime,$ctime,$blksize,$blocks) = stat($files[$count]);
+ print sprintf "[%s] %-30s\tsize (bytes): %12s\n",$logCountStr, $files[$count], $cursize;
open(LOG,"$files[$count]") or do { openFailed($!, $files[$count]) };
- $firstline = "yes";
+ my $firstline = "yes";
while(<LOG>){
unless ($endFlag) {
if ($firstline eq "yes"){
@@ -442,7 +442,7 @@ for ($count=0; $count < $file_count; $count++){
print_stats_block( $s_stats );
print_stats_block( $m_stats );
$totalLineCount = $totalLineCount + $linesProcessed;
- if($linesProcessed => $limit){print sprintf " %10s Lines Processed\n\n",--$linesProcessed;}
+ statusreport();
}
print "\n\nTotal Log Lines Analysed: " . ($totalLineCount - 1) . "\n";
@@ -457,9 +457,11 @@ $allOps = $srchCount + $modCount + $addCount + $cmpCount + $delCount + $modrdnCo
# if we are using startTime & endTime then we need to clean it up for our processing
+my $start;
if($startTime){
if ($start =~ / *([0-9a-z:\/]+)/i){$start=$1;}
}
+my $end;
if($endTime){
if ($end =~ / *([0-9a-z:\/]+)/i){$end =$1;}
}
@@ -468,8 +470,10 @@ if($endTime){
# Get the start time in seconds
#
-$logStart = $start;
-
+my $logStart = $start;
+my $logDate;
+my @dateComps;
+my ($timeMonth, $timeDay, $timeYear, $dateTotal);
if ($logStart =~ / *([0-9A-Z\/]+)/i ){
$logDate = $1;
@dateComps = split /\//, $logDate;
@@ -481,6 +485,9 @@ if ($logStart =~ / *([0-9A-Z\/]+)/i ){
$dateTotal = $timeMonth + $timeDay + $timeYear;
}
+my $logTime;
+my @timeComps;
+my ($timeHour, $timeMinute, $timeSecond, $timeTotal);
if ($logStart =~ / *(:[0-9:]+)/i ){
$logTime = $1;
@timeComps = split /:/, $logTime;
@@ -491,14 +498,14 @@ if ($logStart =~ / *(:[0-9:]+)/i ){
$timeTotal = $timeHour + $timeMinute + $timeSecond;
}
-$startTotal = $timeTotal + $dateTotal;
+my $startTotal = $timeTotal + $dateTotal;
#
# Get the end time in seconds
#
-$logEnd = $end;
-
+my $logEnd = $end;
+my ($endDay, $endMonth, $endYear, $endTotal);
if ($logEnd =~ / *([0-9A-Z\/]+)/i ){
$logDate = $1;
@dateComps = split /\//, $logDate;
@@ -506,10 +513,11 @@ if ($logEnd =~ / *([0-9A-Z\/]+)/i ){
$endDay = $dateComps[0] *3600 * 24;
$endMonth = 1 + $monthname{$dateComps[1]};
$endMonth = $endMonth * 3600 * 24 * 30;
- $endYear = $endTotal + $dateComps[2] *365 * 3600 * 24 ;
+ $endYear = $dateComps[2] *365 * 3600 * 24 ;
$dateTotal = $endDay + $endMonth + $endYear;
}
+my ($endHour, $endMinute, $endSecond);
if ($logEnd =~ / *(:[0-9:]+)/i ){
$logTime = $1;
@timeComps = split /:/, $logTime;
@@ -525,8 +533,8 @@ $endTotal = $timeTotal + $dateTotal;
#
# Tally the numbers
#
-$totalTimeInSecs = $endTotal - $startTotal;
-$remainingTimeInSecs = $totalTimeInSecs;
+my $totalTimeInSecs = $endTotal - $startTotal;
+my $remainingTimeInSecs = $totalTimeInSecs;
#
# Calculate the elapsed time
@@ -540,33 +548,21 @@ while(($remainingTimeInSecs - 86400) > 0){
}
# hours
+my $elapsedHours = 0;
while(($remainingTimeInSecs - 3600) > 0){
$elapsedHours++;
$remainingTimeInSecs = $remainingTimeInSecs - 3600;
}
# minutes
+my $elapsedMinutes = 0;
while($remainingTimeInSecs - 60 > 0){
$elapsedMinutes++;
$remainingTimeInSecs = $remainingTimeInSecs - 60;
}
# seconds
-$elapsedSeconds = $remainingTimeInSecs;
-
-# Initialize empty values
-if($elapsedHours eq ""){
- $elapsedHours = "0";
-}
-if($elapsedMinutes eq ""){
- $elapsedMinutes = "0";
-}
-if($elapsedSeconds eq ""){
- $elapsedSeconds = "0";
-}
-
-&closeDataFiles();
-
+my $elapsedSeconds = $remainingTimeInSecs;
#####################################
# #
@@ -605,20 +601,21 @@ print " - LDAPI Conections: $ldapiCount\n";
print "Peak Concurrent Connections: $maxsimConnection\n";
print "Total Operations: $allOps\n";
print "Total Results: $allResults\n";
+my ($perf, $tmp);
if ($allOps ne "0"){
- print sprintf "Overall Performance: %.1f%\n\n" , ($perf = ($tmp = ($allResults / $allOps)*100) > 100 ? 100.0 : $tmp) ;
+ print sprintf "Overall Performance: %.1f%%\n\n" , ($perf = ($tmp = ($allResults / $allOps)*100) > 100 ? 100.0 : $tmp) ;
}
else {
print "Overall Performance: No Operations to evaluate\n\n";
}
-$searchStat = sprintf "(%.2f/sec) (%.2f/min)\n",($srchCount / $totalTimeInSecs), $srchCount / ($totalTimeInSecs/60);
-$modStat = sprintf "(%.2f/sec) (%.2f/min)\n",$modCount / $totalTimeInSecs, $modCount/($totalTimeInSecs/60);
-$addStat = sprintf "(%.2f/sec) (%.2f/min)\n",$addCount/$totalTimeInSecs, $addCount/($totalTimeInSecs/60);
-$deleteStat = sprintf "(%.2f/sec) (%.2f/min)\n",$delCount/$totalTimeInSecs, $delCount/($totalTimeInSecs/60);
-$modrdnStat = sprintf "(%.2f/sec) (%.2f/min)\n",$modrdnCount/$totalTimeInSecs, $modrdnCount/($totalTimeInSecs/60);
-$compareStat = sprintf "(%.2f/sec) (%.2f/min)\n",$cmpCount/$totalTimeInSecs, $cmpCount/($totalTimeInSecs/60);
-$bindCountStat = sprintf "(%.2f/sec) (%.2f/min)\n",$bindCount/$totalTimeInSecs, $bindCount/($totalTimeInSecs/60);
+my $searchStat = sprintf "(%.2f/sec) (%.2f/min)\n",($srchCount / $totalTimeInSecs), $srchCount / ($totalTimeInSecs/60);
+my $modStat = sprintf "(%.2f/sec) (%.2f/min)\n",$modCount / $totalTimeInSecs, $modCount/($totalTimeInSecs/60);
+my $addStat = sprintf "(%.2f/sec) (%.2f/min)\n",$addCount/$totalTimeInSecs, $addCount/($totalTimeInSecs/60);
+my $deleteStat = sprintf "(%.2f/sec) (%.2f/min)\n",$delCount/$totalTimeInSecs, $delCount/($totalTimeInSecs/60);
+my $modrdnStat = sprintf "(%.2f/sec) (%.2f/min)\n",$modrdnCount/$totalTimeInSecs, $modrdnCount/($totalTimeInSecs/60);
+my $compareStat = sprintf "(%.2f/sec) (%.2f/min)\n",$cmpCount/$totalTimeInSecs, $cmpCount/($totalTimeInSecs/60);
+my $bindCountStat = sprintf "(%.2f/sec) (%.2f/min)\n",$bindCount/$totalTimeInSecs, $bindCount/($totalTimeInSecs/60);
format STDOUT =
Searches: @<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<
@@ -634,7 +631,7 @@ Mod RDNs: @<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<
Compares: @<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<
$cmpCount, $compareStat
Binds: @<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<
- $bindCount $bindCountStat
+ $bindCount, $bindCountStat
.
write STDOUT;
@@ -658,148 +655,110 @@ print "Unindexed Searches: $unindexedSrchCountNotesA\n";
print "Unindexed Components: $unindexedSrchCountNotesU\n";
if ($verb eq "yes" || $usage =~ /u/){
if ($unindexedSrchCountNotesA > 0){
- %conn_hash = getHashFromFile($CONN_HASH);
- @notesConn = getArrayFromFile($NOTES_A_CONN);
- @notesOp = getArrayFromFile($NOTES_A_OP);
- @notesEtime = getArrayFromFile($NOTES_A_ETIME);
- @notesTime = getArrayFromFile($NOTES_A_TIME);
- @notesNentries = getArrayFromFile($NOTES_A_NENTRIES);
- getInfoArraysFromFile($BASEINFO);
- @base_val = @fileArray1;
- @base_conn = @fileArray2;
- @base_op = @fileArray3;
- getInfoArraysFromFile($SCOPEINFO);
- @scope_val = @fileArray1;
- @scope_conn = @fileArray2;
- @scope_op = @fileArray3;
- getInfoArraysFromFile($FILTERINFO);
- @filter_val = @fileArray1;
- @filter_conn = @fileArray2;
- @filter_op = @fileArray3;
-
- $notesCount = "1";
- for ($n = 0; $n <= $#notesEtime; $n++){
- @alreadyseenDN = ();
- if($conn_hash{$notesConn[$n]} eq ""){
+ my $conn_hash = $hashes->{conn_hash};
+ my $notesConn = $arrays->{notesAconn};
+ my $notesOp = $arrays->{notesAop};
+ my $notesEtime = $arrays->{notesAetime};
+ my $notesTime = $arrays->{notesAtime};
+ my $notesNentries = $arrays->{notesAnentries};
+ my $base_val = $arrays->{baseval};
+ my $base_conn = $arrays->{baseconn};
+ my $base_op = $arrays->{baseop};
+ my $scope_val = $arrays->{scopeval};
+ my $scope_conn = $arrays->{scopeconn};
+ my $scope_op = $arrays->{scopeop};
+ my $filter_val = $arrays->{filterval};
+ my $filter_conn = $arrays->{filterconn};
+ my $filter_op = $arrays->{filterop};
+
+ my $notesCount = "1";
+ my $unindexedIp;
+ for (my $n = 0; $n <= scalar(@{$notesEtime}); $n++){
+ if($conn_hash->{$notesConn->[$n]} eq ""){
$unindexedIp = "?";
} else {
- $unindexedIp = $conn_hash{$notesConn[$n]};
+ $unindexedIp = $conn_hash->{$notesConn->[$n]};
}
print "\n Unindexed Search #".$notesCount."\n"; $notesCount++;
- print " - Date/Time: $notesTime[$n]\n";
- print " - Connection Number: $notesConn[$n]\n";
- print " - Operation Number: $notesOp[$n]\n";
- print " - Etime: $notesEtime[$n]\n";
- print " - Nentries: $notesNentries[$n]\n";
+ print " - Date/Time: $notesTime->[$n]\n";
+ print " - Connection Number: $notesConn->[$n]\n";
+ print " - Operation Number: $notesOp->[$n]\n";
+ print " - Etime: $notesEtime->[$n]\n";
+ print " - Nentries: $notesNentries->[$n]\n";
print " - IP Address: $unindexedIp\n";
- for ($nnn = 0; $nnn < $baseCount; $nnn++){
- if ($notesConn[$n] eq $base_conn[$nnn] && $notesOp[$n] eq $base_op[$nnn]){
- print " - Search Base: $base_val[$nnn]\n";
+ for (my $nnn = 0; $nnn < $baseCount; $nnn++){
+ if ($notesConn->[$n] eq $base_conn->[$nnn] && $notesOp->[$n] eq $base_op->[$nnn]){
+ print " - Search Base: $base_val->[$nnn]\n";
last;
}
}
- for ($nnn = 0; $nnn < $scopeCount; $nnn++){
- if ($notesConn[$n] eq $scope_conn[$nnn] && $notesOp[$n] eq $scope_op[$nnn]){
- print " - Search Scope: $scope_val[$nnn]\n";
+ for (my $nnn = 0; $nnn < $scopeCount; $nnn++){
+ if ($notesConn->[$n] eq $scope_conn->[$nnn] && $notesOp->[$n] eq $scope_op->[$nnn]){
+ print " - Search Scope: $scope_val->[$nnn]\n";
last;
}
}
- for ($nnn = 0; $nnn < $filterCount; $nnn++){
- if ($notesConn[$n] eq $filter_conn[$nnn] && $notesOp[$n] eq $filter_op[$nnn]){
- print " - Search Filter: $filter_val[$nnn]\n";
+ for (my $nnn = 0; $nnn < $filterCount; $nnn++){
+ if ($notesConn->[$n] eq $filter_conn->[$nnn] && $notesOp->[$n] eq $filter_op->[$nnn]){
+ print " - Search Filter: $filter_val->[$nnn]\n";
last;
}
}
}
- undef %conn_hash;
- undef @notesConn;
- undef @notesOp;
- undef @notesEtime;
- undef @notesTime;
- undef @notesNentries;
- undef @notesIp;
- undef @filter_val;
- undef @filter_conn;
- undef @filter_op;
- undef @base_val;
- undef @base_conn;
- undef @base_op;
- undef @scope_val;
- undef @scope_conn;
- undef @scope_op;
}
if ($unindexedSrchCountNotesU > 0){
- %conn_hash = getHashFromFile($CONN_HASH);
- @notesConn = getArrayFromFile($NOTES_U_CONN);
- @notesOp = getArrayFromFile($NOTES_U_OP);
- @notesEtime = getArrayFromFile($NOTES_U_ETIME);
- @notesTime = getArrayFromFile($NOTES_U_TIME);
- @notesNentries = getArrayFromFile($NOTES_U_NENTRIES);
- getInfoArraysFromFile($BASEINFO);
- @base_val = @fileArray1;
- @base_conn = @fileArray2;
- @base_op = @fileArray3;
- getInfoArraysFromFile($SCOPEINFO);
- @scope_val = @fileArray1;
- @scope_conn = @fileArray2;
- @scope_op = @fileArray3;
- getInfoArraysFromFile($FILTERINFO);
- @filter_val = @fileArray1;
- @filter_conn = @fileArray2;
- @filter_op = @fileArray3;
-
- $notesCount = "1";
- for ($n = 0; $n <= $#notesEtime; $n++){
- @alreadyseenDN = ();
- if($conn_hash{$notesConn[$n]} eq ""){
+ my $conn_hash = $hashes->{conn_hash};
+ my $notesConn = $arrays->{notesUconn};
+ my $notesOp = $arrays->{notesUop};
+ my $notesEtime = $arrays->{notesUetime};
+ my $notesTime = $arrays->{notesUtime};
+ my $notesNentries = $arrays->{notesUnentries};
+ my $base_val = $arrays->{baseval};
+ my $base_conn = $arrays->{baseconn};
+ my $base_op = $arrays->{baseop};
+ my $scope_val = $arrays->{scopeval};
+ my $scope_conn = $arrays->{scopeconn};
+ my $scope_op = $arrays->{scopeop};
+ my $filter_val = $arrays->{filterval};
+ my $filter_conn = $arrays->{filterconn};
+ my $filter_op = $arrays->{filterop};
+
+ my $notesCount = "1";
+ my $unindexedIp;
+ for (my $n = 0; $n <= scalar(@{$notesEtime}); $n++){
+ if($conn_hash->{$notesConn->[$n]} eq ""){
$unindexedIp = "?";
} else {
- $unindexedIp = $conn_hash{$notesConn[$n]};
+ $unindexedIp = $conn_hash->{$notesConn->[$n]};
}
print "\n Unindexed Components #".$notesCount."\n"; $notesCount++;
- print " - Date/Time: $notesTime[$n]\n";
- print " - Connection Number: $notesConn[$n]\n";
- print " - Operation Number: $notesOp[$n]\n";
- print " - Etime: $notesEtime[$n]\n";
- print " - Nentries: $notesNentries[$n]\n";
+ print " - Date/Time: $notesTime->[$n]\n";
+ print " - Connection Number: $notesConn->[$n]\n";
+ print " - Operation Number: $notesOp->[$n]\n";
+ print " - Etime: $notesEtime->[$n]\n";
+ print " - Nentries: $notesNentries->[$n]\n";
print " - IP Address: $unindexedIp\n";
- for ($nnn = 0; $nnn < $baseCount; $nnn++){
- if ($notesConn[$n] eq $base_conn[$nnn] && $notesOp[$n] eq $base_op[$nnn]){
- print " - Search Base: $base_val[$nnn]\n";
+ for (my $nnn = 0; $nnn < $baseCount; $nnn++){
+ if ($notesConn->[$n] eq $base_conn->[$nnn] && $notesOp->[$n] eq $base_op->[$nnn]){
+ print " - Search Base: $base_val->[$nnn]\n";
last;
}
}
- for ($nnn = 0; $nnn < $scopeCount; $nnn++){
- if ($notesConn[$n] eq $scope_conn[$nnn] && $notesOp[$n] eq $scope_op[$nnn]){
- print " - Search Scope: $scope_val[$nnn]\n";
+ for (my $nnn = 0; $nnn < $scopeCount; $nnn++){
+ if ($notesConn->[$n] eq $scope_conn->[$nnn] && $notesOp->[$n] eq $scope_op->[$nnn]){
+ print " - Search Scope: $scope_val->[$nnn]\n";
last;
}
}
- for ($nnn = 0; $nnn < $filterCount; $nnn++){
- if ($notesConn[$n] eq $filter_conn[$nnn] && $notesOp[$n] eq $filter_op[$nnn]){
- print " - Search Filter: $filter_val[$nnn]\n";
+ for (my $nnn = 0; $nnn < $filterCount; $nnn++){
+ if ($notesConn->[$n] eq $filter_conn->[$nnn] && $notesOp->[$n] eq $filter_op->[$nnn]){
+ print " - Search Filter: $filter_val->[$nnn]\n";
last;
}
}
}
- undef %conn_hash;
- undef @notesConn;
- undef @notesOp;
- undef @notesEtime;
- undef @notesTime;
- undef @notesNentries;
- undef @notesIp;
- undef @filter_val;
- undef @filter_conn;
- undef @filter_op;
- undef @base_val;
- undef @base_conn;
- undef @base_op;
- undef @scope_val;
- undef @scope_conn;
- undef @scope_op;
}
} # end of unindexed search report
@@ -809,10 +768,12 @@ print "FDs Returned: $fdReturned\n";
print "Highest FD Taken: $highestFdTaken\n\n";
print "Broken Pipes: $brokenPipeCount\n";
if ($brokenPipeCount > 0){
- foreach $key (sort { $rc{$b} <=> $rc{$a} } keys %rc) {
- if ($rc{$key} > 0){
+ my $rc = $hashes->{rc};
+ my @etext;
+ foreach my $key (sort { $rc->{$b} <=> $rc->{$a} } keys %{$rc}) {
+ if ($rc->{$key} > 0){
if ($conn{$key} eq ""){$conn{$key} = "**Unknown**";}
- push @etext, sprintf " - %-4s (%2s) %-40s\n",$rc{$key},$conn{$key},$connmsg{$key
+ push @etext, sprintf " - %-4s (%2s) %-40s\n",$rc->{$key},$conn{$key},$connmsg{$key
};
}
}
@@ -822,10 +783,12 @@ if ($brokenPipeCount > 0){
print "Connections Reset By Peer: $connResetByPeerCount\n";
if ($connResetByPeerCount > 0){
- foreach $key (sort { $src{$b} <=> $src{$a} } keys %src) {
- if ($src{$key} > 0){
+ my $src = $hashes->{src};
+ my @retext;
+ foreach my $key (sort { $src->{$b} <=> $src->{$a} } keys %{$src}) {
+ if ($src->{$key} > 0){
if ($conn{$key} eq ""){$conn{$key} = "**Unknown**";}
- push @retext, sprintf " - %-4s (%2s) %-40s\n",$src{$key},$conn{$key},$connmsg{$key
+ push @retext, sprintf " - %-4s (%2s) %-40s\n",$src->{$key},$conn{$key},$connmsg{$key
};
}
}
@@ -835,10 +798,12 @@ if ($connResetByPeerCount > 0){
print "Resource Unavailable: $resourceUnavailCount\n";
if ($resourceUnavailCount > 0){
- foreach $key (sort { $rsrc{$b} <=> $rsrc{$a} } keys %rsrc) {
- if ($rsrc{$key} > 0){
+ my $rsrc = $hashes->{rsrc};
+ my @rtext;
+ foreach my $key (sort { $rsrc->{$b} <=> $rsrc->{$a} } keys %{$rsrc}) {
+ if ($rsrc->{$key} > 0){
if ($conn{$key} eq ""){$conn{$key} = "**Resource Issue**";}
- push @rtext, sprintf " - %-4s (%2s) %-40s\n",$rsrc{$key},$conn{$key},$connmsg{$key};
+ push @rtext, sprintf " - %-4s (%2s) %-40s\n",$rsrc->{$key},$conn{$key},$connmsg{$key};
}
}
print @rtext;
@@ -854,14 +819,15 @@ print " - SSL Client Binds: $sslClientBindCount\n";
print " - Failed SSL Client Binds: $sslClientFailedCount\n";
print " - SASL Binds: $saslBindCount\n";
if ($saslBindCount > 0){
- foreach $saslb ( sort {$saslmech{$b} <=> $saslmech{$a} } (keys %saslmech) ){
- printf " %-4s %-12s\n",$saslmech{$saslb}, $saslb;
- }
+ my $saslmech = $hashes->{saslmech};
+ foreach my $saslb ( sort {$saslmech->{$b} <=> $saslmech->{$a} } (keys %{$saslmech}) ){
+ printf " %-4s %-12s\n",$saslmech->{$saslb}, $saslb;
+ }
}
print " - Directory Manager Binds: $rootDNBindCount\n";
print " - Anonymous Binds: $anonymousBindCount\n";
-$otherBindCount = $bindCount -($rootDNBindCount + $anonymousBindCount);
+my $otherBindCount = $bindCount -($rootDNBindCount + $anonymousBindCount);
print " - Other Binds: $otherBindCount\n\n";
##########################################################################
@@ -879,8 +845,10 @@ if ($verb eq "yes" || $usage =~ /y/){
print " (in seconds)\t\t<=1\t2\t3\t4-5\t6-10\t11-15\t>15\n";
print " --------------------------------------------------------------------------\n";
print " (# of connections)\t";
- for ($i=0; $i <=$#latency; $i++) {
- print "$latency[$i]\t";
+ for (my $i=0; $i <=$#latency; $i++) {
+ if (defined($latency[$i])) {
+ print "$latency[$i]\t";
+ }
}
}
@@ -891,9 +859,9 @@ if ($verb eq "yes" || $usage =~ /y/){
###################################
if ($verb eq "yes" || $usage =~ /p/){
- if ($openConnection[0] ne ""){
+ if (@openConnection > 0){
print "\n\n----- Current Open Connection IDs ----- \n\n";
- for ($i=0; $i <= $#openConnection ; $i++) {
+ for (my $i=0; $i <= $#openConnection ; $i++) {
if ($openConnection[$i]) {
print "Conn Number: $i (" . getIPfromConn($i) . ")\n";
}
@@ -910,17 +878,16 @@ if ($verb eq "yes" || $usage =~ /p/){
if ($usage =~ /e/i || $verb eq "yes"){
print "\n\n----- Errors -----\n";
- %er = sort( {$b <=> $a} %er);
- for ($i = 0; $i<98; $i++){
- if ($err[$i] ne "" && $errorCode[$i] >0) {
+ for (my $i = 0; $i<98; $i++){
+ if (defined($err[$i]) && $err[$i] ne "" && defined($errorCode[$i]) && $errorCode[$i] >0) {
push @errtext, sprintf "%-8s %12s %-25s","err=$i",$errorCode[$i],$err[$i];
}
}
- for ($i = 0; $i < $#errtext; $i++){
- for ($ii = 0; $ii < $#errtext; $ii++){
- $yy="0";
- $zz="0";
+ for (my $i = 0; $i < $#errtext; $i++){
+ for (my $ii = 0; $ii < $#errtext; $ii++){
+ my $yy="0";
+ my $zz="0";
while ($errtext[$ii] =~ /(\w+)\s/g){
$errornum[$yy]="$1";
$yy++;
@@ -936,7 +903,7 @@ if ($usage =~ /e/i || $verb eq "yes"){
}
}
}
- for ($i = 0; $i <= $#errtext; $i++){
+ for (my $i = 0; $i <= $#errtext; $i++){
$errtext[$i] =~ s/\n//g;
print "\n" . $errtext[$i];
}
@@ -953,51 +920,44 @@ if ($verb eq "yes" || $usage =~ /f/ ){
print "\n\n----- Top $sizeCount Failed Logins ------\n\n";
if ($ds6x eq "true"){
- %ds6xbadpwd = getCounterHashFromFile($DS6XBADPWD);
- $ds6loop = 0;
- foreach $ds6bp (sort { $ds6xbadpwd{$b} <=> $ds6xbadpwd{$a} } keys %ds6xbadpwd) {
- if ($eloop > $sizeCount){ last; }
- printf "%-4s %-40s\n", $ds6xbadpwd{$ds6bp}, $ds6bp;
+ my $ds6xbadpwd = $hashes->{ds6xbadpwd};
+ my $ds6loop = 0;
+ foreach my $ds6bp (sort { $ds6xbadpwd->{$b} <=> $ds6xbadpwd->{$a} } keys %{$ds6xbadpwd}) {
+ if ($ds6loop > $sizeCount){ last; }
+ printf "%-4s %-40s\n", $ds6xbadpwd->{$ds6bp}, $ds6bp;
$ds6loop++;
}
- undef %ds6xbadpwd;
} else {
- getInfoArraysFromFile($BINDINFO);
- @bindVal = @fileArray1;
- @bindConn = @fileArray2;
- @bindOp = @fileArray3;
- @badPasswordConn = getArrayFromFile($BADPWDCONN);
- @badPasswordOp = getArrayFromFile($BADPWDOP);
- @badPasswordIp = getArrayFromFile($BADPWDIP);
- for ($ii =0 ; $ii < $badPwdCount; $ii++){
- for ($i = 0; $i < $bindCount; $i++){
- if ($badPasswordConn[$ii] eq $bindConn[$i] && $badPasswordOp[$ii] eq $bindOp[$i] ){
- $badPassword{ "$bindVal[$i]" } = $badPassword{ "$bindVal[$i]" } + 1;
+ my $bindVal = $arrays->{binddn};
+ my $bindConn = $arrays->{bindconn};
+ my $bindOp = $arrays->{bindop};
+ my $badPasswordConn = $arrays->{badpwdconn};
+ my $badPasswordOp = $arrays->{badpwdop};
+ my $badPasswordIp = $arrays->{badpwdip};
+ my %badPassword = ();
+ for (my $ii =0 ; $ii < $badPwdCount; $ii++){
+ for (my $i = 0; $i < $bindCount; $i++){
+ if ($badPasswordConn->[$ii] eq $bindConn->[$i] && $badPasswordOp->[$ii] eq $bindOp->[$i] ){
+ $badPassword{ $bindVal->[$i] }++;
}
}
}
# sort the new hash of $badPassword{}
- $bpTotal = 0;
- $bpCount = 0;
- foreach $badpw (sort {$badPassword{$b} <=> $badPassword{$a} } keys %badPassword){
+ my $bpTotal = 0;
+ my $bpCount = 0;
+ foreach my $badpw (sort {$badPassword{$b} <=> $badPassword{$a} } keys %badPassword){
if ($bpCount > $sizeCount){ last;}
$bpCount++;
$bpTotal = $bpTotal + $badPassword{"$badpw"};
printf "%-4s %-40s\n", $badPassword{"$badpw"}, $badpw;
}
print "\nFrom the IP address(s) :\n\n";
- for ($i=0; $i<$badPwdCount; $i++) {
- print "\t\t$badPasswordIp[$i]\n";
+ for (my $i=0; $i<$badPwdCount; $i++) {
+ print "\t\t$badPasswordIp->[$i]\n";
}
if ($bpTotal > $badPwdCount){
print "\n** Warning : Wrongly reported failed login attempts : ". ($bpTotal - $badPwdCount) . "\n";
}
- undef @bindVal;
- undef @bindConn;
- undef @bindOp;
- undef @badPasswordConn;
- undef @badPasswordOp;
- undef @badPasswordIp;
} # this ends the if $ds6x = true
}
}
@@ -1012,15 +972,14 @@ if ($verb eq "yes" || $usage =~ /f/ ){
if ($connCodeCount > 0){
if ($usage =~ /c/i || $verb eq "yes"){
print "\n\n----- Total Connection Codes -----\n\n";
- %conncount = &getCounterHashFromFile($CONNCOUNT);
-
- foreach $key (sort { $conncount{$b} <=> $conncount{$a} } keys %conncount) {
- if ($conncount{$key} > 0){
- push @conntext, sprintf "%-4s %6s %-40s\n",$key,$conncount{$key},$connmsg{ $key };
+ my $conncount = $hashes->{conncount};
+ my @conntext;
+ foreach my $key (sort { $conncount->{$b} <=> $conncount->{$a} } keys %{$conncount}) {
+ if ($conncount->{$key} > 0){
+ push @conntext, sprintf "%-4s %6s %-40s\n",$key,$conncount->{$key},$connmsg{ $key };
}
}
print @conntext;
- undef %conncount;
}
}
@@ -1031,35 +990,36 @@ if ($connCodeCount > 0){
########################################
if ($usage =~ /i/i || $verb eq "yes"){
- %ip_hash = getTwoDimHashFromFile($IP_HASH);
- %exCount = getCounterHashFromFile($EXCOUNT);
- @ipkeys = keys %ip_hash;
- @exxCount = keys %exCount;
- $ip_count = ($#ipkeys + 1)-($#exxCount + 1);
+ my $ip_hash = $hashes->{ip_hash};
+ my $exCount = $hashes->{excount};
+ my @ipkeys = keys %{$ip_hash};
+ my @exxCount = keys %${exCount};
+ my $ip_count = ($#ipkeys + 1)-($#exxCount + 1);
+ my $ccount = 0;
if ($ip_count > 0){
print "\n\n----- Top $sizeCount Clients -----\n\n";
print "Number of Clients: $ip_count\n\n";
- foreach $key (sort { $ip_hash{$b}{"count"} <=> $ip_hash{$a}{"count"} } keys %ip_hash) {
- $exc = "no";
+ foreach my $key (sort { $ip_hash->{$b} <=> $ip_hash->{$a} } @ipkeys) {
+ my $exc = "no";
if ($ccount > $sizeCount){ last;}
$ccount++;
- for ($xxx =0; $xxx <= $#excludeIP; $xxx++){
+ for (my $xxx =0; $xxx < $#excludeIP; $xxx++){
if ($excludeIP[$xxx] eq $key){$exc = "yes";}
}
if ($exc ne "yes"){
- if ($ip_hash{ $key }{"count"} eq ""){$ip_hash{ $key }{"count"} = "?";}
+ if ($ip_hash->{ $key } eq ""){$ip_hash->{ $key } = "?";}
printf "[%s] Client: %s\n",$ccount, $key;
- printf "%10s - Connections\n", $ip_hash{ $key }{"count"};
- foreach $code (sort { $ip_hash{ $key }{$b} <=> $ip_hash{ $key }{$a} } keys %{$ip_hash{ $key }}) {
+ printf "%10s - Connections\n", $ip_hash->{ $key };
+ my %counts;
+ map { $counts{$_} = $hashes->{$_}->{$key} if (defined($hashes->{$_}->{$key})) } @conncodes;
+ foreach my $code (sort { $counts{$b} <=> $counts{$a} } keys %counts) {
if ($code eq 'count' ) { next; }
- printf "%10s - %s (%s)\n", $ip_hash{ $key }{ $code }, $code, $connmsg{ $code };
+ printf "%10s - %s (%s)\n", $counts{ $code }, $code, $connmsg{ $code };
}
print "\n";
}
}
}
- undef %exCount;
- undef %ip_hash;
}
###################################
@@ -1069,21 +1029,22 @@ if ($usage =~ /i/i || $verb eq "yes"){
###################################
if ($usage =~ /b/i || $verb eq "yes"){
- %bindlist = getCounterHashFromFile($BINDLIST);
- @bindkeys = keys %bindlist;
- $bind_count = $#bindkeys + 1;
+ my $bindlist = $hashes->{bindlist};
+ my @bindkeys = keys %{$bindlist};
+ my $bind_count = $#bindkeys + 1;
if ($bind_count > 0){
print "\n\n----- Top $sizeCount Bind DN's -----\n\n";
print "Number of Unique Bind DN's: $bind_count\n\n";
- $bindcount = 0;
- foreach $dn (sort { $bindlist{$b} <=> $bindlist{$a} } keys %bindlist) {
- if ($bindcount < $sizeCount){
- printf "%-8s %-40s\n", $bindlist{ $dn },$dn;
- }
+ my $bindcount = 0;
+ foreach my $dn (sort { $bindlist->{$b} <=> $bindlist->{$a} } @bindkeys) {
+ if ($bindcount < $sizeCount){
+ printf "%-8s %-40s\n", $bindlist->{ $dn },$dn;
+ } else {
+ last;
+ }
$bindcount++;
}
}
- undef %bindlist;
}
#########################################
@@ -1093,21 +1054,22 @@ if ($usage =~ /b/i || $verb eq "yes"){
#########################################
if ($usage =~ /a/i || $verb eq "yes"){
- %base = getCounterHashFromFile($BASE);
- @basekeys = keys %base;
- $base_count = $#basekeys + 1;
+ my $base = $hashes->{base};
+ my @basekeys = keys %{$base};
+ my $base_count = $#basekeys + 1;
if ($base_count > 0){
print "\n\n----- Top $sizeCount Search Bases -----\n\n";
print "Number of Unique Search Bases: $base_count\n\n";
- $basecount = 0;
- foreach $bas (sort { $base{$b} <=> $base{$a} } keys %base) {
+ my $basecount = 0;
+ foreach my $bas (sort { $base->{$b} <=> $base->{$a} } @basekeys) {
if ($basecount < $sizeCount){
- printf "%-8s %-40s\n", $base{ $bas },$bas;
- }
+ printf "%-8s %-40s\n", $base->{ $bas },$bas;
+ } else {
+ last;
+ }
$basecount++;
}
}
- undef %base;
}
#########################################
@@ -1117,21 +1079,22 @@ if ($usage =~ /a/i || $verb eq "yes"){
#########################################
if ($usage =~ /l/ || $verb eq "yes"){
- %filter = getCounterHashFromFile($FILTER);
- @filterkeys = keys %filter;
- $filter_count = $#filterkeys + 1;
+ my $filter = $hashes->{filter};
+ my @filterkeys = keys %{$filter};
+ my $filter_count = $#filterkeys + 1;
if ($filter_count > 0){
print "\n\n----- Top $sizeCount Search Filters -----\n";
print "\nNumber of Unique Search Filters: $filter_count\n\n";
- $filtercount = 0;
- foreach $filt (sort { $filter{$b} <=> $filter{$a} } keys %filter){
+ my $filtercount = 0;
+ foreach my $filt (sort { $filter->{$b} <=> $filter->{$a} } @filterkeys){
if ($filtercount < $sizeCount){
- printf "%-8s %-40s\n", $filter{$filt}, $filt;
- }
+ printf "%-8s %-40s\n", $filter->{$filt}, $filt;
+ } else {
+ last;
+ }
$filtercount++;
}
}
- undef %filter;
}
#########################################
@@ -1140,20 +1103,23 @@ if ($usage =~ /l/ || $verb eq "yes"){
# #
#########################################
+my $first;
if ($usage =~ /t/i || $verb eq "yes"){
- %etime = getCounterHashFromFile($ETIME);
+ my $etime = $hashes->{etime};
+ my @ekeys = keys %{$etime};
#
# print most often etimes
#
print "\n\n----- Top $sizeCount Most Frequent etimes -----\n\n";
- $eloop = 0;
- foreach $et (sort { $etime{$b} <=> $etime{$a} } keys %etime) {
+ my $eloop = 0;
+ my $retime = 0;
+ foreach my $et (sort { $etime->{$b} <=> $etime->{$a} } @ekeys) {
if ($eloop == $sizeCount) { last; }
if ($retime ne "2"){
$first = $et;
$retime = "2";
}
- printf "%-8s %-12s\n", $etime{ $et }, "etime=$et";
+ printf "%-8s %-12s\n", $etime->{ $et }, "etime=$et";
$eloop++;
}
#
@@ -1161,12 +1127,11 @@ if ($usage =~ /t/i || $verb eq "yes"){
#
print "\n\n----- Top $sizeCount Longest etimes -----\n\n";
$eloop = 0;
- foreach $et (sort { $b <=> $a } (keys %etime)) {
+ foreach my $et (sort { $b <=> $a } @ekeys) {
if ($eloop == $sizeCount) { last; }
- printf "%-12s %-10s\n","etime=$et",$etime{ $et };
+ printf "%-12s %-10s\n","etime=$et",$etime->{ $et };
$eloop++;
}
- undef %etime;
}
#######################################
@@ -1177,23 +1142,23 @@ if ($usage =~ /t/i || $verb eq "yes"){
if ($usage =~ /n/i || $verb eq "yes"){
- %nentries = getCounterHashFromFile($NENTRIES);
+ my $nentries = $hashes->{nentries};
+ my @nkeys = keys %{$nentries};
print "\n\n----- Top $sizeCount Largest nentries -----\n\n";
- $eloop = 0;
- foreach $nentry (sort { $b <=> $a } (keys %nentries)){
+ my $eloop = 0;
+ foreach my $nentry (sort { $b <=> $a } @nkeys){
if ($eloop == $sizeCount) { last; }
- printf "%-18s %12s\n","nentries=$nentry", $nentries{ $nentry };
+ printf "%-18s %12s\n","nentries=$nentry", $nentries->{ $nentry };
$eloop++;
}
print "\n\n----- Top $sizeCount Most returned nentries -----\n\n";
$eloop = 0;
- foreach $nentry (sort { $nentries{$b} <=> $nentries{$a} } (keys %nentries)){
+ foreach my $nentry (sort { $nentries->{$b} <=> $nentries->{$a} } @nkeys){
if ($eloop == $sizeCount) { last; }
- printf "%-12s %-14s\n", $nentries{ $nentry }, "nentries=$nentry";
+ printf "%-12s %-14s\n", $nentries->{ $nentry }, "nentries=$nentry";
$eloop++;
}
print "\n";
- undef %nentries;
}
##########################################
@@ -1204,9 +1169,10 @@ if ($usage =~ /n/i || $verb eq "yes"){
if ($usage =~ /x/i || $verb eq "yes"){
if ($extopCount > 0){
- %oid = getCounterHashFromFile($OID);
+ my $oid = $hashes->{oid};
print "\n\n----- Extended Operations -----\n\n";
- foreach $oids (sort { $oid{$b} <=> $oid{$a} } (keys %oid) ){
+ foreach my $oids (sort { $oid->{$b} <=> $oid->{$a} } (keys %{$oid}) ){
+ my $oidmessage;
if ($oids eq "2.16.840.1.113730.3.5.1"){ $oidmessage = "Transaction Request"} #depreciated?
elsif ($oids eq "2.16.840.1.113730.3.5.2"){ $oidmessage = "Transaction Response"} #depreciated?
elsif ($oids eq "2.16.840.1.113730.3.5.3"){ $oidmessage = "Start Replication Request (incremental update)"}
@@ -1236,9 +1202,8 @@ if ($usage =~ /x/i || $verb eq "yes"){
elsif ($oids eq "1.3.6.1.4.1.4203.1.11.1"){ $oidmessage = "Password Modify"}
elsif ($oids eq "2.16.840.1.113730.3.4.20"){ $oidmessage = "MTN Control Use One Backend"}
else {$oidmessage = "Other"}
- printf "%-6s %-23s %-60s\n", $oid{ $oids }, $oids, $oidmessage;
+ printf "%-6s %-23s %-60s\n", $oid->{ $oids }, $oids, $oidmessage;
}
- undef %oid;
}
}
@@ -1250,15 +1215,14 @@ if ($usage =~ /x/i || $verb eq "yes"){
if ($usage =~ /r/i || $verb eq "yes"){
if ($anyAttrs > 0){
- %attr = getCounterHashFromFile($ATTR);
+ my $attr = $hashes->{attr};
print "\n\n----- Top $sizeCount Most Requested Attributes -----\n\n";
- $eloop = 0;
- foreach $mostAttr (sort { $attr{$b} <=> $attr{$a} } (keys %attr) ){
+ my $eloop = 0;
+ foreach my $mostAttr (sort { $attr->{$b} <=> $attr->{$a} } (keys %{$attr}) ){
if ($eloop eq $sizeCount){ last; }
- printf "%-10s %-19s\n", $attr{$mostAttr}, $mostAttr;
+ printf "%-10s %-19s\n", $attr->{$mostAttr}, $mostAttr;
$eloop++;
}
- undef %attr;
}
}
@@ -1269,77 +1233,59 @@ if ($usage =~ /r/i || $verb eq "yes"){
#############################
if ($usage =~ /g/i || $verb eq "yes"){
- $abandonTotal = $srchCount + $delCount + $modCount + $addCount + $modrdnCount + $bindCount + $extopCount + $cmpCount;
+ my $abandonTotal = $srchCount + $delCount + $modCount + $addCount + $modrdnCount + $bindCount + $extopCount + $cmpCount;
if ($verb eq "yes" && $abandonCount > 0 && $abandonTotal > 0){
- %conn_hash = getHashFromFile($CONN_HASH);
- @srchConn = getArrayFromFile($SRCH_CONN);
- @srchOp = getArrayFromFile($SRCH_OP);
- @delConn = getArrayFromFile($DEL_CONN);
- @delOp = getArrayFromFile($DEL_OP);
- @targetConn = getArrayFromFile($TARGET_CONN);
- @targetOp = getArrayFromFile($TARGET_OP);
- @msgid = getArrayFromFile($MSGID);
- @addConn = getArrayFromFile($ADD_CONN);
- @addOp = getArrayFromFile($ADD_OP);
- @modConn = getArrayFromFile($MOD_CONN);
- @modOp = getArrayFromFile($MOD_OP);
- @cmpConn = getArrayFromFile($CMP_CONN);
- @cmpOp = getArrayFromFile($CMP_OP);
- @modrdnConn = getArrayFromFile($MODRDN_CONN);
- @modrdnOp = getArrayFromFile($MODRDN_OP);
- @bindConn = getArrayFromFile($BIND_CONN);
- @bindOp = getArrayFromFile($BIND_OP);
- @unbindConn = getArrayFromFile($UNBIND_CONN);
- @unbindOp = getArrayFromFile($UNBIND_OP);
- @extConn = getArrayFromFile($EXT_CONN);
- @extOp = getArrayFromFile($EXT_OP);
+ my $conn_hash = $hashes->{conn_hash};
print "\n\n----- Abandon Request Stats -----\n\n";
- for ($g = 0; $g < $abandonCount; $g++){
- for ($sc = 0; $sc < $srchCount; $sc++){
- if ($srchConn[$sc] eq $targetConn[$g] && $srchOp[$sc] eq $targetOp[$g] ){
- print " - SRCH conn=$targetConn[$g] op=$targetOp[$g] msgid=$msgid[$g] client=$conn_hash{$targetConn[$g]}\n";
+ for (my $g = 0; $g < $abandonCount; $g++){
+ my $conn = $arrays->{targetconn}->[$g];
+ my $op = $arrays->{targetop}->[$g];
+ my $msgid = $arrays->{msgid}->[$g];
+ for (my $sc = 0; $sc < $srchCount; $sc++){
+ if ($arrays->{srchconn}->[$sc] eq $conn && $arrays->{srchop}->[$sc] eq $op ){
+ print " - SRCH conn=$conn op=$op msgid=$msgid client=$conn_hash->{$conn}\n";
}
}
- for ($dc = 0; $dc < $delCount; $dc++){
- if ($delConn[$dc] eq $targetConn[$g] && $delOp[$dc] eq $targetOp[$g]){
- print " - DEL conn=$targetConn[$g] op=$targetOp[$g] msgid=$msgid[$g] client=$conn_hash{$targetConn[$g]}\n";
+ for (my $dc = 0; $dc < $delCount; $dc++){
+ if ($arrays->{delconn}->[$dc] eq $conn && $arrays->{delop}->[$dc] eq $op){
+ print " - DEL conn=$conn op=$op msgid=$msgid client=$conn_hash->{$conn}\n";
}
}
- for ($adc = 0; $adc < $addCount; $adc++){
- if ($addConn[$adc] eq $targetConn[$g] && $addOp[$adc] eq $targetOp[$g]){
- print " - ADD conn=$targetConn[$g] op=$targetOp[$g] msgid=$msgid[$g] client=$conn_hash{$targetConn[$g]}\n";
+ for (my $adc = 0; $adc < $addCount; $adc++){
+ if ($arrays->{addconn}->[$adc] eq $conn && $arrays->{addop}->[$adc] eq $op){
+ print " - ADD conn=$conn op=$op msgid=$msgid client=$conn_hash->{$conn}\n";
}
}
- for ($mc = 0; $mc < $modCount; $mc++){
- if ($modConn[$mc] eq $targetConn[$g] && $modOp[$mc] eq $targetOp[$g]){
- print " - MOD conn=$targetConn[$g] op=$targetOp[$g] msgid=$msgid[$g] client=$conn_hash{$targetConn[$g]}\n";
+ for (my $mc = 0; $mc < $modCount; $mc++){
+ if ($arrays->{modconn}->[$mc] eq $conn && $arrays->{modop}->[$mc] eq $op){
+ print " - MOD conn=$conn op=$op msgid=$msgid client=$conn_hash->{$conn}\n";
}
}
- for ($cc = 0; $cc < $cmpCount; $cc++){
- if ($cmpConn[$mdc] eq $targetConn[$g] && $cmpOp[$mdc] eq $targetOp[$g]){
- print " - CMP conn=$targetConn[$g] op=$targetOp[$g] msgid=$msgid[$g] client=$conn_hash{$targetConn[$g]}\n";
+ for (my $cc = 0; $cc < $cmpCount; $cc++){
+ if ($arrays->{cmpconn}->[$cc] eq $conn && $arrays->{cmpop}->[$cc] eq $op){
+ print " - CMP conn=$conn op=$op msgid=$msgid client=$conn_hash->{$conn}\n";
}
}
- for ($mdc = 0; $mdc < $modrdnCount; $mdc++){
- if ($modrdnConn[$mdc] eq $targetConn[$g] && $modrdnOp[$mdc] eq $targetOp[$g]){
- print " - MODRDN conn=$targetConn[$g] op=$targetOp[$g] msgid=$msgid[$g] client=$conn_hash{$targetConn[$g]}\n";
+ for (my $mdc = 0; $mdc < $modrdnCount; $mdc++){
+ if ($arrays->{modrdnconn}->[$mdc] eq $conn && $arrays->{modrdnop}->[$mdc] eq $op){
+ print " - MODRDN conn=$conn op=$op msgid=$msgid client=$conn_hash->{$conn}\n";
}
}
- for ($bcb = 0; $bcb < $bindCount; $bcb++){
- if ($bindConn[$bcb] eq $targetConn[$g] && $bindOp[$bcb] eq $targetOp[$g]){
- print " - BIND conn=$targetConn[$g] op=$targetOp[$g] msgid=$msgid[$g] client=$conn_hash{$targetConn[$g]}\n";
+ for (my $bcb = 0; $bcb < $bindCount; $bcb++){
+ if ($arrays->{bindconn}->[$bcb] eq $conn && $arrays->{bindop}->[$bcb] eq $op){
+ print " - BIND conn=$conn op=$op msgid=$msgid client=$conn_hash->{$conn}\n";
}
}
- for ($ubc = 0; $ubc < $unbindCount; $ubc++){
- if ($unbindConn[$ubc] eq $targetConn[$g] && $unbindOp[$ubc] eq $targetOp[$g]){
- print " - UNBIND conn=$targetConn[$g] op=$targetOp[$g] msgid=$msgid[$g] client=$conn_hash{$targetConn[$g]}\n";
+ for (my $ubc = 0; $ubc < $unbindCount; $ubc++){
+ if ($arrays->{unbindconn}->[$ubc] eq $conn && $arrays->{unbindop}->[$ubc] eq $op){
+ print " - UNBIND conn=$conn op=$op msgid=$msgid client=$conn_hash->{$conn}\n";
}
}
- for ($ec = 0; $ec < $extopCount; $ec++){
- if ($extConn[$ec] eq $targetConn[$g] && $extOp[$ec] eq $targetOp[$g]){
- print " - EXT conn=$targetConn[$g] op=$targetOp[$g] msgid=$msgid[$g] client=$conn_hash{$targetConn[$g]}\n";
+ for (my $ec = 0; $ec < $extopCount; $ec++){
+ if ($arrays->{extconn}->[$ec] eq $conn && $arrays->{extop}->[$ec] eq $op){
+ print " - EXT conn=$conn op=$op msgid=$msgid client=$conn_hash->{$conn}\n";
}
}
}
@@ -1354,9 +1300,9 @@ print "\n";
#######################################
if ($usage =~ /j/i || $verb eq "yes"){
- %conncount = getCounterHashFromFile($CONNCOUNT);
+ my $conncount = $hashes->{conncount};
print "\n----- Recommendations -----\n";
- $recCount = "1";
+ my $recCount = "1";
if ($unindexedSrchCountNotesA > 0){
print "\n $recCount. You have unindexed searches, this can be caused from a search on an unindexed attribute, or your returned results exceeded the allidsthreshold. Unindexed searches are not recommended. To refuse unindexed searches, switch \'nsslapd-require-index\' to \'on\' under your database entry (e.g. cn=UserRoot,cn=ldbm database,cn=plugins,cn=config).\n";
$recCount++;
@@ -1365,11 +1311,11 @@ if ($usage =~ /j/i || $verb eq "yes"){
print "\n $recCount. You have unindexed components, this can be caused from a search on an unindexed attribute, or your returned results exceeded the allidsthreshold. Unindexed components are not recommended. To refuse unindexed searches, switch \'nsslapd-require-index\' to \'on\' under your database entry (e.g. cn=UserRoot,cn=ldbm database,cn=plugins,cn=config).\n";
$recCount++;
}
- if ($conncount{"T1"} > 0){
+ if (defined($conncount->{"T1"}) and $conncount->{"T1"} > 0){
print "\n $recCount. You have some connections that are are being closed by the idletimeout setting. You may want to increase the idletimeout if it is set low.\n";
$recCount++;
}
- if ($conncount{"T2"} > 0){
+ if (defined($conncount->{"T2"}) and $conncount->{"T2"} > 0){
print "\n $recCount. You have some coonections that are being closed by the ioblocktimeout setting. You may want to increase the ioblocktimeout.\n";
$recCount++;
}
@@ -1391,7 +1337,7 @@ if ($usage =~ /j/i || $verb eq "yes"){
print "\n $recCount. You have more unsuccessful operations than successful operations. You should investigate this difference.\n";
$recCount++;
}
- if ($conncount{"U1"} < ($connCodeCount - $conncount{"U1"})){
+ if (defined($conncount->{"U1"}) and $conncount->{"U1"} < ($connCodeCount - $conncount->{"U1"})){
print "\n $recCount. You have more abnormal connection codes than cleanly closed connections. You may want to investigate this difference.\n";
$recCount++;
}
@@ -1407,7 +1353,6 @@ if ($usage =~ /j/i || $verb eq "yes"){
print "\nNone.\n";
}
print "\n";
- undef %conncount;
}
#
@@ -1499,11 +1444,9 @@ parseLineBind {
$linesProcessed++;
$lineBlockCount++;
local $_ = $logline;
+ my $ip;
- if ($lineBlockCount >= $limit){
- print STDERR sprintf" %10s Lines Processed\n",$linesProcessed;
- $lineBlockCount="0";
- }
+ statusreport();
# skip blank lines
return if $_ =~ /^\s/;
@@ -1531,7 +1474,8 @@ parseLineBind {
}
}
if ($_ =~ /connection from *([0-9A-Fa-f\.\:]+)/i ) {
- for ($excl =0; $excl <= $#excludeIP; $excl++){
+ my $skip = "yes";
+ for (my $excl =0; $excl < $#excludeIP; $excl++){
if ($excludeIP[$excl] eq $1){
$skip = "yes";
last;
@@ -1547,6 +1491,7 @@ parseLineBind {
return;
}
if (/ BIND/ && $_ =~ /dn=\"(.*)\" method/i ){
+ my $dn;
if ($1 eq ""){
$dn = "Anonymous";
} else {
@@ -1599,30 +1544,36 @@ parseLineBind {
sub
processOpForBindReport
{
- $op = @_[0];
- $data = @_[1];
+ my $op = shift;
+ my $data = shift;
if ($data =~ /conn= *([0-9]+)/i) {
- foreach $dn (keys %bindReport){
+ foreach my $dn (keys %bindReport){
if ($bindReport{$dn}{"conn"} =~ / $1 /){
- $bindDN = $dn;
- $bindReport{$bindDN}{$op}++;
+ $bindReport{$dn}{$op}++;
return;
}
}
}
}
+my ($last_tm, $lastzone, $last_min, $gmtime, $tzoff);
sub parseLineNormal
{
local $_ = $logline;
+ my $ip;
+ my $tmpp;
+ my $exc = "no";
+ my $connID;
+ my $con;
+ my $op;
+ $linesProcessed++;
+ $lineBlockCount++;
# lines starting blank are restart
return if $_ =~ /^\s/;
- $linesProcessed++;
- $lineBlockCount++;
- if ($lineBlockCount >= $limit){ print STDERR sprintf" %10s Lines Processed\n",$linesProcessed; $lineBlockCount="0";}
+ statusreport();
# gather/process the timestamp
if($firstFile == 1 && $_ =~ /^\[/){
@@ -1648,30 +1599,30 @@ sub parseLineNormal
}
# Additional performance stats
- ($time, $tzone) = split (' ', $_);
- if ($reportStats && $time ne $last_tm)
+ my ($time, $tzone) = split (' ', $_);
+ if (($reportStats or ($verb eq "yes") || ($usage =~ /y/)) && (!defined($last_tm) or ($time ne $last_tm)))
{
$last_tm = $time;
$time =~ s/\[//;
$tzone =~ s/\].*//;
- if($tzone ne $lastzone)
+ if(!defined($lastzone) or $tzone ne $lastzone)
{
# tz offset change
$lastzone=$tzone;
- ($sign,$hr,$min) = $tzone =~ m/(.)(\d\d)(\d\d)/;
+ my ($sign,$hr,$min) = $tzone =~ m/(.)(\d\d)(\d\d)/;
$tzoff = $hr*3600 + $min*60;
$tzoff *= -1
if $sign eq '-';
# to be subtracted from converted values.
}
- ($date, $hr, $min, $sec) = split (':', $time);
- ($day, $mon, $yr) = split ('/', $date);
- $newmin = timegm(0, $min, $hr, $day, $monthname{$mon}, $yr) - $tzoff;
+ my ($date, $hr, $min, $sec) = split (':', $time);
+ my ($day, $mon, $yr) = split ('/', $date);
+ my $newmin = timegm(0, $min, $hr, $day, $monthname{$mon}, $yr) - $tzoff;
$gmtime = $newmin + $sec;
print_stats_block( $s_stats );
reset_stats_block( $s_stats, $gmtime, $time.' '.$tzone );
- if ($newmin != $last_min)
+ if (!defined($last_min) or $newmin != $last_min)
{
print_stats_block( $m_stats );
$time =~ s/\d\d$/00/;
@@ -1689,58 +1640,57 @@ sub parseLineNormal
if($reportStats){ inc_stats('srch',$s_stats,$m_stats); }
if ($_ =~ / attrs=\"(.*)\"/i){
$anyAttrs++;
- $attrs = $1 . " ";
- while ($attrs =~ /(\S+)\s/g){
- writeFile($ATTR, $1);
- }
- }
+ my $attr = $hashes->{attr};
+ map { $attr->{$_}++ } split /\s/, $1;
+ }
if (/ attrs=ALL/){
- writeFile($ATTR, "All Attributes");
+ my $attr = $hashes->{attr};
+ $attr->{"All Attributes"}++;
$anyAttrs++;
}
- if ($verb eq "yes"){
- if ($_ =~ /conn= *([0-9]+)/i){ writeFile($SRCH_CONN, $1);}
- if ($_ =~ /op= *([0-9]+)/i){ writeFile($SRCH_OP, $1);}
+ if ($verb eq "yes"){
+ if ($_ =~ /conn= *([0-9]+)/i){ push @{$arrays->{srchconn}}, $1;}
+ if ($_ =~ /op= *([0-9]+)/i){ push @{$arrays->{srchop}}, $1;}
}
}
if (m/ DEL/){
$delCount++;
if($reportStats){ inc_stats('del',$s_stats,$m_stats); }
if ($verb eq "yes"){
- if ($_ =~ /conn= *([0-9]+)/i){ writeFile($DEL_CONN, $1);}
- if ($_ =~ /op= *([0-9]+)/i){ writeFile($DEL_OP, $1);}
+ if ($_ =~ /conn= *([0-9]+)/i){ push @{$arrays->{delconn}}, $1;}
+ if ($_ =~ /op= *([0-9]+)/i){ push @{$arrays->{delop}}, $1;}
}
}
if (m/ MOD dn=/){
$modCount++;
if($reportStats){ inc_stats('mod',$s_stats,$m_stats); }
if ($verb eq "yes"){
- if ($_ =~ /conn= *([0-9]+)/i){ writeFile($MOD_CONN, $1);}
- if ($_ =~ /op= *([0-9]+)/i){ writeFile($MOD_OP, $1); }
+ if ($_ =~ /conn= *([0-9]+)/i){ push @{$arrays->{modconn}}, $1;}
+ if ($_ =~ /op= *([0-9]+)/i){ push @{$arrays->{modop}}, $1; }
}
}
if (m/ ADD/){
$addCount++;
if($reportStats){ inc_stats('add',$s_stats,$m_stats); }
if ($verb eq "yes"){
- if ($_ =~ /conn= *([0-9]+)/i){ writeFile($ADD_CONN, $1); }
- if ($_ =~ /op= *([0-9]+)/i){ writeFile($ADD_OP, $1); }
+ if ($_ =~ /conn= *([0-9]+)/i){ push @{$arrays->{addconn}}, $1; }
+ if ($_ =~ /op= *([0-9]+)/i){ push @{$arrays->{addop}}, $1; }
}
}
if (m/ MODRDN/){
$modrdnCount++;
if($reportStats){ inc_stats('modrdn',$s_stats,$m_stats); }
if ($verb eq "yes"){
- if ($_ =~ /conn= *([0-9]+)/i){ writeFile($MODRDN_CONN, $1); }
- if ($_ =~ /op= *([0-9]+)/i){ writeFile($MODRDN_OP, $1); }
+ if ($_ =~ /conn= *([0-9]+)/i){ push @{$arrays->{modrdnconn}}, $1; }
+ if ($_ =~ /op= *([0-9]+)/i){ push @{$arrays->{modrdnop}}, $1; }
}
}
if (m/ CMP dn=/){
$cmpCount++;
if($reportStats){ inc_stats('cmp',$s_stats,$m_stats); }
if ($verb eq "yes" || $usage =~ /g/i){
- if ($_ =~ /conn= *([0-9]+)/i){ writeFile($CMP_CONN, $1);}
- if ($_ =~ /op= *([0-9]+)/i){ writeFile($CMP_OP, $1);}
+ if ($_ =~ /conn= *([0-9]+)/i){ push @{$arrays->{cmpconn}}, $1;}
+ if ($_ =~ /op= *([0-9]+)/i){ push @{$arrays->{cmpop}}, $1;}
}
}
if (m/ ABANDON /){
@@ -1748,9 +1698,9 @@ sub parseLineNormal
if($reportStats){ inc_stats('abandon',$s_stats,$m_stats); }
$allResults++;
if ($_ =~ /targetop= *([0-9a-zA-Z]+)/i ){
- writeFile($TARGET_OP, $1);
- if ($_ =~ /conn= *([0-9]+)/i){ writeFile($TARGET_CONN, $1); }
- if ($_ =~ /msgid= *([0-9]+)/i){ writeFile($MSGID, $1);}
+ push @{$arrays->{targetop}}, $1;
+ if ($_ =~ /conn= *([0-9]+)/i){ push @{$arrays->{targetconn}}, $1; }
+ if ($_ =~ /msgid= *([0-9]+)/i){ push @{$arrays->{msgid}}, $1; }
}
}
if (m/ VLV /){
@@ -1774,20 +1724,19 @@ sub parseLineNormal
if ($1 ne ""){
$tmpp = $1;
$tmpp =~ tr/A-Z/a-z/;
- writeFile($BINDLIST, $tmpp);
+ $hashes->{bindlist}->{$tmpp}++;
if($1 eq $rootDN){
$rootDNBindCount++;
}
} else {
$anonymousBindCount++;
- writeFile($BINDLIST, "Anonymous Binds");
+ $hashes->{bindlist}->{"Anonymous Binds"}++;
inc_stats('anonbind',$s_stats,$m_stats);
}
}
if (m/ connection from/){
- $exc = "no";
if ($_ =~ /connection from *([0-9A-Fa-f\.\:]+)/i ){
- for ($xxx =0; $xxx <= $#excludeIP; $xxx++){
+ for (my $xxx =0; $xxx < $#excludeIP; $xxx++){
if ($excludeIP[$xxx] eq $1){$exc = "yes";}
}
if ($exc ne "yes"){
@@ -1801,11 +1750,13 @@ sub parseLineNormal
}
($connID) = $_ =~ /conn=(\d*)\s/;
$openConnection[$connID]++;
- ($time, $tzone) = split (' ', $_);
- ($date, $hr, $min, $sec) = split (':', $time);
- ($day, $mon, $yr) = split ('/', $date);
- $day =~ s/\[//;
- $start_time_of_connection[$connID] = timegm($sec, $min, $hours, $day, $monthname{$mon}, $yr);
+ if ($reportStats or ($verb eq "yes") || ($usage =~ /y/)) {
+ my ($time, $tzone) = split (' ', $_);
+ my ($date, $hr, $min, $sec) = split (':', $time);
+ my ($day, $mon, $yr) = split ('/', $date);
+ $day =~ s/\[//;
+ $start_time_of_connection[$connID] = timegm($sec, $min, $hr, $day, $monthname{$mon}, $yr);
+ }
}
if (m/ SSL client bound as /){$sslClientBindCount++;}
if (m/ SSL failed to map client certificate to LDAP DN/){$sslClientFailedCount++;}
@@ -1816,16 +1767,22 @@ sub parseLineNormal
($connID) = $_ =~ /conn=(\d*)\s/;
$openConnection[$connID]--;
- $end_time_of_connection[$connID] = $gmtime;
- $diff = $end_time_of_connection[$connID] - $start_time_of_connection[$connID];
- $start_time_of_connection[$connID] = $end_time_of_connection[$connID] = 0;
- if ($diff <= 1) { $latency[0]++;}
- if ($diff == 2) { $latency[1]++;}
- if ($diff == 3) { $latency[2]++;}
- if ($diff >= 4 && $diff <=5 ) { $latency[3]++;}
- if ($diff >= 6 && $diff <=10 ) { $latency[4]++;}
- if ($diff >= 11 && $diff <=15 ) { $latency[5]++;}
- if ($diff >= 16) { $latency[6] ++;}
+ if ($reportStats or ($verb eq "yes") || ($usage =~ /y/)) {
+ # if we didn't see the start time of this connection
+ # i.e. due to truncation or log rotation
+ # then just set to 0
+ my $stoc = $start_time_of_connection[$connID] || 0;
+ $end_time_of_connection[$connID] = $gmtime || 0;
+ my $diff = $end_time_of_connection[$connID] - $stoc;
+ $start_time_of_connection[$connID] = $end_time_of_connection[$connID] = 0;
+ if ($diff <= 1) { $latency[0]++;}
+ if ($diff == 2) { $latency[1]++;}
+ if ($diff == 3) { $latency[2]++;}
+ if ($diff >= 4 && $diff <=5 ) { $latency[3]++;}
+ if ($diff >= 6 && $diff <=10 ) { $latency[4]++;}
+ if ($diff >= 11 && $diff <=15 ) { $latency[5]++;}
+ if ($diff >= 16) { $latency[6] ++;}
+ }
}
if (m/ BIND/ && $_ =~ /dn=\"(.*)\" method/i ){
if($reportStats){ inc_stats('bind',$s_stats,$m_stats); }
@@ -1834,25 +1791,26 @@ sub parseLineNormal
if($1 eq $rootDN){$rootDNBindCount++;}
$tmpp = $1;
$tmpp =~ tr/A-Z/a-z/;
- writeFile($BINDLIST, $tmpp);
- $bindVal = $tmpp;
- if ($_ =~ /conn= *([0-9]+)/i) { $bindConn = $1; writeFile($BIND_CONN, $1);}
- if ($_ =~ /op= *([0-9]+)/i) { $bindOp = $1; writeFile($BIND_OP, $1);}
+ $hashes->{bindlist}->{$tmpp}++;
+ if ($_ =~ /conn= *([0-9]+)/i) { push @{$arrays->{bindconn}}, $1;}
+ if ($_ =~ /op= *([0-9]+)/i) { push @{$arrays->{bindop}}, $1;}
if($usage =~ /f/ || $verb eq "yes"){
- # only need this for the failed bind report
- writeFile($BINDINFO, "$bindVal ,, $bindConn ,, $bindOp");
+ push @{$arrays->{binddn}}, $tmpp;
}
} else {
$anonymousBindCount++;
- writeFile($BINDLIST, "Anonymous Binds");
+ $hashes->{bindlist}->{"Anonymous Binds"}++;
+ if ($_ =~ /conn= *([0-9]+)/i) { push @{$arrays->{bindconn}}, $1;}
+ if ($_ =~ /op= *([0-9]+)/i) { push @{$arrays->{bindop}}, $1;}
+ push @{$arrays->{binddn}}, "";
inc_stats('anonbind',$s_stats,$m_stats);
}
}
if (m/ UNBIND/){
$unbindCount++;
if ($verb eq "yes"){
- if ($_ =~ /conn= *([0-9]+)/i){ writeFile($UNBIND_CONN, $1); }
- if ($_ =~ /op= *([0-9]+)/i){ writeFile($UNBIND_OP, $1); }
+ if ($_ =~ /conn= *([0-9]+)/i){ push @{$arrays->{unbindconn}}, $1; }
+ if ($_ =~ /op= *([0-9]+)/i){ push @{$arrays->{unbindop}}, $1; }
}
}
if (m/ RESULT err=/ && m/ notes=P/){
@@ -1863,7 +1821,7 @@ sub parseLineNormal
$con = $1;
if ($_ =~ /op= *([0-9]+)/i){ $op = $1;}
}
- for ($i=0; $i <= $vlvCount;$i++){
+ for (my $i=0; $i <= $vlvCount;$i++){
if ($vlvconn[$i] eq $con && $vlvop[$i] eq $op){ $vlvNotesACount++; $isVlvNotes="1";}
}
if($isVlvNotes == 0){
@@ -1873,22 +1831,12 @@ sub parseLineNormal
if($reportStats){ inc_stats('notesA',$s_stats,$m_stats); }
}
if ($usage =~ /u/ || $verb eq "yes"){
- if ($isVlvNnotes == 0 ){
- if ($_ =~ /etime= *([0-9.]+)/i ){
- writeFile($NOTES_A_ETIME, $1);
- }
- if ($_ =~ /conn= *([0-9]+)/i){
- writeFile($NOTES_A_CONN, $1);
- }
- if ($_ =~ /op= *([0-9]+)/i){
- writeFile($NOTES_A_OP, $1);
- }
- if ($_ =~ / *([0-9a-z:\/]+)/i){
- writeFile($NOTES_A_TIME, $1);
- }
- if ($_ =~ /nentries= *([0-9]+)/i ){
- writeFile($NOTES_A_NENTRIES, $1);
- }
+ if ($isVlvNotes == 0 ){
+ if ($_ =~ /etime= *([0-9.]+)/i ){ push @{$arrays->{notesAetime}}, $1; }
+ if ($_ =~ /conn= *([0-9]+)/i){ push @{$arrays->{notesAconn}}, $1; }
+ if ($_ =~ /op= *([0-9]+)/i){ push @{$arrays->{notesAop}}, $1; }
+ if ($_ =~ / *([0-9a-z:\/]+)/i){ push @{$arrays->{notesAtime}}, $1; }
+ if ($_ =~ /nentries= *([0-9]+)/i ){ push @{$arrays->{notesAnentries}}, $1; }
}
}
$isVlvNotes = 0;
@@ -1898,7 +1846,7 @@ sub parseLineNormal
$con = $1;
if ($_ =~ /op= *([0-9]+)/i){ $op = $1;}
}
- for ($i=0; $i <= $vlvCount;$i++){
+ for (my $i=0; $i <= $vlvCount;$i++){
if ($vlvconn[$i] eq $con && $vlvop[$i] eq $op){ $vlvNotesUCount++; $isVlvNotes="1";}
}
if($isVlvNotes == 0){
@@ -1908,85 +1856,75 @@ sub parseLineNormal
if($reportStats){ inc_stats('notesU',$s_stats,$m_stats); }
}
if ($usage =~ /u/ || $verb eq "yes"){
- if ($isVlvNnotes == 0 ){
- if ($_ =~ /etime= *([0-9.]+)/i ){
- writeFile($NOTES_U_ETIME, $1);
- }
- if ($_ =~ /conn= *([0-9]+)/i){
- writeFile($NOTES_U_CONN, $1);
- }
- if ($_ =~ /op= *([0-9]+)/i){
- writeFile($NOTES_U_OP, $1);
- }
- if ($_ =~ / *([0-9a-z:\/]+)/i){
- writeFile($NOTES_U_TIME, $1);
- }
- if ($_ =~ /nentries= *([0-9]+)/i ){
- writeFile($NOTES_U_NENTRIES, $1);
- }
+ if ($isVlvNotes == 0 ){
+ if ($_ =~ /etime= *([0-9.]+)/i ){ push @{$arrays->{notesUetime}}, $1; }
+ if ($_ =~ /conn= *([0-9]+)/i){ push @{$arrays->{notesUconn}}, $1; }
+ if ($_ =~ /op= *([0-9]+)/i){ push @{$arrays->{notesUop}}, $1; }
+ if ($_ =~ / *([0-9a-z:\/]+)/i){ push @{$arrays->{notesUtime}}, $1; }
+ if ($_ =~ /nentries= *([0-9]+)/i ){ push @{$arrays->{notesUnentries}}, $1; }
}
}
$isVlvNotes = 0;
}
if (m/ closed error 32/){
$brokenPipeCount++;
- if (m/- T1/){ writeFile($RC,"T1"); }
- elsif (m/- T2/){ writeFile($RC,"T2"); }
- elsif (m/- A1/){ writeFile($RC,"A1"); }
- elsif (m/- B1/){ writeFile($RC,"B1"); }
- elsif (m/- B4/){ writeFile($RC,"B4"); }
- elsif (m/- B2/){ writeFile($RC,"B2"); }
- elsif (m/- B3/){ writeFile($RC,"B3"); }
- elsif (m/- R1/){ writeFile($RC,"R1"); }
- elsif (m/- P1/){ writeFile($RC,"P1"); }
- elsif (m/- P1/){ writeFile($RC,"P2"); }
- elsif (m/- U1/){ writeFile($RC,"U1"); }
- else { writeFile($RC,"other"); }
+ if (m/- T1/){ $hashes->{rc}->{"T1"}++; }
+ elsif (m/- T2/){ $hashes->{rc}->{"T2"}++; }
+ elsif (m/- A1/){ $hashes->{rc}->{"A1"}++; }
+ elsif (m/- B1/){ $hashes->{rc}->{"B1"}++; }
+ elsif (m/- B4/){ $hashes->{rc}->{"B4"}++; }
+ elsif (m/- B2/){ $hashes->{rc}->{"B2"}++; }
+ elsif (m/- B3/){ $hashes->{rc}->{"B3"}++; }
+ elsif (m/- R1/){ $hashes->{rc}->{"R1"}++; }
+ elsif (m/- P1/){ $hashes->{rc}->{"P1"}++; }
+ elsif (m/- P1/){ $hashes->{rc}->{"P2"}++; }
+ elsif (m/- U1/){ $hashes->{rc}->{"U1"}++; }
+ else { $hashes->{rc}->{"other"}++; }
}
if (m/ closed error 131/ || m/ closed error -5961/){
$connResetByPeerCount++;
- if (m/- T1/){ writeFile($SRC,"T1"); }
- elsif (m/- T2/){ writeFile($SRC,"T2"); }
- elsif (m/- A1/){ writeFile($SRC,"A1"); }
- elsif (m/- B1/){ writeFile($SRC,"B1"); }
- elsif (m/- B4/){ writeFile($SRC,"B4"); }
- elsif (m/- B2/){ writeFile($SRC,"B2"); }
- elsif (m/- B3/){ writeFile($SRC,"B3"); }
- elsif (m/- R1/){ writeFile($SRC,"R1"); }
- elsif (m/- P1/){ writeFile($SRC,"P1"); }
- elsif (m/- P1/){ writeFile($SRC,"P2"); }
- elsif (m/- U1/){ writeFile($SRC,"U1"); }
- else { writeFile($SRC,"other"); }
+ if (m/- T1/){ $hashes->{src}->{"T1"}++; }
+ elsif (m/- T2/){ $hashes->{src}->{"T2"}++; }
+ elsif (m/- A1/){ $hashes->{src}->{"A1"}++; }
+ elsif (m/- B1/){ $hashes->{src}->{"B1"}++; }
+ elsif (m/- B4/){ $hashes->{src}->{"B4"}++; }
+ elsif (m/- B2/){ $hashes->{src}->{"B2"}++; }
+ elsif (m/- B3/){ $hashes->{src}->{"B3"}++; }
+ elsif (m/- R1/){ $hashes->{src}->{"R1"}++; }
+ elsif (m/- P1/){ $hashes->{src}->{"P1"}++; }
+ elsif (m/- P1/){ $hashes->{src}->{"P2"}++; }
+ elsif (m/- U1/){ $hashes->{src}->{"U1"}++; }
+ else { $hashes->{src}->{"other"}++; }
}
if (m/ closed error 11/){
$resourceUnavailCount++;
- if (m/- T1/){ writeFile($RSRC,"T1"); }
- elsif (m/- T2/){ writeFile($RSRC,"T2"); }
- elsif (m/- A1/){ writeFile($RSRC,"A1"); }
- elsif (m/- B1/){ writeFile($RSRC,"B1"); }
- elsif (m/- B4/){ writeFile($RSRC,"B4"); }
- elsif (m/- B2/){ writeFile($RSRC,"B2"); }
- elsif (m/- B3/){ writeFile($RSRC,"B3"); }
- elsif (m/- R1/){ writeFile($RSRC,"R1"); }
- elsif (m/- P1/){ writeFile($RSRC,"P1"); }
- elsif (m/- P1/){ writeFile($RSRC,"P2"); }
- elsif (m/- U1/){ writeFile($RSRC,"U1"); }
- else { writeFile($RSRC,"other"); }
+ if (m/- T1/){ $hashes->{rsrc}->{"T1"}++; }
+ elsif (m/- T2/){ $hashes->{rsrc}->{"T2"}++; }
+ elsif (m/- A1/){ $hashes->{rsrc}->{"A1"}++; }
+ elsif (m/- B1/){ $hashes->{rsrc}->{"B1"}++; }
+ elsif (m/- B4/){ $hashes->{rsrc}->{"B4"}++; }
+ elsif (m/- B2/){ $hashes->{rsrc}->{"B2"}++; }
+ elsif (m/- B3/){ $hashes->{rsrc}->{"B3"}++; }
+ elsif (m/- R1/){ $hashes->{rsrc}->{"R1"}++; }
+ elsif (m/- P1/){ $hashes->{rsrc}->{"P1"}++; }
+ elsif (m/- P1/){ $hashes->{rsrc}->{"P2"}++; }
+ elsif (m/- U1/){ $hashes->{rsrc}->{"U1"}++; }
+ else { $hashes->{rsrc}->{"other"}++; }
}
if ($usage =~ /g/ || $usage =~ /c/ || $usage =~ /i/ || $verb eq "yes"){
$exc = "no";
if ($_ =~ /connection from *([0-9A-fa-f\.\:]+)/i ) {
- for ($xxx = 0; $xxx <= $#excludeIP; $xxx++){
+ for (my $xxx = 0; $xxx < $#excludeIP; $xxx++){
if ($1 eq $excludeIP[$xxx]){
$exc = "yes";
- writeFile($EXCOUNT,$1);
+ $hashes->{excount}->{$1}++;
}
}
$ip = $1;
- writeFile($IP_HASH, "$ip count");
+ $hashes->{ip_hash}->{$ip}++;
if ($_ =~ /conn= *([0-9]+)/i ){
if ($exc ne "yes"){
- writeFile($CONN_HASH, "$1 $ip");
+ $hashes->{conn_hash}->{$1} = $ip;
}
}
}
@@ -1995,12 +1933,12 @@ sub parseLineNormal
$exc = "no";
$ip = getIPfromConn($1);
if ($ip eq ""){$ip = "Unknown_Host";}
- for ($xxx = 0; $xxx <= $#excludeIP; $xxx++){
+ for (my $xxx = 0; $xxx < $#excludeIP; $xxx++){
if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
}
if ($exc ne "yes"){
- writeFile($IP_HASH, "$ip A1");
- writeFile($CONNCOUNT, "A1");
+ $hashes->{A1}->{$ip}++;
+ $hashes->{conncount}->{"A1"}++;
$connCodeCount++;
}
}
@@ -2010,12 +1948,12 @@ sub parseLineNormal
$exc = "no";
$ip = getIPfromConn($1);
if ($ip eq ""){$ip = "Unknown_Host";}
- for ($xxx = 0; $xxx <= $#excludeIP; $xxx++){
+ for (my $xxx = 0; $xxx < $#excludeIP; $xxx++){
if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
}
if ($exc ne "yes"){
- writeFile($IP_HASH, "$ip B1");
- writeFile($CONNCOUNT, "B1");
+ $hashes->{B1}->{$ip}++;
+ $hashes->{conncount}->{"B1"}++;
$connCodeCount++;
}
}
@@ -2025,12 +1963,12 @@ sub parseLineNormal
$exc = "no";
$ip = getIPfromConn($1);
if ($ip eq ""){$ip = "Unknown_Host";}
- for ($xxx = 0; $xxx <= $#excludeIP; $xxx++){
+ for (my $xxx = 0; $xxx < $#excludeIP; $xxx++){
if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
}
if ($exc ne "yes"){
- writeFile($IP_HASH, "$ip B4");
- writeFile($CONNCOUNT, "B4");
+ $hashes->{B4}->{$ip}++;
+ $hashes->{conncount}->{"B4"}++;
$connCodeCount++;
}
}
@@ -2040,12 +1978,12 @@ sub parseLineNormal
$exc = "no";
$ip = getIPfromConn($1);
if ($ip eq ""){$ip = "Unknown_Host";}
- for ($xxx = 0; $xxx <= $#excludeIP; $xxx++){
+ for (my $xxx = 0; $xxx < $#excludeIP; $xxx++){
if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
}
if ($exc ne "yes"){
- writeFile($IP_HASH, "$ip T1");
- writeFile($CONNCOUNT, "T1");
+ $hashes->{T1}->{$ip}++;
+ $hashes->{conncount}->{"T1"}++;
$connCodeCount++;
}
}
@@ -2055,12 +1993,12 @@ sub parseLineNormal
$exc = "no";
$ip = getIPfromConn($1);
if ($ip eq ""){$ip = "Unknown_Host";}
- for ($xxx = 0; $xxx <= $#excludeIP; $xxx++){
+ for (my $xxx = 0; $xxx < $#excludeIP; $xxx++){
if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
}
if ($exc ne "yes"){
- writeFile($IP_HASH, "$ip T2");
- writeFile($CONNCOUNT, "T2");
+ $hashes->{T2}->{$ip}++;
+ $hashes->{conncount}->{"T2"}++;
$connCodeCount++;
}
}
@@ -2071,12 +2009,12 @@ sub parseLineNormal
$ip = getIPfromConn($1);
$maxBerSizeCount++;
if ($ip eq ""){$ip = "Unknown_Host";}
- for ($xxx = 0; $xxx <= $#excludeIP; $xxx++){
+ for (my $xxx = 0; $xxx < $#excludeIP; $xxx++){
if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
}
if ($exc ne "yes"){
- writeFile($IP_HASH, "$ip B2");
- writeFile($CONNCOUNT, "B2");
+ $hashes->{B2}->{$ip}++;
+ $hashes->{conncount}->{"B2"}++;
$connCodeCount++;
}
}
@@ -2086,12 +2024,12 @@ sub parseLineNormal
$exc = "no";
$ip = getIPfromConn($1);
if ($ip eq ""){$ip = "Unknown_Host";}
- for ($xxx = 0; $xxx <= $#excludeIP; $xxx++){
+ for (my $xxx = 0; $xxx < $#excludeIP; $xxx++){
if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
}
if ($exc ne "yes"){
- writeFile($IP_HASH, "$ip B3");
- writeFile($CONNCOUNT, "B3");
+ $hashes->{B3}->{$ip}++;
+ $hashes->{conncount}->{"B3"}++;
$connCodeCount++;
}
}
@@ -2101,12 +2039,12 @@ sub parseLineNormal
$exc = "no";
$ip = getIPfromConn($1);
if ($ip eq ""){$ip = "Unknown_Host";}
- for ($xxx = 0; $xxx <= $#excludeIP; $xxx++){
+ for (my $xxx = 0; $xxx < $#excludeIP; $xxx++){
if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
}
if ($exc ne "yes"){
- writeFile($IP_HASH, "$ip R1");
- writeFile($CONNCOUNT, "R1");
+ $hashes->{R1}->{$ip}++;
+ $hashes->{conncount}->{"R1"}++;
$connCodeCount++;
}
}
@@ -2116,12 +2054,12 @@ sub parseLineNormal
$exc = "no";
$ip = getIPfromConn($1);
if ($ip eq ""){$ip = "Unknown_Host";}
- for ($xxx = 0; $xxx <= $#excludeIP; $xxx++){
+ for (my $xxx = 0; $xxx < $#excludeIP; $xxx++){
if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
}
if ($exc ne "yes"){
- writeFile($IP_HASH, "$ip P1");
- writeFile($CONNCOUNT, "P1");
+ $hashes->{P1}->{$ip}++;
+ $hashes->{conncount}->{"P1"}++;
$connCodeCount++;
}
}
@@ -2131,12 +2069,12 @@ sub parseLineNormal
$exc = "no";
$ip = getIPfromConn($1);
if ($ip eq ""){$ip = "Unknown_Host";}
- for ($xxx = 0; $xxx <= $#excludeIP; $xxx++){
+ for (my $xxx = 0; $xxx < $#excludeIP; $xxx++){
if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
}
if ($exc ne "yes"){
- writeFile($IP_HASH, "$ip P2");
- writeFile($CONNCOUNT, "P2");
+ $hashes->{P2}->{$ip}++;
+ $hashes->{conncount}->{"P2"}++;
$connCodeCount++;
}
}
@@ -2146,12 +2084,12 @@ sub parseLineNormal
$exc = "no";
$ip = getIPfromConn($1);
if ($ip eq ""){$ip = "Unknown_Host";}
- for ($xxx = 0; $xxx <= $#excludeIP; $xxx++){
+ for (my $xxx = 0; $xxx < $#excludeIP; $xxx++){
if ($ip eq $excludeIP[$xxx]){$exc = "yes";}
}
if ($exc ne "yes"){
- writeFile($IP_HASH, "$ip U1");
- writeFile($CONNCOUNT, "U1");
+ $hashes->{U1}->{$ip}++;
+ $hashes->{conncount}->{"U1"}++;
$connCodeCount++;
}
}
@@ -2162,59 +2100,60 @@ sub parseLineNormal
if ($1 ne "0"){ $errorCount++;}
else { $successCount++;}
}
- if ($_ =~ /etime= *([0-9.]+)/ ) { writeFile($ETIME, $1); inc_stats_val('etime',$1,$s_stats,$m_stats); }
+ if ($_ =~ /etime= *([0-9.]+)/ ) { $hashes->{etime}->{$1}++; inc_stats_val('etime',$1,$s_stats,$m_stats); }
if ($_ =~ / tag=101 / || $_ =~ / tag=111 / || $_ =~ / tag=100 / || $_ =~ / tag=115 /){
- if ($_ =~ / nentries= *([0-9]+)/i ){ writeFile($NENTRIES, $1); }
+ if ($_ =~ / nentries= *([0-9]+)/i ){ $hashes->{nentries}->{$1}++; }
}
if (m/objectclass=\*/i || m/objectclass=top/i ){
if (m/ scope=2 /){ $objectclassTopCount++;}
}
if (m/ EXT oid=/){
$extopCount++;
- if ($_ =~ /oid=\" *([0-9\.]+)/i ){ writeFile($OID,$1); }
+ if ($_ =~ /oid=\" *([0-9\.]+)/i ){ $hashes->{oid}->{$1}++; }
if ($1 && $1 eq $startTLSoid){$startTLSCount++;}
if ($verb eq "yes"){
- if ($_ =~ /conn= *([0-9]+)/i){ writeFile($EXT_CONN, $1); }
- if ($_ =~ /op= *([0-9]+)/i){ writeFile($EXT_OP, $1); }
+ if ($_ =~ /conn= *([0-9]+)/i){ push @{$arrays->{extconn}}, $1; }
+ if ($_ =~ /op= *([0-9]+)/i){ push @{$arrays->{extop}}, $1; }
}
}
- if ($usage =~ /l/ || $verb eq "yes"){
+ if (($usage =~ /l/ || $verb eq "yes") and / SRCH /){
+ my ($filterConn, $filterOp);
if (/ SRCH / && / attrs=/ && $_ =~ /filter=\"(.*)\" /i ){
$tmpp = $1;
$tmpp =~ tr/A-Z/a-z/;
$tmpp =~ s/\\22/\"/g;
- writeFile($FILTER, $tmpp);
- $filterVal = $tmpp;
+ $hashes->{filter}->{$tmpp}++;
if ($_ =~ /conn= *([0-9]+)/i) { $filterConn = $1; }
if ($_ =~ /op= *([0-9]+)/i) { $filterOp = $1; }
} elsif (/ SRCH / && $_ =~ /filter=\"(.*)\"/i){
$tmpp = $1;
$tmpp =~ tr/A-Z/a-z/;
$tmpp =~ s/\\22/\"/g;
- writeFile($FILTER, $tmpp);
- $filterVal = $tmpp;
+ $hashes->{filter}->{$tmpp}++;
if ($_ =~ /conn= *([0-9]+)/i) { $filterConn = $1; }
if ($_ =~ /op= *([0-9]+)/i) { $filterOp = $1; }
}
$filterCount++;
if($usage =~ /u/ || $verb eq "yes"){
- # we noly need this for the unindexed search report
- writeFile($FILTERINFO, "$filterVal ,, $filterConn ,, $filterOp");
+ # we only need this for the unindexed search report
+ push @{$arrays->{filterval}}, $tmpp;
+ push @{$arrays->{filterconn}}, $filterConn;
+ push @{$arrays->{filterop}}, $filterOp;
}
}
if ($usage =~ /a/ || $verb eq "yes"){
if (/ SRCH / && $_ =~ /base=\"(.*)\" scope/i ){
+ my ($baseConn, $baseOp, $scopeVal, $scopeConn, $scopeOp);
if ($1 eq ""){
$tmpp = "Root DSE";
} else {
$tmpp = $1;
}
$tmpp =~ tr/A-Z/a-z/;
- writeFile($BASE, $tmpp);
+ $hashes->{base}->{$tmpp}++;
#
# grab the search bases & scope for potential unindexed searches
#
- $baseVal = $tmpp;
if ($_ =~ /scope= *([0-9]+)/i) {
$scopeVal = $1;
}
@@ -2227,9 +2166,13 @@ sub parseLineNormal
$scopeOp = $1;
}
if($usage =~ /u/ || $verb eq "yes"){
- # we noly need this for the unindexed search report
- writeFile($BASEINFO, "$baseVal ,, $baseConn ,, $baseOp");
- writeFile($SCOPEINFO, "$scopeVal ,, $scopeConn ,, $scopeOp");
+ # we only need this for the unindexed search report
+ push @{$arrays->{baseval}}, $tmpp;
+ push @{$arrays->{baseconn}}, $baseConn;
+ push @{$arrays->{baseop}}, $baseOp;
+ push @{$arrays->{scopeval}}, $scopeVal;
+ push @{$arrays->{scopeconn}}, $scopeConn;
+ push @{$arrays->{scopeop}}, $scopeOp;
}
$baseCount++;
$scopeCount++;
@@ -2243,26 +2186,26 @@ sub parseLineNormal
if ($usage =~ /f/ || $verb eq "yes"){
if (/ err=49 tag=/ && / dn=\"/){
if ($_ =~ /dn=\"(.*)\"/i ){
- writeFile($DS6XBADPWD, $1);
+ $hashes->{ds6xbadpwd}->{$1}++;
}
$ds6x = "true";
$badPwdCount++;
} elsif (/ err=49 tag=/ ){
if ($_ =~ /conn= *([0-9]+)/i ){
- writeFile($BADPWDCONN, $1);
+ push @{$arrays->{badpwdconn}}, $1;
$ip = getIPfromConn($1);
$badPwdCount++;
}
if ($_ =~ /op= *([0-9]+)/i ){
- writeFile($BADPWDOP, $1);
+ push @{$arrays->{badpwdop}}, $1;
}
- writeFile($BADPWDIP, $ip);
+ push @{$arrays->{badpwdip}}, $ip;
}
}
if (/ BIND / && /method=sasl/i){
$saslBindCount++;
- if ($_ =~ /mech=(.*)/i ){
- writeFile($SASLMECH, $1);
+ if ($_ =~ /mech=(.*)/i ){
+ $hashes->{saslmech}->{$1}++;
}
}
if (/ conn=Internal op=-1 / && !/ RESULT err=/){ $internalOpCount++; }
@@ -2414,7 +2357,7 @@ displayBindReport
print "\nBind Report\n";
print "====================================================================\n\n";
- foreach $bindDN (sort { $bindReport{$a} <=> $bindReport{$b} } keys %bindReport) {
+ foreach my $bindDN (sort { $bindReport{$a} <=> $bindReport{$b} } keys %bindReport) {
print("Bind DN: $bindDN\n");
print("--------------------------------------------------------------------\n");
print(" Client Addresses:\n\n");
@@ -2430,11 +2373,11 @@ displayBindReport
sub
printClients
{
- @bindConns = &cleanConns(split(' ', @_[0]));
- $IPcount = "1";
+ my @bindConns = &cleanConns(split(' ', $_[0]));
+ my $IPcount = "1";
- foreach $ip ( keys %connList ){ # Loop over all the IP addresses
- foreach $bc (@bindConns){ # Loop over each bind conn number and compare it
+ foreach my $ip ( keys %connList ){ # Loop over all the IP addresses
+ foreach my $bc (@bindConns){ # Loop over each bind conn number and compare it
if($connList{$ip} =~ / $bc /){
print(" [$IPcount] $ip\n");
$IPcount++;
@@ -2447,22 +2390,22 @@ printClients
sub
cleanConns
{
- @dirtyConns = @_;
- $#cleanConns = -1;
- $c = 0;
+ my @dirtyConns = @_;
+ my @retConns = ();
+ my $c = 0;
- for ($i = 0; $i <=$#dirtyConns; $i++){
+ for (my $i = 0; $i <=$#dirtyConns; $i++){
if($dirtyConns[$i] ne ""){
- $cleanConns[$c++] = $dirtyConns[$i];
+ $retConns[$c++] = $dirtyConns[$i];
}
}
- return @cleanConns;
+ return @retConns;
}
sub
printOpStats
{
- $dn = @_[0];
+ my $dn = $_[0];
if( $bindReport{$dn}{"failedBind"} == 0 ){
print(" Binds: " . $bindReport{$dn}{"binds"} . "\n");
@@ -2487,333 +2430,70 @@ printOpStats
sub
openFailed
{
- $open_error = @_[0];
- $file_name = @_[1];
- closeDataFiles();
+ my $open_error = $_[0];
+ my $file_name = $_[1];
removeDataFiles();
die ("Can not open $file_name error ($open_error)");
}
sub
-openDataFiles
+openHashFiles
{
- # hash files
- open ($ATTR, ">$ATTR") or do { openFailed($!, $ATTR) };
- open ($RC, ">$RC") or do { openFailed($!, $RC) };
- open ($SRC, ">$SRC") or do { openFailed($!, $SRC) };
- open ($RSRC, ">$RSRC") or do { openFailed($!, $RSRC) };
- open ($EXCOUNT, ">$EXCOUNT") or do { openFailed($!, $EXCOUNT) };
- open ($CONN_HASH, ">$CONN_HASH") or do { openFailed($!, $CONN_HASH) };
- open ($IP_HASH, ">$IP_HASH") or do { openFailed($!, $IP_HASH) };
- open ($CONNCOUNT, ">$CONNCOUNT") or do { openFailed($!, $CONNCOUNT) };
- open ($NENTRIES, ">$NENTRIES") or do { openFailed($!, $NENTRIES) };
- open ($FILTER, ">$FILTER") or do { openFailed($!, $FILTER) };
- open ($BASE, ">$BASE") or do { openFailed($!, $BASE) };
- open ($DS6XBADPWD, ">$DS6XBADPWD") or do { openFailed($!, $DS6XBADPWD) };
- open ($SASLMECH, ">$SASLMECH") or do { openFailed($!, $SASLMECH) };
- open ($BINDLIST, ">$BINDLIST") or do { openFailed($!, $BINDLIST) };
- open ($ETIME, ">$ETIME") or do { openFailed($!, $ETIME) };
- open ($OID, ">$OID") or do { openFailed($!, $OID) };
-
- # array files
- open($SRCH_CONN,">$SRCH_CONN") or do { openFailed($!, $SRCH_CONN) };
- open($SRCH_OP, ">$SRCH_OP") or do { openFailed($!, $SRCH_OP) };
- open($DEL_CONN, ">$DEL_CONN") or do { openFailed($!, $DEL_CONN) };
- open($DEL_OP, ">$DEL_OP") or do { openFailed($!, $DEL_OP) };
- open($MOD_CONN, ">$MOD_CONN") or do { openFailed($!, $MOD_CONN) };
- open($MOD_OP, ">$MOD_OP") or do { openFailed($!, $MOD_OP) };
- open($ADD_CONN, ">$ADD_CONN") or do { openFailed($!, $ADD_CONN) };
- open($ADD_OP, ">$ADD_OP") or do { openFailed($!, $ADD_OP) };
- open($MODRDN_CONN, ">$MODRDN_CONN") or do { openFailed($!, $MODRDN_CONN) };
- open($MODRDN_OP, ">$MODRDN_OP") or do { openFailed($!, $MODRDN_OP) };
- open($CMP_CONN, ">$CMP_CONN") or do { openFailed($!, $CMP_CONN) };
- open($CMP_OP,">$CMP_OP") or do { openFailed($!, $CMP_OP) };
- open($TARGET_CONN, ">$TARGET_CONN") or do { openFailed($!, $TARGET_CONN) };
- open($TARGET_OP, ">$TARGET_OP") or do { openFailed($!, $TARGET_OP) };
- open($MSGID, ">$MSGID") or do { openFailed($!, $MSGID) };
- open($BIND_CONN, ">$BIND_CONN") or do { openFailed($!, $BIND_CONN) };
- open($BIND_OP, ">$BIND_OP") or do { openFailed($!, $BIND_OP) };
- open($UNBIND_CONN, ">$UNBIND_CONN") or do { openFailed($!, $UNBIND_CONN) };
- open($UNBIND_OP, ">$UNBIND_OP") or do { openFailed($!, $UNBIND_OP) };
- open($EXT_CONN, ">$EXT_CONN") or do { openFailed($!, $EXT_CONN) };
- open($EXT_OP, ">$EXT_OP") or do { openFailed($!, $EXT_OP) };
- open($NOTES_A_ETIME, ">$NOTES_A_ETIME") or do { openFailed($!, $NOTES_A_ETIME) };
- open($NOTES_A_CONN, ">$NOTES_A_CONN") or do { openFailed($!, $NOTES_A_CONN) };
- open($NOTES_A_OP, ">$NOTES_A_OP") or do { openFailed($!, $NOTES_A_OP) };
- open($NOTES_A_TIME, ">$NOTES_A_TIME") or do { openFailed($!, $NOTES_A_TIME) };
- open($NOTES_A_NENTRIES, ">$NOTES_A_NENTRIES") or do { openFailed($!, $NOTES_A_NENTRIES) };
- open($NOTES_U_ETIME, ">$NOTES_U_ETIME") or do { openFailed($!, $NOTES_U_ETIME) };
- open($NOTES_U_CONN, ">$NOTES_U_CONN") or do { openFailed($!, $NOTES_U_CONN) };
- open($NOTES_U_OP, ">$NOTES_U_OP") or do { openFailed($!, $NOTES_U_OP) };
- open($NOTES_U_TIME, ">$NOTES_U_TIME") or do { openFailed($!, $NOTES_U_TIME) };
- open($NOTES_U_NENTRIES, ">$NOTES_U_NENTRIES") or do { openFailed($!, $NOTES_U_NENTRIES) };
- open($BADPWDCONN, ">$BADPWDCONN") or do { openFailed($!, $BADPWDCONN) };
- open($BADPWDOP, ">$BADPWDOP") or do { openFailed($!, $BADPWDOP) };
- open($BADPWDIP, ">$BADPWDIP") or do { openFailed($!, $NADPWDIP) };
-
- # info files
- open($BINDINFO, ">$BINDINFO") or do { openFailed($!, $BINDINFO) };
- open($BASEINFO, ">$BASEINFO") or do { openFailed($!, $BASEINFO) };
- open($SCOPEINFO, ">$SCOPEINFO") or do { openFailed($!, $SCOPEINFO) };
- open($FILTERINFO, ">$FILTERINFO") or do { openFailed($!, $FILTERINFO) };
-}
-
-sub
-closeDataFiles
-{
- close $ATTR;
- close $RC;
- close $SRC;
- close $RSRC;
- close $EXCOUNT;
- close $CONN_HASH;
- close $IP_HASH;
- close $CONNCOUNT;
- close $NENTRIES;
- close $FILTER;
- close $BASE;
- close $DS6XBADPWD;
- close $SASLMECH;
- close $BINDLIST;
- close $ETIME;
- close $OID;
-
- # array files
- close $SRCH_CONN;
- close $SRCH_OP;
- close $DEL_CONN;
- close $DEL_OP;
- close $MOD_CONN;
- close $MOD_OP;
- close $ADD_CONN;
- close $ADD_OP;
- close $MODRDN_CONN;
- close $MODRDN_OP;
- close $CMP_CONN;
- close $CMP_OP;
- close $TARGET_CONN;
- close $TARGET_OP;
- close $MSGID;
- close $BIND_CONN;
- close $BIND_OP;
- close $UNBIND_CONN;
- close $UNBIND_OP;
- close $EXT_CONN;
- close $EXT_OP;
- close $NOTES_A_ETIME;
- close $NOTES_A_CONN;
- close $NOTES_A_OP;
- close $NOTES_A_TIME;
- close $NOTES_A_NENTRIES;
- close $NOTES_U_ETIME;
- close $NOTES_U_CONN;
- close $NOTES_U_OP;
- close $NOTES_U_TIME;
- close $NOTES_U_NENTRIES;
- close $BADPWDCONN;
- close $BADPWDOP;
- close $BADPWDIP;
-
- # info files
- close $BINDINFO;
- close $BASEINFO;
- close $SCOPEINFO;
- close $FILTERINFO;
-}
-
-sub
-removeDataFiles
-{
- unlink $ATTR;
- unlink $RC;
- unlink $SRC;
- unlink $RSRC;
- unlink $EXCOUNT;
- unlink $CONN_HASH;
- unlink $IP_HASH;
- unlink $CONNCOUNT;
- unlink $NENTRIES;
- unlink $FILTER;
- unlink $BASE;
- unlink $DS6XBADPWD;
- unlink $SASLMECH;
- unlink $BINDLIST;
- unlink $ETIME;
- unlink $OID;
-
- # array files
- unlink $SRCH_CONN;
- unlink $SRCH_OP;
- unlink $DEL_CONN;
- unlink $DEL_OP;
- unlink $MOD_CONN;
- unlink $MOD_OP;
- unlink $ADD_CONN;
- unlink $ADD_OP;
- unlink $MODRDN_CONN;
- unlink $MODRDN_OP;
- unlink $CMP_CONN;
- unlink $CMP_OP;
- unlink $TARGET_CONN;
- unlink $TARGET_OP;
- unlink $MSGID;
- unlink $BIND_CONN;
- unlink $BIND_OP;
- unlink $UNBIND_CONN;
- unlink $UNBIND_OP;
- unlink $EXT_CONN;
- unlink $EXT_OP;
- unlink $NOTES_A_ETIME;
- unlink $NOTES_A_CONN;
- unlink $NOTES_A_OP;
- unlink $NOTES_A_TIME;
- unlink $NOTES_A_NENTRIES;
- unlink $NOTES_U_ETIME;
- unlink $NOTES_U_CONN;
- unlink $NOTES_U_OP;
- unlink $NOTES_U_TIME;
- unlink $NOTES_U_NENTRIES;
- unlink $BADPWDCONN;
- unlink $BADPWDOP;
- unlink $BADPWDIP;
-
- # info files
- unlink $BINDINFO;
- unlink $BASEINFO;
- unlink $SCOPEINFO;
- unlink $FILTERINFO;
-}
-
-sub
-getIPfromConn
-{
- $connip = @_[0];
- $retval = "";
-
- close $CONN_HASH; # we can not read the file is its already open
- open(CONN,"$CONN_HASH") or do { openFailed($!, $CONN_HASH) };
- while (<CONN>){
- if($_ =~ /$connip (.*)/){
- $retval = $1;
- last;
- }
+ my $dir = shift;
+ my %hashes = ();
+ for my $hn (@_) {
+ my %h = (); # using my in inner loop will create brand new hash every time through for tie
+ my $fn = "$dir/$hn.logconv.db";
+ push @removefiles, $fn;
+ tie %h, "DB_File", $fn, O_CREAT|O_RDWR, 0600, $DB_HASH or do { openFailed($!, $fn) };
+ $hashes{$hn} = \%h;
}
- close CONN;
- #reopen file for writing(append)
- open($CONN_HASH,">>$CONN_HASH") or do { openFailed($!, $CONN_HASH) };
-
- return $retval;
-}
-
-sub
-writeFile
-{
- $file = @_[0];
- $text = @_[1] . "\n";
-
- print $file $text;
+ return \%hashes;
}
-# This hash file stores one value per line
sub
-getCounterHashFromFile
+openArrayFiles
{
- $file = @_[0];
- my %hash = ();
-
- open(FILE,"$file") or do { openFailed($!, $file) };
- while(<FILE>){
- chomp;
- $hash{$_}++;
+ my $dir = shift;
+ my %arrays = ();
+ for my $an (@_) {
+ my @ary = (); # using my in inner loop will create brand new array every time through for tie
+ my $fn = "$dir/$an.logconv.db";
+ push @removefiles, $fn;
+ tie @ary, "DB_File", $fn, O_CREAT|O_RDWR, 0600, $DB_RECNO or do { openFailed($!, $fn) };
+ $arrays{$an} = \@ary;
}
- close FILE;
-
- return %hash;
+ return \%arrays;
}
-# this hash file stores two values per line (2 dimension hash)
sub
-getTwoDimHashFromFile
+removeDataFiles
{
- $file = @_[0];
- my %hash = ();
+ if (!$needCleanup) { return ; }
- open(FILE,"$file") or do { openFailed($!, $file) };
- while(<FILE>){
- @parts = split (' ', $_);
- chomp(@parts);
- $hash{$parts[0]}{$parts[1]}++;
+ for my $h (keys %{$hashes}) {
+ untie %{$hashes->{$h}};
}
- close FILE;
-
- return %hash;
-}
-
-# this hash file stores two values per line (1 dimension hash)
-sub
-getHashFromFile
-{
- $file = @_[0];
- my %hash = ();
- @parts = ();
-
- open(FILE,"$file") or do { openFailed($!, $file ) };
- while(<FILE>){
- @parts = split (' ',$_);
- chomp(@parts);
- $hash{$parts[0]} = $parts[1];
+ for my $a (keys %{$arrays}) {
+ untie @{$arrays->{$a}};
}
- close FILE;
-
- return %hash;
-}
-
-# Return array of values from the file
-sub
-getArrayFromFile
-{
- my @arry;
- $file = @_[0];
- $array_count = 0;
-
- open(FILE,"$file") or do { openFailed($!, $file) };
- while(<FILE>){
- chomp;
- $arry[$array_count] = $_;
- $array_count++;
+ for my $file (@removefiles) {
+ unlink $file;
}
- close FILE;
-
- return @arry;
+ $needCleanup = 0;
}
-# build the three array
+END { print "Cleaning up temp files . . .\n"; removeDataFiles(); print "Done\n"; }
+
sub
-getInfoArraysFromFile
+getIPfromConn
{
- $file = @_[0];
- $array_count = 0;
- @parts = ();
-
- open(FILE,"<$file") or do { openFailed($!, $file) };
- while(<FILE>){
- @parts = split (' ,, ',$_);
- chomp(@parts);
- if($#parts > 0){
- $fileArray1[$array_count] = $parts[0];
- $fileArray2[$array_count] = $parts[1];
- $fileArray3[$array_count] = $parts[2];
- $array_count++;
- }
- }
- close FILE;
+ my $connid = shift;
+ return $hashes->{conn_hash}->{$connid};
}
-
-
#######################################
# #
# The End #
# #
#######################################
-
10 years, 10 months
Branch '389-ds-base-1.2.11' - ldap/servers
by Noriko Hosoi
ldap/servers/plugins/replication/urp.c | 18 +++-----
ldap/servers/slapd/back-ldbm/ldbm_delete.c | 35 +++++++++++-----
ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c | 2
ldap/servers/slapd/back-ldbm/ldbm_search.c | 2
ldap/servers/slapd/dn.c | 59 ++++++++++++++++++++++++---
ldap/servers/slapd/rdn.c | 24 +++-------
ldap/servers/slapd/slapi-plugin.h | 18 ++++++++
7 files changed, 116 insertions(+), 42 deletions(-)
New commits:
commit c2c64017e0e25a4376139debe29b4f587964710f
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Thu Jun 6 16:52:14 2013 -0700
Ticket #47367 - (phase 1) ldapdelete returns non-leaf entry error while trying to remove a leaf entry
Bug description: Replication conflict confuses the numsubordinate
count, which leaves an entry that cannot be deleted even its
subordinate entries are all removed.
Fix description:
[urp.c] get_dn_plus_uniqueid: a logic to create a conflict DN
had a bug. It used to call slapi_sdn_get_rdn to get the rdn.
The function slapi_sdn_get_rdn blindly returned the "dn" field
without checking whether the field is NULL or not. Instead,
this patch changes the interface of the helper function get_
dn_plus_uniqueid and use the original Slapi_DN with slapi_
sdn_get_dn, then generates the conflict DN "nsuniqueid=...+
<RDN>,<PARENT>".
[ldbm_delete.c] There is a case a parent of a delete-candidate
entry runs into a conflict and multiple parent entries exist.
Once it occurs, a parent entry found by the parent dn string
may not be the entry which manages the numsubordinate count
the delete-candidate entry belonging to. It confuses the
numsubordinate counts and leaves an entry which cannot be
deleted due to the numsubordinate count mismatch. This patch
retrieves parent entry by parent id if it is available.
[ldbm_entryrdn.c] When traversing the DIT, a special treatment
is needed for a tombstone entry. I.e, 2 RDNs (nsuniqueid=...,
<RDN>) is treated as one RDN. It should decrement the index
(rdnidx) one more to point to the right position of the RDN
array in Slapi_RDN.
[ldbm_search.c] When checking the scope of an entry in ldbm_
back_next_search_entry_ext, a tombstone entry was not properly
examined. This patch introduces a new slapi api slapi_sdn_
scope_test_ext.
[dn.c] In slapi_sdn_get_rdn, use slapi_sdn_get_dn to get the
dn value of Slapi_DN. It was one cause of the problem in
get_dn_plus_uniqueid (urp.c).
This patch adds slapi_sdn_scope_test_ext, which takes flags
to indicates the first argument dn is a tombstone sdn.
Also, this patch replaces "malloc + strcpy + strcat" with
slapi_ch_smprintf to improve the readability of the code.
[rdn.c] This patch replaces "malloc + strcpy + strcat" with
slapi_create_dn_string to normalize the newly added rdn and
improve the readability of the code.
Reviewed by Rich (Thank you!!)
https://fedorahosted.org/389/ticket/47367
diff --git a/ldap/servers/plugins/replication/urp.c b/ldap/servers/plugins/replication/urp.c
index 1d8799a..e236541 100644
--- a/ldap/servers/plugins/replication/urp.c
+++ b/ldap/servers/plugins/replication/urp.c
@@ -57,7 +57,7 @@ static int urp_annotate_dn (char *sessionid, Slapi_Entry *entry, CSN *opcsn, con
static int urp_naming_conflict_removal (Slapi_PBlock *pb, char *sessionid, CSN *opcsn, const char *optype);
static int mod_namingconflict_attr (const char *uniqueid, const Slapi_DN *entrysdn, const Slapi_DN *conflictsdn, CSN *opcsn);
static int del_replconflict_attr (Slapi_Entry *entry, CSN *opcsn, int opflags);
-static char *get_dn_plus_uniqueid(char *sessionid,const char *olddn,const char *uniqueid);
+static char *get_dn_plus_uniqueid(char *sessionid,const Slapi_DN *oldsdn,const char *uniqueid);
static char *get_rdn_plus_uniqueid(char *sessionid,const char *olddn,const char *uniqueid);
static int is_suffix_entry (Slapi_PBlock *pb, Slapi_Entry *entry, Slapi_DN **parenddn);
@@ -180,7 +180,7 @@ urp_add_operation( Slapi_PBlock *pb )
if (r<0)
{
/* Entry to be added is a loser */
- char *newdn= get_dn_plus_uniqueid (sessionid, basedn, adduniqueid);
+ char *newdn = get_dn_plus_uniqueid (sessionid, (const Slapi_DN *)addentry, adduniqueid);
if(newdn==NULL)
{
op_result= LDAP_OPERATIONS_ERROR;
@@ -1222,16 +1222,15 @@ bailout:
/* The returned value is either null or "uniqueid=<uniqueid>+<basedn>" */
static char *
-get_dn_plus_uniqueid(char *sessionid, const char *olddn, const char *uniqueid)
+get_dn_plus_uniqueid(char *sessionid, const Slapi_DN *oldsdn, const char *uniqueid)
{
- Slapi_DN *sdn= slapi_sdn_new_dn_byval(olddn);
Slapi_RDN *rdn= slapi_rdn_new();
char *newdn;
PR_ASSERT(uniqueid!=NULL);
/* Check if the RDN already contains the Unique ID */
- slapi_sdn_get_rdn(sdn,rdn);
+ slapi_rdn_set_dn(rdn, slapi_sdn_get_dn(oldsdn));
if(slapi_rdn_contains(rdn,SLAPI_ATTR_UNIQUEID,uniqueid,strlen(uniqueid)))
{
/* The Unique ID is already in the RDN.
@@ -1241,16 +1240,15 @@ get_dn_plus_uniqueid(char *sessionid, const char *olddn, const char *uniqueid)
* require admin intercession
*/
slapi_log_error(SLAPI_LOG_FATAL, sessionid,
- "Annotated DN %s has naming conflict\n", olddn );
+ "Annotated DN %s has naming conflict\n", slapi_sdn_get_dn(oldsdn) );
newdn= NULL;
}
else
{
- slapi_rdn_add(rdn,SLAPI_ATTR_UNIQUEID,uniqueid);
- slapi_sdn_set_rdn(sdn, rdn);
- newdn= slapi_ch_strdup(slapi_sdn_get_dn(sdn));
+ char *parentdn = slapi_dn_parent(slapi_sdn_get_dn(oldsdn));
+ slapi_rdn_add(rdn, SLAPI_ATTR_UNIQUEID, uniqueid);
+ newdn = slapi_ch_smprintf("%s,%s", slapi_rdn_get_rdn(rdn), parentdn);
}
- slapi_sdn_free(&sdn);
slapi_rdn_free(&rdn);
return newdn;
}
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_delete.c b/ldap/servers/slapd/back-ldbm/ldbm_delete.c
index 528693e..d80c54e 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_delete.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_delete.c
@@ -242,14 +242,12 @@ ldbm_back_delete( Slapi_PBlock *pb )
*/
is_tombstone_entry = slapi_entry_flag_is_set(e->ep_entry, SLAPI_ENTRY_FLAG_TOMBSTONE);
if (delete_tombstone_entry) {
- PR_ASSERT(is_tombstone_entry);
if (!is_tombstone_entry) {
slapi_log_error(SLAPI_LOG_FATAL, "ldbm_back_delete",
"Attempt to delete a non-tombstone entry %s\n", dn);
delete_tombstone_entry = 0;
}
} else {
- PR_ASSERT(!is_tombstone_entry);
if (is_tombstone_entry) {
slapi_log_error(SLAPI_LOG_FATAL, "ldbm_back_delete",
"Attempt to Tombstone again a tombstone entry %s\n", dn);
@@ -328,12 +326,31 @@ ldbm_back_delete( Slapi_PBlock *pb )
if ( !slapi_sdn_isempty(&parentsdn) )
{
struct backentry *parent = NULL;
- entry_address parent_addr;
+ char *pid_str = slapi_entry_attr_get_charptr(e->ep_entry, LDBM_PARENTID_STR);
+ if (pid_str) {
+ /* First, try to get the direct parent. */
+ /*
+ * Although a rare case, multiple parents from repl conflict could exist.
+ * In such case, if a parent entry is found just by parentsdn
+ * (find_entry2modify_only_ext), a wrong parent could be found,
+ * and numsubordinate count could get confused.
+ */
+ ID pid = (ID)strtol(pid_str, (char **)NULL, 10);
+ parent = id2entry(be, pid ,NULL, &retval);
+ if (parent && cache_lock_entry(&inst->inst_cache, parent)) {
+ /* Failed to obtain parent entry's entry lock */
+ CACHE_RETURN(&(inst->inst_cache), &parent);
+ goto error_return;
+ }
+ }
+ if (NULL == parent) {
+ entry_address parent_addr;
- parent_addr.sdn = &parentsdn;
- parent_addr.uniqueid = NULL;
- parent = find_entry2modify_only_ext(pb, be, &parent_addr,
- TOMBSTONE_INCLUDED, &txn);
+ parent_addr.sdn = &parentsdn;
+ parent_addr.uniqueid = NULL;
+ parent = find_entry2modify_only_ext(pb, be, &parent_addr,
+ TOMBSTONE_INCLUDED, &txn);
+ }
if (NULL != parent) {
int isglue;
size_t haschildren = 0;
@@ -1171,9 +1188,9 @@ common_return:
}
diskfull_return:
- if(ldap_result_code!=-1)
+ if(ldap_result_code!=-1)
{
- slapi_send_ldap_result( pb, ldap_result_code, NULL, ldap_result_message, 0, NULL );
+ slapi_send_ldap_result( pb, ldap_result_code, NULL, ldap_result_message, 0, NULL );
}
modify_term(&parent_modify_c,be);
if(dblock_acquired)
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c b/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c
index f3823cb..156461b 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c
@@ -3152,6 +3152,7 @@ _entryrdn_index_read(backend *be,
/* Node might be a tombstone. */
rc = _entryrdn_get_tombstone_elem(cursor, tmpsrdn,
&key, nrdn, elem);
+ rdnidx--; /* consider nsuniqueid=..,<RDN> one RDN */
}
if (rc || NULL == *elem) {
slapi_log_error(SLAPI_LOG_BACKLDBM, ENTRYRDN_TAG,
@@ -3258,6 +3259,7 @@ _entryrdn_index_read(backend *be,
}
goto bail;
}
+ rdnidx--; /* consider nsuniqueid=..,<RDN> one RDN */
} else {
slapi_ch_free((void **)&tmpelem);
if (DB_NOTFOUND != rc) {
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_search.c b/ldap/servers/slapd/back-ldbm/ldbm_search.c
index c61dcce..e68b897 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_search.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_search.c
@@ -1602,7 +1602,7 @@ ldbm_back_next_search_entry_ext( Slapi_PBlock *pb, int use_extension )
* just forget about it, since we don't want to return anything at all. */
{
if ( slapi_uniqueIDCompareString(target_uniqueid, e->ep_entry->e_uniqueid) ||
- slapi_sdn_scope_test( backentry_get_sdn(e), basesdn, scope ))
+ slapi_sdn_scope_test_ext( backentry_get_sdn(e), basesdn, scope, e->ep_entry->e_flags ))
{
/* check size limit */
if ( slimit >= 0 )
diff --git a/ldap/servers/slapd/dn.c b/ldap/servers/slapd/dn.c
index b40b6a0..dda439b 100644
--- a/ldap/servers/slapd/dn.c
+++ b/ldap/servers/slapd/dn.c
@@ -2114,10 +2114,7 @@ slapi_sdn_add_rdn(Slapi_DN *sdn, const Slapi_RDN *rdn)
{
/* NewDN= NewRDN + DN */
const char *dn= slapi_sdn_get_dn(sdn);
- char *newdn= slapi_ch_malloc(strlen(rawrdn)+1+strlen(dn)+1);
- strcpy( newdn, rawrdn );
- strcat( newdn, "," );
- strcat( newdn, dn );
+ char *newdn = slapi_ch_smprintf("%s,%s", rawrdn, dn);
slapi_sdn_set_dn_passin(sdn,newdn);
}
return sdn;
@@ -2345,7 +2342,7 @@ slapi_sdn_get_backend_parent(const Slapi_DN *sdn,Slapi_DN *sdn_parent,const Slap
void
slapi_sdn_get_rdn(const Slapi_DN *sdn,Slapi_RDN *rdn)
{
- slapi_rdn_set_dn(rdn,sdn->dn);
+ slapi_rdn_set_dn(rdn, slapi_sdn_get_dn(sdn));
}
Slapi_DN *
@@ -2516,6 +2513,47 @@ slapi_sdn_scope_test( const Slapi_DN *dn, const Slapi_DN *base, int scope )
return rc;
}
+/*
+ * Return non-zero if "dn" matches the scoping criteria
+ * given by "base" and "scope".
+ * If SLAPI_ENTRY_FLAG_TOMBSTONE is set to flags,
+ * DN without "nsuniqueid=...," is examined.
+ */
+int
+slapi_sdn_scope_test_ext( const Slapi_DN *dn, const Slapi_DN *base, int scope, int flags )
+{
+ int rc = 0;
+
+ switch ( scope ) {
+ case LDAP_SCOPE_BASE:
+ if (flags & SLAPI_ENTRY_FLAG_TOMBSTONE) {
+ Slapi_DN parent;
+ slapi_sdn_init(&parent);
+ slapi_sdn_get_parent(dn, &parent);
+ rc = ( slapi_sdn_compare( dn, &parent ) == 0 );
+ slapi_sdn_done(&parent);
+ } else {
+ rc = ( slapi_sdn_compare( dn, base ) == 0 );
+ }
+ break;
+ case LDAP_SCOPE_ONELEVEL:
+ if (flags & SLAPI_ENTRY_FLAG_TOMBSTONE) {
+ Slapi_DN parent;
+ slapi_sdn_init(&parent);
+ slapi_sdn_get_parent(dn, &parent);
+ rc = ( slapi_sdn_isparent( base, &parent ) != 0 );
+ slapi_sdn_done(&parent);
+ } else {
+ rc = ( slapi_sdn_isparent( base, dn ) != 0 );
+ }
+ break;
+ case LDAP_SCOPE_SUBTREE:
+ rc = ( slapi_sdn_issuffix( dn, base ) != 0 );
+ break;
+ }
+ return rc;
+}
+
/*
* build the new dn of an entry for moddn operations
*/
@@ -2563,8 +2601,17 @@ size_t
slapi_sdn_get_size(const Slapi_DN *sdn)
{
size_t sz = sizeof(Slapi_DN);
+ /* slapi_sdn_get_ndn_len returns the normalized dn length
+ * if dn or ndn exists. If both does not exist, it
+ * normalizes udn and set it to dn and returns the length.
+ */
sz += slapi_sdn_get_ndn_len(sdn);
- sz += strlen(sdn->dn) + 1;
+ if (sdn->dn && sdn->ndn) {
+ sz += slapi_sdn_get_ndn_len(sdn);
+ }
+ if (sdn->udn) {
+ sz += strlen(sdn->udn) + 1;
+ }
return sz;
}
diff --git a/ldap/servers/slapd/rdn.c b/ldap/servers/slapd/rdn.c
index d408f0e..fe2fae0 100644
--- a/ldap/servers/slapd/rdn.c
+++ b/ldap/servers/slapd/rdn.c
@@ -479,25 +479,17 @@ slapi_rdn_add(Slapi_RDN *rdn, const char *type, const char *value)
PR_ASSERT(NULL != value);
if(rdn->rdn==NULL)
{
- /* type=value '\0' */
- rdn->rdn= slapi_ch_malloc(strlen(type)+1+strlen(value)+1);
- strcpy( rdn->rdn, type );
- strcat( rdn->rdn, "=" );
- strcat( rdn->rdn, value );
+ /* type=value '\0' */
+ rdn->rdn = slapi_create_dn_string("%s=%s", type, value);
}
else
{
- /* type=value+rdn '\0' */
- char *newrdn= slapi_ch_malloc(strlen(type)+1+strlen(value)+1+strlen(rdn->rdn)+1);
- strcpy( newrdn, type );
- strcat( newrdn, "=" );
- strcat( newrdn, value );
- strcat( newrdn, "+" );
- strcat( newrdn, rdn->rdn );
- slapi_ch_free((void**)&rdn->rdn);
- rdn->rdn= newrdn;
- }
- slapi_unsetbit_uchar(rdn->flag,FLAG_RDNS);
+ /* type=value+rdn '\0' */
+ char *newrdn = slapi_create_dn_string("%s=%s+%s", type, value, rdn->rdn);
+ slapi_ch_free_string(&rdn->rdn);
+ rdn->rdn = newrdn;
+ }
+ slapi_unsetbit_uchar(rdn->flag,FLAG_RDNS);
return 1;
}
diff --git a/ldap/servers/slapd/slapi-plugin.h b/ldap/servers/slapd/slapi-plugin.h
index 4e7aae5..4a2544e 100644
--- a/ldap/servers/slapd/slapi-plugin.h
+++ b/ldap/servers/slapd/slapi-plugin.h
@@ -2698,6 +2698,24 @@ int slapi_sdn_get_ndn_len(const Slapi_DN *sdn);
int slapi_sdn_scope_test( const Slapi_DN *dn, const Slapi_DN *base, int scope );
/**
+ * Checks if a DN is within a specified scope under a specified base DN.
+ * This api adjusts tombstoned DN when comparing with the base dn.
+ *
+ * \param dn A pointer to the \c Slapi_DN structure to test.
+ * \param base The base DN against which \c dn is going to be tested.
+ * \param scope The scope tested. Valid scopes are:
+ * \arg \c LDAP_SCOPE_BASE
+ * \arg \c LDAP_SCOPE_ONELEVEL
+ * \arg \c LDAP_SCOPE_SUBTREE
+ * \param flags 0 or SLAPI_ENTRY_FLAG_TOMBSTONE
+ * \return non-zero if \c dn matches the scoping criteria given by \c base and \c scope.
+ * \see slapi_sdn_compare()
+ * \see slapi_sdn_isparent()
+ * \see slapi_sdn_issuffix()
+ */
+int slapi_sdn_scope_test_ext( const Slapi_DN *dn, const Slapi_DN *base, int scope, int flags );
+
+/**
* Retreives the RDN from a given DN.
*
* This function takes the DN stored in the \c Slapi_DN structure pointed to
10 years, 10 months
ldap/servers
by thierry bordaz
ldap/servers/plugins/replication/repl5_replica.c | 73 +++++++++++++----------
ldap/servers/plugins/replication/repl5_ruv.c | 31 +++++++++
ldap/servers/plugins/replication/repl5_ruv.h | 1
ldap/servers/slapd/back-ldbm/dblayer.c | 1
ldap/servers/slapd/back-ldbm/ldbm_config.c | 2
ldap/servers/slapd/plugin.c | 11 +++
ldap/servers/slapd/slapi-plugin.h | 2
7 files changed, 91 insertions(+), 30 deletions(-)
New commits:
commit 7f5268f6f41d74655ee86d948b8ea301adb0138a
Author: Thierry bordaz (tbordaz) <tbordaz(a)redhat.com>
Date: Wed Jun 5 11:09:25 2013 +0200
Ticket 564 - Is ldbm_txn_ruv_modify_context still required
Bug description
Ticket 47358 introduces backend optimizations using a configuration switch.
By default all optimisation are disabled.
One optimisation is related to changelog and DB RUV being written back to disk in the same txn with the same value.
This is a consequence of bug fix 543633. Although the write back of the DB RUV brings a little overhead
it is not strictly required. In fact since 633168, changelog RUV is in sync with the data store. So
changelog RUV and DB RUV have the same values.
Fix Description:
This fix enables by default the ticket 47358 optimization BACKEND_OPT_NO_RUV_UPDATE that does
not compute/update the database RUV.
Two consequences of this are:
1. In case of disordely shutdown (crash) and after recovery, we need to rebuild the DB RUV
2. Provide a mechanism to monitor replication status, as DB ruv would be late compare
to the current update status
1. is achieve using the changelog RUV (in sync with the data store) to rebuild the database RUV.
2. was done with ticket https://fedorahosted.org/389/ticket/47350
https://fedorahosted.org/389/ticket/564
Reviewed by: Rich, Ludwig (thanks to you both !)
Platforms tested: fedora 17
Flag Day: no
Doc impact: no
diff --git a/ldap/servers/plugins/replication/repl5_replica.c b/ldap/servers/plugins/replication/repl5_replica.c
index f9914e4..8121901 100644
--- a/ldap/servers/plugins/replication/repl5_replica.c
+++ b/ldap/servers/plugins/replication/repl5_replica.c
@@ -1494,41 +1494,56 @@ int replica_check_for_data_reload (Replica *r, void *arg)
* sessions.
*/
- rc = ruv_compare_ruv(upper_bound_ruv, "changelog max RUV", r_ruv, "database RUV", 0, SLAPI_LOG_FATAL);
- if (RUV_COMP_IS_FATAL(rc))
- {
- /* create a temporary replica object to conform to the interface */
- r_obj = object_new (r, NULL);
-
- /* We can't use existing changelog - remove existing file */
+ if (slapi_disordely_shutdown(PR_FALSE)) {
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name, "replica_check_for_data_reload: "
- "Warning: data for replica %s does not match the data in the changelog. "
- "Recreating the changelog file. "
- "This could affect replication with replica's consumers in which case the "
- "consumers should be reinitialized.\n",
+ "Warning: disordely shutdown for replica %s. Check if DB RUV needs to be updated\n",
slapi_sdn_get_dn(r->repl_root));
+
+ if (ruv_covers_ruv(upper_bound_ruv, r_ruv) && !ruv_covers_ruv(r_ruv, upper_bound_ruv)) {
+ /*
+ * The Changelog RUV is ahead of the RUV in the DB.
+ * RUV DB was likely not flushed on disk.
+ */
+
+ ruv_force_csn_update_from_ruv(upper_bound_ruv, r_ruv,
+ "Force update of database RUV (from CL RUV) -> ", SLAPI_LOG_FATAL);
+ replica_set_ruv_dirty(r);
+ }
+
+ } else {
- rc = cl5DeleteDBSync (r_obj);
+ rc = ruv_compare_ruv(upper_bound_ruv, "changelog max RUV", r_ruv, "database RUV", 0, SLAPI_LOG_FATAL);
+ if (RUV_COMP_IS_FATAL(rc)) {
+ /* create a temporary replica object to conform to the interface */
+ r_obj = object_new(r, NULL);
- object_release (r_obj);
+ /* We can't use existing changelog - remove existing file */
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name, "replica_check_for_data_reload: "
+ "Warning: data for replica %s does not match the data in the changelog. "
+ "Recreating the changelog file. "
+ "This could affect replication with replica's consumers in which case the "
+ "consumers should be reinitialized.\n",
+ slapi_sdn_get_dn(r->repl_root));
- if (rc == CL5_SUCCESS)
- {
- /* log changes to mark starting point for replication */
- rc = replica_log_ruv_elements (r);
+ rc = cl5DeleteDBSync(r_obj);
+
+ object_release(r_obj);
+
+ if (rc == CL5_SUCCESS) {
+ /* log changes to mark starting point for replication */
+ rc = replica_log_ruv_elements(r);
+ }
+ } else if (rc) {
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name, "replica_check_for_data_reload: "
+ "Warning: for replica %s there were some differences between the changelog max RUV and the "
+ "database RUV. If there are obsolete elements in the database RUV, you "
+ "should remove them using the CLEANALLRUV task. If they are not obsolete, "
+ "you should check their status to see why there are no changes from those "
+ "servers in the changelog.\n",
+ slapi_sdn_get_dn(r->repl_root));
+ rc = 0;
}
- }
- else if (rc)
- {
- slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name, "replica_check_for_data_reload: "
- "Warning: for replica %s there were some differences between the changelog max RUV and the "
- "database RUV. If there are obsolete elements in the database RUV, you "
- "should remove them using the CLEANALLRUV task. If they are not obsolete, "
- "you should check their status to see why there are no changes from those "
- "servers in the changelog.\n",
- slapi_sdn_get_dn(r->repl_root));
- rc = 0;
- }
+ } // slapi_disordely_shutdown
object_release (ruv_obj);
}
diff --git a/ldap/servers/plugins/replication/repl5_ruv.c b/ldap/servers/plugins/replication/repl5_ruv.c
index 43f2c84..bc2a270 100644
--- a/ldap/servers/plugins/replication/repl5_ruv.c
+++ b/ldap/servers/plugins/replication/repl5_ruv.c
@@ -2255,6 +2255,37 @@ ruv_is_newer (Object *sruvobj, Object *cruvobj)
return is_newer;
}
+/*
+ * This routine is called after a disordely shutdown
+ * The Database RUV was found late compare to the changelog RUV
+ */
+void
+ruv_force_csn_update_from_ruv(RUV *src_ruv, RUV *tgt_ruv, char *msg, int logLevel) {
+ RUVElement *replica = NULL;
+ char csnStr [CSN_STRSIZE];
+ int cookie;
+
+ slapi_rwlock_rdlock(src_ruv->lock);
+
+ for (replica = dl_get_first(src_ruv->elements, &cookie);
+ NULL != replica;
+ replica = dl_get_next(src_ruv->elements, &cookie)) {
+ /*
+ * In case the DB RUV (tgt_ruv) is behind the CL RUV (src_ruv)
+ * updates the DB RUV.
+ */
+ if (!ruv_covers_csn(tgt_ruv, replica->csn)) {
+ ruv_force_csn_update(tgt_ruv, replica->csn);
+ csn_as_string(replica->csn, PR_FALSE, csnStr);
+ slapi_log_error(logLevel, repl_plugin_name, "%s %s\n",
+ msg, csnStr);
+ }
+ }
+
+ slapi_rwlock_unlock(src_ruv->lock);
+
+}
+
void
ruv_force_csn_update (RUV *ruv, CSN *csn)
{
diff --git a/ldap/servers/plugins/replication/repl5_ruv.h b/ldap/servers/plugins/replication/repl5_ruv.h
index c9b85ac..4d84662 100644
--- a/ldap/servers/plugins/replication/repl5_ruv.h
+++ b/ldap/servers/plugins/replication/repl5_ruv.h
@@ -144,6 +144,7 @@ int ruv_local_contains_supplier(RUV *ruv, ReplicaId rid);
PRBool ruv_has_csns(const RUV *ruv);
PRBool ruv_has_both_csns(const RUV *ruv);
PRBool ruv_is_newer (Object *sruv, Object *cruv);
+void ruv_force_csn_update_from_ruv(RUV *src_ruv, RUV *tgt_ruv, char *msg, int logLevel);
void ruv_force_csn_update (RUV *ruv, CSN *csn);
void ruv_insert_dummy_min_csn (RUV *ruv);
int ruv_compare_ruv(const RUV *ruv1, const char *ruv1name, const RUV *ruv2, const char *ruv2name, int strict, int loglevel);
diff --git a/ldap/servers/slapd/back-ldbm/dblayer.c b/ldap/servers/slapd/back-ldbm/dblayer.c
index 20af828..daf1794 100644
--- a/ldap/servers/slapd/back-ldbm/dblayer.c
+++ b/ldap/servers/slapd/back-ldbm/dblayer.c
@@ -1643,6 +1643,7 @@ dblayer_start(struct ldbminfo *li, int dbmode)
LDAPDebug(LDAP_DEBUG_ANY, "Detected Disorderly Shutdown last "
"time Directory Server was running, recovering "
"database.\n", 0, 0, 0);
+ slapi_disordely_shutdown(PR_TRUE);
}
}
switch (dbmode&DBLAYER_RESTORE_MASK) {
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_config.c b/ldap/servers/slapd/back-ldbm/ldbm_config.c
index 2466861..ae2e8fc 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_config.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_config.c
@@ -1436,7 +1436,7 @@ static config_info ldbm_config[] = {
{CONFIG_PAGEDLOOKTHROUGHLIMIT, CONFIG_TYPE_INT, "0", &ldbm_config_pagedlookthroughlimit_get, &ldbm_config_pagedlookthroughlimit_set, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
{CONFIG_PAGEDIDLISTSCANLIMIT, CONFIG_TYPE_INT, "0", &ldbm_config_pagedallidsthreshold_get, &ldbm_config_pagedallidsthreshold_set, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
{CONFIG_RANGELOOKTHROUGHLIMIT, CONFIG_TYPE_INT, "5000", &ldbm_config_rangelookthroughlimit_get, &ldbm_config_rangelookthroughlimit_set, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
- {CONFIG_BACKEND_OPT_LEVEL, CONFIG_TYPE_INT, "0", &ldbm_config_backend_opt_level_get, &ldbm_config_backend_opt_level_set, CONFIG_FLAG_ALWAYS_SHOW},
+ {CONFIG_BACKEND_OPT_LEVEL, CONFIG_TYPE_INT, "1", &ldbm_config_backend_opt_level_get, &ldbm_config_backend_opt_level_set, CONFIG_FLAG_ALWAYS_SHOW},
{NULL, 0, NULL, NULL, NULL, 0}
};
diff --git a/ldap/servers/slapd/plugin.c b/ldap/servers/slapd/plugin.c
index d19faa5..52b9c3c 100644
--- a/ldap/servers/slapd/plugin.c
+++ b/ldap/servers/slapd/plugin.c
@@ -3223,3 +3223,14 @@ slapi_set_plugin_open_rootdn_bind(Slapi_PBlock *pb){
ptd_set_special_data(&(config->plgc_bind_subtrees), PLGC_DATA_BIND_ROOT);
}
+
+PRBool
+slapi_disordely_shutdown(PRBool set)
+{
+ static PRBool is_disordely_shutdown = PR_FALSE;
+
+ if (set) {
+ is_disordely_shutdown = PR_TRUE;
+ }
+ return (is_disordely_shutdown);
+}
\ No newline at end of file
diff --git a/ldap/servers/slapd/slapi-plugin.h b/ldap/servers/slapd/slapi-plugin.h
index ba8b6e6..d7d968d 100644
--- a/ldap/servers/slapd/slapi-plugin.h
+++ b/ldap/servers/slapd/slapi-plugin.h
@@ -7362,6 +7362,8 @@ uint64_t slapi_str_to_u64(const char *s);
void slapi_set_plugin_open_rootdn_bind(Slapi_PBlock *pb);
+PRBool slapi_disordely_shutdown(PRBool set);
+
/*
* Public entry extension getter/setter functions
*
10 years, 10 months
Branch '389-ds-base-1.2.11' - ldap/servers
by Mark Reynolds
ldap/servers/slapd/connection.c | 129 ++++++++++++++++++++--------------------
1 file changed, 65 insertions(+), 64 deletions(-)
New commits:
commit accea11ad4e16ad57b319b7c7091301adf33a99e
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Fri Jun 7 11:41:38 2013 -0400
Ticket 47383 - connections attribute in cn=snmp,cn=monitor is counted twice
Bug Description: In disconnect_server_nomutex() we increment, instead of decrement
the connection counter.
Fix Description: Decrement the counter. Also did some code cleanup.
https://fedorahosted.org/389/ticket/47383
Reviewed by: Richm(Thanks!)
(cherry picked from commit 202c9831194558a7439da815f6627993ce1a17db)
diff --git a/ldap/servers/slapd/connection.c b/ldap/servers/slapd/connection.c
index a3b1df5..1d1adac 100644
--- a/ldap/servers/slapd/connection.c
+++ b/ldap/servers/slapd/connection.c
@@ -2737,77 +2737,78 @@ void
disconnect_server_nomutex( Connection *conn, PRUint64 opconnid, int opid, PRErrorCode reason, PRInt32 error )
{
if ( ( conn->c_sd != SLAPD_INVALID_SOCKET &&
- conn->c_connid == opconnid ) && !(conn->c_flags & CONN_FLAG_CLOSING) ) {
-
- /*
- * PR_Close must be called before anything else is done because
- * of NSPR problem on NT which requires that the socket on which
- * I/O timed out is closed before any other I/O operation is
- * attempted by the thread.
- * WARNING : As of today the current code does not fulfill the
- * requirements above.
- */
+ conn->c_connid == opconnid ) && !(conn->c_flags & CONN_FLAG_CLOSING) )
+ {
+ /*
+ * PR_Close must be called before anything else is done because
+ * of NSPR problem on NT which requires that the socket on which
+ * I/O timed out is closed before any other I/O operation is
+ * attempted by the thread.
+ * WARNING : As of today the current code does not fulfill the
+ * requirements above.
+ */
- /* Mark that the socket should be closed on this connection.
- * We don't want to actually close the socket here, because
- * the listener thread could be PR_Polling over it right now.
- * The last thread to stop using the connection will do the closing.
- */
- conn->c_flags |= CONN_FLAG_CLOSING;
- g_decrement_current_conn_count();
+ /* Mark that the socket should be closed on this connection.
+ * We don't want to actually close the socket here, because
+ * the listener thread could be PR_Polling over it right now.
+ * The last thread to stop using the connection will do the closing.
+ */
+ conn->c_flags |= CONN_FLAG_CLOSING;
+ g_decrement_current_conn_count();
- /*
- * Print the error captured above.
- */
- if (error && (EPIPE != error) ) {
- slapi_log_access( LDAP_DEBUG_STATS,
- "conn=%" NSPRIu64 " op=%d fd=%d closed error %d (%s) - %s\n",
- conn->c_connid, opid, conn->c_sd, error,
- slapd_system_strerror(error),
- slapd_pr_strerror(reason));
- } else {
- slapi_log_access( LDAP_DEBUG_STATS,
- "conn=%" NSPRIu64 " op=%d fd=%d closed - %s\n",
- conn->c_connid, opid, conn->c_sd,
- slapd_pr_strerror(reason));
- }
+ /*
+ * Print the error captured above.
+ */
+ if (error && (EPIPE != error) ) {
+ slapi_log_access( LDAP_DEBUG_STATS,
+ "conn=%" NSPRIu64 " op=%d fd=%d closed error %d (%s) - %s\n",
+ conn->c_connid, opid, conn->c_sd, error,
+ slapd_system_strerror(error),
+ slapd_pr_strerror(reason));
+ } else {
+ slapi_log_access( LDAP_DEBUG_STATS,
+ "conn=%" NSPRIu64 " op=%d fd=%d closed - %s\n",
+ conn->c_connid, opid, conn->c_sd,
+ slapd_pr_strerror(reason));
+ }
- if (! config_check_referral_mode()) {
- slapi_counter_increment(g_get_global_snmp_vars()->ops_tbl.dsConnections);
- }
+ if (! config_check_referral_mode()) {
+ slapi_counter_decrement(g_get_global_snmp_vars()->ops_tbl.dsConnections);
+ }
- conn->c_gettingber = 0;
- connection_abandon_operations( conn );
- /* needed here to ensure simple paged results timeout properly and
- * don't impact subsequent ops */
- pagedresults_reset_timedout_nolock(conn);
+ conn->c_gettingber = 0;
+ connection_abandon_operations( conn );
+ /* needed here to ensure simple paged results timeout properly and
+ * don't impact subsequent ops */
+ pagedresults_reset_timedout_nolock(conn);
- if (! config_check_referral_mode()) {
- /*
- * If any of the outstanding operations on this
- * connection were persistent searches, then
- * ding all the persistent searches to get them
- * to notice that their operations have been abandoned.
- */
- int found_ps = 0;
- Operation *o;
+ if (! config_check_referral_mode()) {
+ /*
+ * If any of the outstanding operations on this
+ * connection were persistent searches, then
+ * ding all the persistent searches to get them
+ * to notice that their operations have been abandoned.
+ */
+ int found_ps = 0;
+ Operation *o;
- for ( o = conn->c_ops; !found_ps && o != NULL; o = o->o_next ) {
- if ( o->o_flags & OP_FLAG_PS ) {
- found_ps = 1;
- }
- }
- if ( found_ps ) {
- if ( NULL == ps_wakeup_all_fn ) {
- if ( get_entry_point( ENTRY_POINT_PS_WAKEUP_ALL,
- (caddr_t *)(&ps_wakeup_all_fn )) == 0 ) {
- (ps_wakeup_all_fn)();
- }
- } else {
- (ps_wakeup_all_fn)();
+ for ( o = conn->c_ops; !found_ps && o != NULL; o = o->o_next ) {
+ if ( o->o_flags & OP_FLAG_PS ) {
+ found_ps = 1;
+ }
+ }
+ if ( found_ps ) {
+ if ( NULL == ps_wakeup_all_fn ) {
+ if ( get_entry_point( ENTRY_POINT_PS_WAKEUP_ALL,
+ (caddr_t *)(&ps_wakeup_all_fn )) == 0 )
+ {
+ (ps_wakeup_all_fn)();
+ }
+ } else {
+ (ps_wakeup_all_fn)();
+ }
+ }
}
- }
- }
}
}
10 years, 10 months
Branch '389-ds-base-1.3.0' - ldap/servers
by Mark Reynolds
ldap/servers/slapd/connection.c | 131 ++++++++++++++++++++--------------------
1 file changed, 66 insertions(+), 65 deletions(-)
New commits:
commit fcce22c46647a385dffc105dfad71eabd5fb0650
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Fri Jun 7 11:41:38 2013 -0400
Ticket 47383 - connections attribute in cn=snmp,cn=monitor is counted twice
Bug Description: In disconnect_server_nomutex() we increment, instead of decrement
the connection counter.
Fix Description: Decrement the counter. Also did some code cleanup.
https://fedorahosted.org/389/ticket/47383
Reviewed by: Richm(Thanks!)
(cherry picked from commit 202c9831194558a7439da815f6627993ce1a17db)
diff --git a/ldap/servers/slapd/connection.c b/ldap/servers/slapd/connection.c
index 7750bfe..ca64f21 100644
--- a/ldap/servers/slapd/connection.c
+++ b/ldap/servers/slapd/connection.c
@@ -2766,77 +2766,78 @@ void
disconnect_server_nomutex( Connection *conn, PRUint64 opconnid, int opid, PRErrorCode reason, PRInt32 error )
{
if ( ( conn->c_sd != SLAPD_INVALID_SOCKET &&
- conn->c_connid == opconnid ) && !(conn->c_flags & CONN_FLAG_CLOSING) ) {
-
- /*
- * PR_Close must be called before anything else is done because
- * of NSPR problem on NT which requires that the socket on which
- * I/O timed out is closed before any other I/O operation is
- * attempted by the thread.
- * WARNING : As of today the current code does not fulfill the
- * requirements above.
- */
-
- /* Mark that the socket should be closed on this connection.
- * We don't want to actually close the socket here, because
- * the listener thread could be PR_Polling over it right now.
- * The last thread to stop using the connection will do the closing.
- */
- conn->c_flags |= CONN_FLAG_CLOSING;
- g_decrement_current_conn_count();
+ conn->c_connid == opconnid ) && !(conn->c_flags & CONN_FLAG_CLOSING) )
+ {
+ /*
+ * PR_Close must be called before anything else is done because
+ * of NSPR problem on NT which requires that the socket on which
+ * I/O timed out is closed before any other I/O operation is
+ * attempted by the thread.
+ * WARNING : As of today the current code does not fulfill the
+ * requirements above.
+ */
- /*
- * Print the error captured above.
- */
- if (error && (EPIPE != error) ) {
- slapi_log_access( LDAP_DEBUG_STATS,
- "conn=%" NSPRIu64 " op=%d fd=%d closed error %d (%s) - %s\n",
- conn->c_connid, opid, conn->c_sd, error,
- slapd_system_strerror(error),
- slapd_pr_strerror(reason));
- } else {
- slapi_log_access( LDAP_DEBUG_STATS,
- "conn=%" NSPRIu64 " op=%d fd=%d closed - %s\n",
- conn->c_connid, opid, conn->c_sd,
- slapd_pr_strerror(reason));
- }
+ /* Mark that the socket should be closed on this connection.
+ * We don't want to actually close the socket here, because
+ * the listener thread could be PR_Polling over it right now.
+ * The last thread to stop using the connection will do the closing.
+ */
+ conn->c_flags |= CONN_FLAG_CLOSING;
+ g_decrement_current_conn_count();
- if (! config_check_referral_mode()) {
- slapi_counter_increment(g_get_global_snmp_vars()->ops_tbl.dsConnections);
- }
+ /*
+ * Print the error captured above.
+ */
+ if (error && (EPIPE != error) ) {
+ slapi_log_access( LDAP_DEBUG_STATS,
+ "conn=%" NSPRIu64 " op=%d fd=%d closed error %d (%s) - %s\n",
+ conn->c_connid, opid, conn->c_sd, error,
+ slapd_system_strerror(error),
+ slapd_pr_strerror(reason));
+ } else {
+ slapi_log_access( LDAP_DEBUG_STATS,
+ "conn=%" NSPRIu64 " op=%d fd=%d closed - %s\n",
+ conn->c_connid, opid, conn->c_sd,
+ slapd_pr_strerror(reason));
+ }
- conn->c_gettingber = 0;
- connection_abandon_operations( conn );
- /* needed here to ensure simple paged results timeout properly and
- * don't impact subsequent ops */
- pagedresults_reset_timedout_nolock(conn);
+ if (! config_check_referral_mode()) {
+ slapi_counter_decrement(g_get_global_snmp_vars()->ops_tbl.dsConnections);
+ }
- if (! config_check_referral_mode()) {
- /*
- * If any of the outstanding operations on this
- * connection were persistent searches, then
- * ding all the persistent searches to get them
- * to notice that their operations have been abandoned.
- */
- int found_ps = 0;
- Operation *o;
+ conn->c_gettingber = 0;
+ connection_abandon_operations( conn );
+ /* needed here to ensure simple paged results timeout properly and
+ * don't impact subsequent ops */
+ pagedresults_reset_timedout_nolock(conn);
- for ( o = conn->c_ops; !found_ps && o != NULL; o = o->o_next ) {
- if ( o->o_flags & OP_FLAG_PS ) {
- found_ps = 1;
- }
- }
- if ( found_ps ) {
- if ( NULL == ps_wakeup_all_fn ) {
- if ( get_entry_point( ENTRY_POINT_PS_WAKEUP_ALL,
- (caddr_t *)(&ps_wakeup_all_fn )) == 0 ) {
- (ps_wakeup_all_fn)();
- }
- } else {
- (ps_wakeup_all_fn)();
+ if (! config_check_referral_mode()) {
+ /*
+ * If any of the outstanding operations on this
+ * connection were persistent searches, then
+ * ding all the persistent searches to get them
+ * to notice that their operations have been abandoned.
+ */
+ int found_ps = 0;
+ Operation *o;
+
+ for ( o = conn->c_ops; !found_ps && o != NULL; o = o->o_next ) {
+ if ( o->o_flags & OP_FLAG_PS ) {
+ found_ps = 1;
+ }
+ }
+ if ( found_ps ) {
+ if ( NULL == ps_wakeup_all_fn ) {
+ if ( get_entry_point( ENTRY_POINT_PS_WAKEUP_ALL,
+ (caddr_t *)(&ps_wakeup_all_fn )) == 0 )
+ {
+ (ps_wakeup_all_fn)();
+ }
+ } else {
+ (ps_wakeup_all_fn)();
+ }
+ }
}
- }
- }
}
}
10 years, 10 months
Branch '389-ds-base-1.3.1' - ldap/servers
by Mark Reynolds
ldap/servers/slapd/connection.c | 131 ++++++++++++++++++++--------------------
1 file changed, 66 insertions(+), 65 deletions(-)
New commits:
commit 17d9dc5332245197ab6cd625d20026adbdb28121
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Fri Jun 7 11:41:38 2013 -0400
Ticket 47383 - connections attribute in cn=snmp,cn=monitor is counted twice
Bug Description: In disconnect_server_nomutex() we increment, instead of decrement
the connection counter.
Fix Description: Decrement the counter. Also did some code cleanup.
https://fedorahosted.org/389/ticket/47383
Reviewed by: Richm(Thanks!)
(cherry picked from commit 202c9831194558a7439da815f6627993ce1a17db)
diff --git a/ldap/servers/slapd/connection.c b/ldap/servers/slapd/connection.c
index 31fc543..866731d 100644
--- a/ldap/servers/slapd/connection.c
+++ b/ldap/servers/slapd/connection.c
@@ -2768,77 +2768,78 @@ void
disconnect_server_nomutex( Connection *conn, PRUint64 opconnid, int opid, PRErrorCode reason, PRInt32 error )
{
if ( ( conn->c_sd != SLAPD_INVALID_SOCKET &&
- conn->c_connid == opconnid ) && !(conn->c_flags & CONN_FLAG_CLOSING) ) {
-
- /*
- * PR_Close must be called before anything else is done because
- * of NSPR problem on NT which requires that the socket on which
- * I/O timed out is closed before any other I/O operation is
- * attempted by the thread.
- * WARNING : As of today the current code does not fulfill the
- * requirements above.
- */
-
- /* Mark that the socket should be closed on this connection.
- * We don't want to actually close the socket here, because
- * the listener thread could be PR_Polling over it right now.
- * The last thread to stop using the connection will do the closing.
- */
- conn->c_flags |= CONN_FLAG_CLOSING;
- g_decrement_current_conn_count();
+ conn->c_connid == opconnid ) && !(conn->c_flags & CONN_FLAG_CLOSING) )
+ {
+ /*
+ * PR_Close must be called before anything else is done because
+ * of NSPR problem on NT which requires that the socket on which
+ * I/O timed out is closed before any other I/O operation is
+ * attempted by the thread.
+ * WARNING : As of today the current code does not fulfill the
+ * requirements above.
+ */
- /*
- * Print the error captured above.
- */
- if (error && (EPIPE != error) ) {
- slapi_log_access( LDAP_DEBUG_STATS,
- "conn=%" NSPRIu64 " op=%d fd=%d closed error %d (%s) - %s\n",
- conn->c_connid, opid, conn->c_sd, error,
- slapd_system_strerror(error),
- slapd_pr_strerror(reason));
- } else {
- slapi_log_access( LDAP_DEBUG_STATS,
- "conn=%" NSPRIu64 " op=%d fd=%d closed - %s\n",
- conn->c_connid, opid, conn->c_sd,
- slapd_pr_strerror(reason));
- }
+ /* Mark that the socket should be closed on this connection.
+ * We don't want to actually close the socket here, because
+ * the listener thread could be PR_Polling over it right now.
+ * The last thread to stop using the connection will do the closing.
+ */
+ conn->c_flags |= CONN_FLAG_CLOSING;
+ g_decrement_current_conn_count();
- if (! config_check_referral_mode()) {
- slapi_counter_increment(g_get_global_snmp_vars()->ops_tbl.dsConnections);
- }
+ /*
+ * Print the error captured above.
+ */
+ if (error && (EPIPE != error) ) {
+ slapi_log_access( LDAP_DEBUG_STATS,
+ "conn=%" NSPRIu64 " op=%d fd=%d closed error %d (%s) - %s\n",
+ conn->c_connid, opid, conn->c_sd, error,
+ slapd_system_strerror(error),
+ slapd_pr_strerror(reason));
+ } else {
+ slapi_log_access( LDAP_DEBUG_STATS,
+ "conn=%" NSPRIu64 " op=%d fd=%d closed - %s\n",
+ conn->c_connid, opid, conn->c_sd,
+ slapd_pr_strerror(reason));
+ }
- conn->c_gettingber = 0;
- connection_abandon_operations( conn );
- /* needed here to ensure simple paged results timeout properly and
- * don't impact subsequent ops */
- pagedresults_reset_timedout_nolock(conn);
+ if (! config_check_referral_mode()) {
+ slapi_counter_decrement(g_get_global_snmp_vars()->ops_tbl.dsConnections);
+ }
- if (! config_check_referral_mode()) {
- /*
- * If any of the outstanding operations on this
- * connection were persistent searches, then
- * ding all the persistent searches to get them
- * to notice that their operations have been abandoned.
- */
- int found_ps = 0;
- Operation *o;
+ conn->c_gettingber = 0;
+ connection_abandon_operations( conn );
+ /* needed here to ensure simple paged results timeout properly and
+ * don't impact subsequent ops */
+ pagedresults_reset_timedout_nolock(conn);
- for ( o = conn->c_ops; !found_ps && o != NULL; o = o->o_next ) {
- if ( o->o_flags & OP_FLAG_PS ) {
- found_ps = 1;
- }
- }
- if ( found_ps ) {
- if ( NULL == ps_wakeup_all_fn ) {
- if ( get_entry_point( ENTRY_POINT_PS_WAKEUP_ALL,
- (caddr_t *)(&ps_wakeup_all_fn )) == 0 ) {
- (ps_wakeup_all_fn)();
- }
- } else {
- (ps_wakeup_all_fn)();
+ if (! config_check_referral_mode()) {
+ /*
+ * If any of the outstanding operations on this
+ * connection were persistent searches, then
+ * ding all the persistent searches to get them
+ * to notice that their operations have been abandoned.
+ */
+ int found_ps = 0;
+ Operation *o;
+
+ for ( o = conn->c_ops; !found_ps && o != NULL; o = o->o_next ) {
+ if ( o->o_flags & OP_FLAG_PS ) {
+ found_ps = 1;
+ }
+ }
+ if ( found_ps ) {
+ if ( NULL == ps_wakeup_all_fn ) {
+ if ( get_entry_point( ENTRY_POINT_PS_WAKEUP_ALL,
+ (caddr_t *)(&ps_wakeup_all_fn )) == 0 )
+ {
+ (ps_wakeup_all_fn)();
+ }
+ } else {
+ (ps_wakeup_all_fn)();
+ }
+ }
}
- }
- }
}
}
10 years, 10 months