diff options
author | Rich Megginson <rmeggins@redhat.com> | 2007-10-18 01:22:29 +0000 |
---|---|---|
committer | Rich Megginson <rmeggins@redhat.com> | 2007-10-18 01:22:29 +0000 |
commit | 33c33e1cfde3580cb74a7b69bf8c5e3545362c0b (patch) | |
tree | f67e4305224dc0ee4e86bfa53a0195726ffc017b /ldap/servers/slapd | |
parent | 19cd513a509aa6e45361df774e74f2d39451e08a (diff) | |
download | ds-33c33e1cfde3580cb74a7b69bf8c5e3545362c0b.tar.gz ds-33c33e1cfde3580cb74a7b69bf8c5e3545362c0b.tar.xz ds-33c33e1cfde3580cb74a7b69bf8c5e3545362c0b.zip |
Resolves: bug 250179
Description: tmpwatch whacks stats
Reviewed by: nkinder (Thanks!)
Fix Description: move the snmp slapd.stats file to run_dir (/var/run/dirsrv) and rename to slapd-instance.stats. Had to add nsslapd-rundir to cn=config in order for ldap-agent to be able to get it.
Doc: Yes, we need to document the new attribute nsslapd-rundir.
Diffstat (limited to 'ldap/servers/slapd')
-rw-r--r-- | ldap/servers/slapd/agtmmap.h | 3 | ||||
-rw-r--r-- | ldap/servers/slapd/libglobs.c | 41 | ||||
-rw-r--r-- | ldap/servers/slapd/proto-slap.h | 2 | ||||
-rw-r--r-- | ldap/servers/slapd/slap.h | 2 | ||||
-rw-r--r-- | ldap/servers/slapd/snmp_collator.c | 19 |
5 files changed, 62 insertions, 5 deletions
diff --git a/ldap/servers/slapd/agtmmap.h b/ldap/servers/slapd/agtmmap.h index 4ee660a8..e329324d 100644 --- a/ldap/servers/slapd/agtmmap.h +++ b/ldap/servers/slapd/agtmmap.h @@ -79,7 +79,8 @@ extern int errno; #if !defined(_MAX_PATH) #define _MAX_PATH 256 #endif -#define AGT_STATS_FILE "slapd.stats" +#define AGT_STATS_EXTENSION ".stats" +#define AGT_STATS_FILE "slapd" AGT_STATS_EXTENSION #define AGT_MJR_VERSION 1 #define AGT_MNR_VERSION 0 diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c index 27075140..21ffa4c2 100644 --- a/ldap/servers/slapd/libglobs.c +++ b/ldap/servers/slapd/libglobs.c @@ -573,6 +573,10 @@ static struct config_get_and_set { {CONFIG_SASLPATH_ATTRIBUTE, config_set_saslpath, NULL, 0, (void**)&global_slapdFrontendConfig.saslpath, CONFIG_STRING, (ConfigGetFunc)config_get_saslpath}, + /* parameterizing run dir */ + {CONFIG_RUNDIR_ATTRIBUTE, config_set_rundir, + NULL, 0, + (void**)&global_slapdFrontendConfig.rundir, CONFIG_STRING, (ConfigGetFunc)config_get_rundir}, {CONFIG_REWRITE_RFC1274_ATTRIBUTE, config_set_rewrite_rfc1274, NULL, 0, (void**)&global_slapdFrontendConfig.rewrite_rfc1274, CONFIG_ON_OFF, NULL}, @@ -4728,6 +4732,43 @@ config_set_bakdir(const char *attrname, char *value, char *errorbuf, int apply) CFG_UNLOCK_WRITE(slapdFrontendConfig); return retVal; } + +char * +config_get_rundir() +{ + slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); + char *retVal; + + CFG_LOCK_READ(slapdFrontendConfig); + retVal = config_copy_strval(slapdFrontendConfig->rundir); + CFG_UNLOCK_READ(slapdFrontendConfig); + + return retVal; +} + +int +config_set_rundir(const char *attrname, char *value, char *errorbuf, int apply) +{ + int retVal = LDAP_SUCCESS; + slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); + + if ( config_value_is_null( attrname, value, errorbuf, 0 )) { + return LDAP_OPERATIONS_ERROR; + } + + if (!apply) { + return retVal; + } + + CFG_LOCK_WRITE(slapdFrontendConfig); + slapi_ch_free((void **)&slapdFrontendConfig->rundir); + + slapdFrontendConfig->rundir = slapi_ch_strdup(value); + + CFG_UNLOCK_WRITE(slapdFrontendConfig); + return retVal; +} + char * config_get_saslpath() { diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h index 571f4edc..b27b74b4 100644 --- a/ldap/servers/slapd/proto-slap.h +++ b/ldap/servers/slapd/proto-slap.h @@ -326,6 +326,7 @@ int config_set_tmpdir( const char *attrname, char *value, char *errorbuf, int ap int config_set_certdir( const char *attrname, char *value, char *errorbuf, int apply ); int config_set_ldifdir( const char *attrname, char *value, char *errorbuf, int apply ); int config_set_bakdir( const char *attrname, char *value, char *errorbuf, int apply ); +int config_set_rundir( const char *attrname, char *value, char *errorbuf, int apply ); int config_set_saslpath( const char *attrname, char *value, char *errorbuf, int apply ); int config_set_attrname_exceptions( const char *attrname, char *value, char *errorbuf, int apply ); int config_set_hash_filters( const char *attrname, char *value, char *errorbuf, int apply ); @@ -438,6 +439,7 @@ char *config_get_tmpdir(); char *config_get_certdir(); char *config_get_ldifdir(); char *config_get_bakdir(); +char *config_get_rundir(); char *config_get_saslpath(); char **config_get_errorlog_list(); char **config_get_accesslog_list(); diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h index f10e8fb2..f1777eb8 100644 --- a/ldap/servers/slapd/slap.h +++ b/ldap/servers/slapd/slap.h @@ -1727,6 +1727,7 @@ typedef struct _slapdEntryPoints { #define CONFIG_LDIFDIR_ATTRIBUTE "nsslapd-ldifdir" #define CONFIG_BAKDIR_ATTRIBUTE "nsslapd-bakdir" #define CONFIG_SASLPATH_ATTRIBUTE "nsslapd-saslpath" +#define CONFIG_RUNDIR_ATTRIBUTE "nsslapd-rundir" #define CONFIG_SSLCLIENTAUTH_ATTRIBUTE "nsslapd-SSLclientAuth" #define CONFIG_SSL_CHECK_HOSTNAME_ATTRIBUTE "nsslapd-ssl-check-hostname" #define CONFIG_HASH_FILTERS_ATTRIBUTE "nsslapd-hash-filters" @@ -1906,6 +1907,7 @@ typedef struct _slapdFrontendConfig { char *certdir; /* full path name of directory containing cert files */ char *ldifdir; /* full path name of directory containing ldif files */ char *bakdir; /* full path name of directory containing bakup files */ + char *rundir; /* where pid, snmp stats, and ldapi files go */ char *saslpath; /* full path name of directory containing sasl plugins */ int attrname_exceptions; /* if true, allow questionable attribute names */ int rewrite_rfc1274; /* return attrs for both v2 and v3 names */ diff --git a/ldap/servers/slapd/snmp_collator.c b/ldap/servers/slapd/snmp_collator.c index 016b55c8..0aadf9b6 100644 --- a/ldap/servers/slapd/snmp_collator.c +++ b/ldap/servers/slapd/snmp_collator.c @@ -60,6 +60,7 @@ #include "prlock.h" #include "prerror.h" #include "prcvar.h" +#include "plstr.h" #include "snmp_collator.h" #include "../snmp/ntagt/nslagtcom_nt.h" @@ -397,8 +398,10 @@ int snmp_collator_start() { int err; - char *statspath = config_get_tmpdir(); + char *statspath = config_get_rundir(); char *lp = NULL; + char *instdir = config_get_configdir(); + char *instname = NULL; /* * Get directory for our stats file @@ -407,10 +410,18 @@ int snmp_collator_start() statspath = slapi_ch_strdup("/tmp"); } - PR_snprintf(szStatsFile, sizeof(szStatsFile), "%s/%s", - statspath, AGT_STATS_FILE); + instname = PL_strrstr(instdir, "slapd-"); + if (!instname) { + instname = PL_strrstr(instdir, "/"); + if (instname) { + instname++; + } + } + PR_snprintf(szStatsFile, sizeof(szStatsFile), "%s/%s%s", + statspath, instname, AGT_STATS_EXTENSION); tmpstatsfile = szStatsFile; - slapi_ch_free((void **) &statspath); + slapi_ch_free_string(&statspath); + slapi_ch_free_string(&instname); /* open the memory map */ if ((err = agt_mopen_stats(tmpstatsfile, O_RDWR, &hdl) != 0)) |