summaryrefslogtreecommitdiffstats
path: root/ldap/servers/slapd/ntperfdll
diff options
context:
space:
mode:
authorcvsadm <cvsadm>2005-01-21 00:44:34 +0000
committercvsadm <cvsadm>2005-01-21 00:44:34 +0000
commitb2093e3016027d6b5cf06b3f91f30769bfc099e2 (patch)
treecf58939393a9032182c4fbc4441164a9456e82f8 /ldap/servers/slapd/ntperfdll
downloadds-ldapserver7x.tar.gz
ds-ldapserver7x.tar.xz
ds-ldapserver7x.zip
Moving NSCP Directory Server from DirectoryBranch to TRUNK, initial drop. (foxworth)ldapserver7x
Diffstat (limited to 'ldap/servers/slapd/ntperfdll')
-rw-r--r--ldap/servers/slapd/ntperfdll/Makefile52
-rw-r--r--ldap/servers/slapd/ntperfdll/exports.def9
-rw-r--r--ldap/servers/slapd/ntperfdll/nsldapctr.cpp985
-rw-r--r--ldap/servers/slapd/ntperfdll/nsldapctrdef.h33
-rw-r--r--ldap/servers/slapd/ntperfdll/nsldapctrmc.h122
-rw-r--r--ldap/servers/slapd/ntperfdll/nsldapctrmc.mc74
-rw-r--r--ldap/servers/slapd/ntperfdll/nsldapctrmsg.h60
-rw-r--r--ldap/servers/slapd/ntperfdll/nsldapctrs.h67
-rw-r--r--ldap/servers/slapd/ntperfdll/nsldapctrs.ini57
-rw-r--r--ldap/servers/slapd/ntperfdll/nsldapctrutil.cpp364
-rw-r--r--ldap/servers/slapd/ntperfdll/nsldapctrutil.h120
-rw-r--r--ldap/servers/slapd/ntperfdll/nsldapreg.ini18
12 files changed, 1961 insertions, 0 deletions
diff --git a/ldap/servers/slapd/ntperfdll/Makefile b/ldap/servers/slapd/ntperfdll/Makefile
new file mode 100644
index 00000000..bed046a6
--- /dev/null
+++ b/ldap/servers/slapd/ntperfdll/Makefile
@@ -0,0 +1,52 @@
+#
+# BEGIN COPYRIGHT BLOCK
+# Copyright 2001 Sun Microsystems, Inc.
+# Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+# All rights reserved.
+# END COPYRIGHT BLOCK
+#
+
+MCOM_ROOT = ../../../../..
+LDAP_SRC = ../../..
+
+OBJDEST = $(OBJDIR)/servers/obj
+BINDIR = $(LDAP_SERVER_RELDIR)
+ALLDIRS = $(BINDIR) $(OBJDEST)
+
+include $(MCOM_ROOT)/ldapserver/nsdefs.mk
+include $(MCOM_ROOT)/ldapserver/nsconfig.mk
+include $(LDAP_SRC)/nsldap.mk
+
+LINK32=link.exe
+
+MC=mc #message compiler?
+
+DLLS = nsldapctr
+
+# -D's get all screwed up: we need to fix them:
+CFLAGS+= -UNS_PERSONAL -DNS_DS
+# this lets us pickup regparms.h
+CFLAGS += -I $(MCOM_ROOT)/ldapserver/include
+
+MCS = nsldapctrmc
+DEPMC = $(addsuffix .h, $(MCS))
+
+OBJS = $(OBJDEST)/nsldapctr.o $(OBJDEST)/nsldapctrutil.o
+
+RELFILES = nsldapctrs.ini nsldapctrdef.h
+
+DESTRELFILES = $(addprefix $(LDAP_INSTALL_BIN_RELDIR)/, $(RELFILES))
+
+all: $(ALLDIRS) $(addprefix $(BINDIR)/, $(addsuffix .dll, $(DLLS) ) ) $(DESTRELFILES)
+
+nsldapctrmc.h:
+ $(MC) -s -v $*.mc
+
+$(OBJDEST)/%.o: %.cpp
+ cl -nologo -c $(CFLAGS) $(MCC_INCLUDE) /Tp $< -Fo$@
+
+$(BINDIR)/nsldapctr.dll: $(DEPMC) $(OBJS)
+ $(LINK_DLL) /OUT:$@ /DEF:exports.def
+
+$(LDAP_INSTALL_BIN_RELDIR)/%: % $(LDAP_INSTALL_BIN_RELDIR)
+ $(CP) $< $(dir $@)
diff --git a/ldap/servers/slapd/ntperfdll/exports.def b/ldap/servers/slapd/ntperfdll/exports.def
new file mode 100644
index 00000000..c5805d9d
--- /dev/null
+++ b/ldap/servers/slapd/ntperfdll/exports.def
@@ -0,0 +1,9 @@
+; BEGIN COPYRIGHT BLOCK
+; Copyright 2001 Sun Microsystems, Inc.
+; Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+; All rights reserved.
+; END COPYRIGHT BLOCK
+;
+EXPORTS OpenNSPerformanceData
+EXPORTS CollectNSPerformanceData
+EXPORTS CloseNSPerformanceData
diff --git a/ldap/servers/slapd/ntperfdll/nsldapctr.cpp b/ldap/servers/slapd/ntperfdll/nsldapctr.cpp
new file mode 100644
index 00000000..21bf429d
--- /dev/null
+++ b/ldap/servers/slapd/ntperfdll/nsldapctr.cpp
@@ -0,0 +1,985 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+/*
+ nsctr.c
+
+ Netscape server performance monitor hooks.
+
+
+ ***********************************************************************
+ HOW TO ADD A NEW PERFMON STATISTIC
+ 1. add to StatSlot or StatHeader struct
+ 2. add new counter definition to NS_DATA_DEFINITION in nsctrs.h
+ 3. define the offset of your new counter in nsctrdef.h
+ 4. add your counter initialization to NSDataDefinition in nsctr.cpp
+ 5. update CollectNSPerformanceData to collect your data
+ 6. modify nsctrs.ini to contain the text info for your counter
+ these are keyed off the "tag" you used in step 3
+ ***********************************************************************
+ HOW TO UPDATE THE REGISTRY
+ 1. run regini nsreg.ini
+ 2. run lodctr nsctrs.ini
+ ***********************************************************************
+ */
+
+#define UNICODE
+
+#include <windows.h>
+#include <string.h>
+#include <winperf.h>
+#include <stdio.h>
+#include <regstr.h>
+#include "nsldapctrs.h"
+#include "nsldapctrmsg.h"
+#include "nsldapctrutil.h"
+#include "nsldapctrmc.h"
+#include "nsldapctrdef.h"
+
+#include "nt/regparms.h"
+
+#include "../agtmmap.h"
+
+#define NUM_INSTANCES 0
+#define MAGT_MAX_LINELEN 255
+
+
+/* --- Constant Performance Counter Declaration --------------------------------------------*/
+
+NS_DATA_DEFINITION NSDataDefinition = {
+
+ { sizeof(NS_DATA_DEFINITION) + SIZE_OF_NS_PERFORMANCE_DATA,
+ sizeof(NS_DATA_DEFINITION),
+ sizeof(PERF_OBJECT_TYPE),
+ NS_OBJ,
+ 0,
+ NS_OBJ,
+ 0,
+ PERF_DETAIL_NOVICE,
+ (sizeof(NS_DATA_DEFINITION)-sizeof(PERF_OBJECT_TYPE))/
+ sizeof(PERF_COUNTER_DEFINITION),
+ 4L,
+ NUM_INSTANCES,
+ 0,
+ 0,
+ 0
+ },
+ {
+ sizeof(PERF_COUNTER_DEFINITION),
+ CONN_RATE,
+ 0,
+ CONN_RATE,
+ 0,
+ 0,
+ PERF_DETAIL_NOVICE,
+ PERF_COUNTER_COUNTER,
+ sizeof(DWORD),
+ NUM_CONN_RATE_OFFSET
+ },
+ {
+ sizeof(PERF_COUNTER_DEFINITION),
+ THROUGHPUT,
+ 0,
+ THROUGHPUT,
+ 0,
+ -3,
+ PERF_DETAIL_NOVICE,
+ PERF_COUNTER_COUNTER,
+ sizeof(DWORD),
+ NUM_THROUGHPUT_OFFSET
+ },
+ {
+ sizeof(PERF_COUNTER_DEFINITION),
+ TOTAL_BYTES_WRITTEN,
+ 0,
+ TOTAL_BYTES_WRITTEN,
+ 0,
+ -3,
+ PERF_DETAIL_NOVICE,
+ PERF_COUNTER_RAWCOUNT,
+ sizeof(DWORD),
+ NUM_TOTAL_BYTES_WRITTEN_OFFSET
+ },
+ {
+ sizeof(PERF_COUNTER_DEFINITION),
+ TOTAL_BYTES_READ,
+ 0,
+ TOTAL_BYTES_READ,
+ 0,
+ -3,
+ PERF_DETAIL_NOVICE,
+ PERF_COUNTER_RAWCOUNT,
+ sizeof(DWORD),
+ NUM_TOTAL_BYTES_READ_OFFSET
+ },
+ {
+ sizeof(PERF_COUNTER_DEFINITION),
+ OP_RATE,
+ 0,
+ OP_RATE,
+ 0,
+ -1,
+ PERF_DETAIL_NOVICE,
+ PERF_COUNTER_COUNTER,
+ sizeof(DWORD),
+ NUM_OP_RATE_OFFSET
+ },
+ {
+ sizeof(PERF_COUNTER_DEFINITION),
+ TOTAL_ERRORS,
+ 0,
+ TOTAL_ERRORS,
+ 0,
+ 0,
+ PERF_DETAIL_NOVICE,
+ PERF_COUNTER_RAWCOUNT,
+ sizeof(DWORD),
+ NUM_TOTAL_ERRORS_OFFSET
+ },
+ {
+ sizeof(PERF_COUNTER_DEFINITION),
+ SEARCH_RATE,
+ 0,
+ SEARCH_RATE,
+ 0,
+ -1,
+ PERF_DETAIL_NOVICE,
+ PERF_COUNTER_COUNTER,
+ sizeof(DWORD),
+ NUM_SEARCH_RATE_OFFSET
+ } ,
+ {
+ sizeof(PERF_COUNTER_DEFINITION),
+ ADD_RATE,
+ 0,
+ ADD_RATE,
+ 0,
+ 0,
+ PERF_DETAIL_NOVICE,
+ PERF_COUNTER_COUNTER,
+ sizeof(DWORD),
+ ADD_RATE_OFFSET
+ },
+ {
+ sizeof(PERF_COUNTER_DEFINITION),
+ DELETE_RATE,
+ 0,
+ DELETE_RATE,
+ 0,
+ 0,
+ PERF_DETAIL_NOVICE,
+ PERF_COUNTER_COUNTER,
+ sizeof(DWORD),
+ DELETE_RATE_OFFSET
+ },
+ {
+ sizeof(PERF_COUNTER_DEFINITION),
+ MODIFY_RATE,
+ 0,
+ MODIFY_RATE,
+ 0,
+ 0,
+ PERF_DETAIL_NOVICE,
+ PERF_COUNTER_COUNTER,
+ sizeof(DWORD),
+ MODIFY_RATE_OFFSET
+ },
+ {
+ sizeof(PERF_COUNTER_DEFINITION),
+ COMPARE_RATE,
+ 0,
+ COMPARE_RATE,
+ 0,
+ -1,
+ PERF_DETAIL_NOVICE,
+ PERF_COUNTER_COUNTER,
+ sizeof(DWORD),
+ COMPARE_RATE_OFFSET
+ },
+ {
+ sizeof(PERF_COUNTER_DEFINITION),
+ MODDN_RATE,
+ 0,
+ MODDN_RATE,
+ 0,
+ 0,
+ PERF_DETAIL_NOVICE,
+ PERF_COUNTER_COUNTER,
+ sizeof(DWORD),
+ MODDN_RATE_OFFSET
+ },
+ {
+ sizeof(PERF_COUNTER_DEFINITION),
+ CONNECTIONS,
+ 0,
+ CONNECTIONS,
+ 0,
+ 0,
+ PERF_DETAIL_NOVICE,
+ PERF_COUNTER_RAWCOUNT,
+ sizeof(DWORD),
+ CONNECTIONS_OFFSET
+ },
+ {
+ sizeof(PERF_COUNTER_DEFINITION),
+ BIND_RATE,
+ 0,
+ BIND_RATE,
+ 0,
+ -1,
+ PERF_DETAIL_NOVICE,
+ PERF_COUNTER_COUNTER,
+ sizeof(DWORD),
+ BIND_RATE_OFFSET
+ },
+ {
+ sizeof(PERF_COUNTER_DEFINITION),
+ ENTRIES_RETURNED,
+ 0,
+ ENTRIES_RETURNED,
+ 0,
+ 0,
+ PERF_DETAIL_NOVICE,
+ PERF_COUNTER_RAWCOUNT,
+ sizeof(DWORD),
+ ENTRIES_RETURNED_OFFSET
+ },
+ {
+ sizeof(PERF_COUNTER_DEFINITION),
+ ENTRIES_RETURNED_RATE,
+ 0,
+ ENTRIES_RETURNED_RATE,
+ 0,
+ -1,
+ PERF_DETAIL_NOVICE,
+ PERF_COUNTER_COUNTER,
+ sizeof(DWORD),
+ ENTRIES_RETURNED_RATE_OFFSET
+ },
+ {
+ sizeof(PERF_COUNTER_DEFINITION),
+ REFERRALS_RETURNED,
+ 0,
+ REFERRALS_RETURNED,
+ 0,
+ 0,
+ PERF_DETAIL_NOVICE,
+ PERF_COUNTER_RAWCOUNT,
+ sizeof(DWORD),
+ REFERRALS_RETURNED_OFFSET
+ },
+ {
+ sizeof(PERF_COUNTER_DEFINITION),
+ REFERRALS_RETURNED_RATE,
+ 0,
+ REFERRALS_RETURNED_RATE,
+ 0,
+ -1,
+ PERF_DETAIL_NOVICE,
+ PERF_COUNTER_COUNTER,
+ sizeof(DWORD),
+ REFERRALS_RETURNED_RATE_OFFSET
+ },
+ {
+ sizeof(PERF_COUNTER_DEFINITION),
+ BYTES_READ_RATE,
+ 0,
+ BYTES_READ_RATE,
+ 0,
+ -3,
+ PERF_DETAIL_NOVICE,
+ PERF_COUNTER_COUNTER,
+ sizeof(DWORD),
+ BYTES_READ_RATE_OFFSET
+ },
+ {
+ sizeof(PERF_COUNTER_DEFINITION),
+ BYTES_WRITTEN_RATE,
+ 0,
+ BYTES_WRITTEN_RATE,
+ 0,
+ -3,
+ PERF_DETAIL_NOVICE,
+ PERF_COUNTER_COUNTER,
+ sizeof(DWORD),
+ BYTES_WRITTEN_RATE_OFFSET
+ }
+
+
+};
+
+/* --- Data structs ----------------------------------------------------------------------- */
+typedef struct instance_list_t {
+ PERF_INSTANCE_DEFINITION instance;
+ PWSTR pInstanceName;
+ PWSTR pConfPath;
+ agt_stats_t * pData;
+ struct instance_list_t * pNext;
+} instance_list_t;
+
+
+/* --- Globals ---------------------------------------------------------------------------- */
+static BOOL bInitialized = FALSE;
+static DWORD dwOpenCount = 0; /* Count of threads holding DLL open */
+static DWORD dwInstanceCount = 0;
+static instance_list_t *pInstanceList = NULL;
+
+#define export extern "C"
+
+
+/*-------------------------------------------------------------------------
+ *
+ * MagtReadLine: Reads one line of text (up to n chars) from specified
+ * file.
+ *
+ * Returns: Len read - No error
+ * -1 - Errors
+ *
+ *-----------------------------------------------------------------------*/
+
+int MagtReadLine(char *buf, int n, FILE *fp)
+{
+ if (fgets(buf, n, fp) != NULL)
+ {
+ return(strlen(buf));
+ }
+ else
+ {
+ return(-1);
+ }
+}
+
+
+
+/* --- strips quotes off of a quoted string -------------------------------------- */
+
+
+char *dequote(char *quoted_string)
+{
+ char *return_string = (char *)malloc((strlen(quoted_string) - 2) * sizeof(char) );
+ char *pQuo = quoted_string;
+ char *pRet = return_string;
+
+ for(; *pQuo; pQuo++) {
+ if (*pQuo != '\"')
+ *(pRet++) = *pQuo;
+ }
+ *pRet = '\0';
+
+ return return_string;
+
+}
+
+/* --- gets the instance dir from conf file ------------------------------------- */
+
+
+/*
+ * The body of this function is pretty much copied from
+ * ldapserver/ldap/servers/snmp/ntagt/nsldapagt_nt.c
+ *
+ */
+char *getRootDirFromConfFile(PWSTR confpath)
+{
+ char *rootDir = NULL;
+ const char *config = "\\config\0" ;
+ char instanceDir[MAGT_MAX_LINELEN + 1] = "";
+ size_t len ;
+ char filename[256];
+
+ if (confpath) {
+ sprintf(filename, "%S", confpath);
+ len = strlen(filename) - strlen(config) ;
+ strncpy(instanceDir, filename, len);
+ rootDir = _strdup(instanceDir) ; // allocate memory for rootDir and set up to value pointed by instanceDir
+ return rootDir ;
+ }
+ else return NULL ;
+}
+
+static DWORD MapSharedMem(char* path, agt_stats_t **ptr)
+{
+ HANDLE hFile = NULL;
+ HANDLE hMapFile = NULL;
+ LPVOID memory = NULL;
+
+ *ptr = NULL;
+ /* Open existing disk file for read */
+ hFile = CreateFileA(path,
+ GENERIC_READ | GENERIC_WRITE,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
+ NULL,
+ OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
+
+ if ( hFile == INVALID_HANDLE_VALUE || hFile == NULL ) return GetLastError();
+
+ /* Create mapped file handle for reading */
+ hMapFile = CreateFileMapping( hFile, NULL, PAGE_READONLY, 0,
+ sizeof(struct agt_stats_t),
+ NULL);
+ if ( hMapFile == NULL ) {
+ CloseHandle( hFile );
+ return GetLastError();
+ }
+
+ /* Create addr ptr to the start of the file */
+ memory = MapViewOfFileEx( hMapFile, FILE_MAP_READ, 0, 0,
+ sizeof(struct agt_stats_t), NULL );
+ CloseHandle( hMapFile );
+ CloseHandle( hFile );
+ if ( memory == NULL ) {
+ return GetLastError();
+ }
+ *ptr = (agt_stats_t *)memory;
+ return 0;
+}
+
+static DWORD UnmapSharedMem(agt_stats_t **ptr)
+{
+ return UnmapViewOfFile( (LPVOID)*ptr) ? 0 : -1;
+}
+
+/* --- Open Function --------------------------------------------------------------------- */
+
+
+/* _FindNetscapeServers()
+ * Function to loop through registry looking for netscape servers
+ * Stores them into pInstanceList as it finds them.
+ */
+
+#define MAX_KEY_SIZE 128
+DWORD
+_FindNetscapeServers()
+{
+ LONG regStatus,
+ status;
+ HKEY hKeyNetscape = NULL,
+ hKeyNetscapeConf;
+ DWORD dwKey,
+ type,
+ dwServerKeySize,
+ size,
+ dwServerCount = 0;
+ WCHAR szServerKeyName[MAX_KEY_SIZE],
+ szConfKeyName[MAX_KEY_SIZE + sizeof(KEY_SOFTWARE_NETSCAPE)],
+ szPath[MAX_KEY_SIZE];
+ FILETIME fileTime;
+ instance_list_t *pNew;
+ DWORD iUniqueID = 0;
+
+ regStatus = RegOpenKeyEx(
+ HKEY_LOCAL_MACHINE,
+ TEXT(KEY_SOFTWARE_NETSCAPE) TEXT("\\") TEXT(DS_KEY_ROOT),
+ 0L,
+ KEY_ALL_ACCESS,
+ &hKeyNetscape);
+
+ if (regStatus != ERROR_SUCCESS) {
+ goto ExitPoint;
+ }
+
+ dwKey = 0;
+ do {
+ dwServerKeySize = MAX_KEY_SIZE;
+ regStatus = RegEnumKeyEx(
+ hKeyNetscape,
+ dwKey,
+ szServerKeyName,
+ &dwServerKeySize,
+ NULL,
+ 0,
+ 0,
+ &fileTime);
+ dwKey++;
+
+ if (regStatus == ERROR_SUCCESS) {
+
+ regStatus = RegOpenKeyEx(
+ hKeyNetscape,
+ szServerKeyName,
+ 0L,
+ KEY_ALL_ACCESS,
+ &hKeyNetscapeConf);
+
+ if (regStatus != ERROR_SUCCESS) {
+ continue;
+ }
+
+ /* Now look for "ConfigurationPath" to find 3.0 netscape servers */
+ size = MAX_KEY_SIZE;
+ status = RegQueryValueEx(
+ hKeyNetscapeConf,
+ TEXT(VALUE_CONFIG_PATH),
+ 0L,
+ &type,
+ (LPBYTE)szPath,
+ &size);
+ if ( status == ERROR_SUCCESS ) {
+ /* this is a netscape server */
+ if ( (pNew = (instance_list_t *)malloc(sizeof(instance_list_t))) == NULL) {
+ status = (unsigned long)-1;
+ RegCloseKey(hKeyNetscapeConf);
+ goto ExitPoint;
+ }
+ if ( (pNew->pInstanceName = (PWCH)malloc(sizeof(WCHAR) *(dwServerKeySize+1))) == NULL) {
+ status = (unsigned long)-1;
+ RegCloseKey(hKeyNetscapeConf);
+ goto ExitPoint;
+ }
+
+ if ( (pNew->pConfPath = (PWCH)malloc(sizeof(WCHAR) *(size+1))) == NULL) {
+ status = (unsigned long)-1;
+ RegCloseKey(hKeyNetscapeConf);
+ goto ExitPoint;
+ }
+
+
+ pNew->pData = NULL;
+
+ pNew->instance.ParentObjectTitleIndex = 0;
+ pNew->instance.ParentObjectInstance = 0;
+ pNew->instance.UniqueID = -1;
+ pNew->instance.NameOffset = sizeof(PERF_INSTANCE_DEFINITION);
+ lstrcpy(pNew->pInstanceName, szServerKeyName);
+ lstrcpy(pNew->pConfPath, szPath);
+
+ pNew->instance.NameLength = (dwServerKeySize+1) * sizeof(WCHAR);
+ pNew->instance.ByteLength = sizeof(PERF_INSTANCE_DEFINITION) +
+ (((pNew->instance.NameLength + sizeof(DWORD)-1)/sizeof(DWORD))*sizeof(DWORD));
+ pNew->instance.UniqueID = iUniqueID++;
+
+ pNew->pNext = pInstanceList;
+ pInstanceList = pNew;
+
+ dwServerCount++;
+ }
+
+ RegCloseKey(hKeyNetscapeConf);
+ }
+
+ } while ( regStatus != ERROR_NO_MORE_ITEMS );
+
+ExitPoint:
+ if (hKeyNetscape)
+ RegCloseKey (hKeyNetscape);
+
+ return dwServerCount;
+}
+
+/* _OpenNetscapeServers()
+ * Once the pInstanceList has been created, this routine will open the instances
+ * of the netscape servers;
+ */
+#define MAX_FILE_LEN 128
+DWORD
+_OpenNetscapeServers()
+{
+ LONG status;
+ DWORD dwServerCount = 0;
+ instance_list_t *pInstance;
+ char *szRootDir;
+ char tmpstatsfile[MAX_FILE_LEN];
+ int err;
+
+ for (pInstance = pInstanceList; pInstance; pInstance = pInstance->pNext) {
+
+ /* open the memory map */
+
+ /*
+ * Get directory for our stats file
+ */
+
+ szRootDir = getRootDirFromConfFile(pInstance->pConfPath);
+ if( szRootDir == NULL){
+ status = GetLastError();
+ continue ;
+ }
+ wsprintfA(tmpstatsfile, "%s/logs/%s", szRootDir, AGT_STATS_FILE);
+ err = MapSharedMem(tmpstatsfile,&pInstance->pData);
+ if ( 0 != err ) {
+ REPORT_ERROR (NSPERF_UNABLE_MAP_VIEW_OF_FILE, LOG_USER);
+ status = GetLastError(); // return error
+ continue;
+ } else {
+ dwServerCount++;
+ }
+
+ if(szRootDir != NULL){
+ free(szRootDir);
+ }
+
+ }
+
+ return dwServerCount;
+}
+
+export DWORD APIENTRY
+OpenNSPerformanceData(LPWSTR lpDeviceNames)
+{
+ LONG status;
+ TCHAR szMappedObject[] = TEXT(SVR_ID_SERVICE) TEXT("Statistics");
+ HKEY hKeyDriverPerf;
+ DWORD size;
+ DWORD type;
+ DWORD dwFirstCounter;
+ DWORD dwFirstHelp;
+
+ if (!dwOpenCount) {
+
+ hEventLog = MonOpenEventLog();
+
+
+ if ( !_FindNetscapeServers() ) {
+ /* No netscape servers found */
+ status = (unsigned long)-1;
+ goto OpenExitPoint;
+ }
+
+ if ( !(dwInstanceCount = _OpenNetscapeServers()) ) {
+ /* No netscape servers are active */
+ status = (unsigned long)-1;
+ goto OpenExitPoint;
+ }
+
+ /* Now load help keys from registry */
+
+ status = RegOpenKeyEx (
+ HKEY_LOCAL_MACHINE,
+ TEXT("System\\CurrentControlSet\\Services") TEXT("\\") TEXT(SVR_ID_SERVICE) TEXT(SVR_VERSION) TEXT("\\") TEXT(KEY_PERFORMANCE),
+ 0L,
+ KEY_ALL_ACCESS,
+ &hKeyDriverPerf);
+
+ if (status != ERROR_SUCCESS) {
+ REPORT_ERROR_DATA (NSPERF_UNABLE_OPEN_DRIVER_KEY, LOG_USER,
+ &status, sizeof(status));
+ goto OpenExitPoint;
+ }
+
+ size = sizeof (DWORD);
+ status = RegQueryValueEx(
+ hKeyDriverPerf,
+ TEXT("First Counter"),
+ 0L,
+ &type,
+ (LPBYTE)&dwFirstCounter,
+ &size);
+
+ if (status != ERROR_SUCCESS) {
+ REPORT_ERROR_DATA (NSPERF_UNABLE_READ_FIRST_COUNTER, LOG_USER,
+ &status, sizeof(status));
+ goto OpenExitPoint;
+ }
+
+ size = sizeof (DWORD);
+ status = RegQueryValueEx(
+ hKeyDriverPerf,
+ TEXT("First Help"),
+ 0L,
+ &type,
+ (LPBYTE)&dwFirstHelp,
+ &size);
+
+ if (status != ERROR_SUCCESS) {
+ REPORT_ERROR_DATA (NSPERF_UNABLE_READ_FIRST_HELP, LOG_USER,
+ &status, sizeof(status));
+ goto OpenExitPoint;
+ }
+
+ NSDataDefinition.NS_ObjectType.ObjectNameTitleIndex += dwFirstCounter;
+ NSDataDefinition.NS_ObjectType.ObjectHelpTitleIndex += dwFirstHelp;
+
+ NSDataDefinition.connection_rate.CounterNameTitleIndex += dwFirstCounter;
+ NSDataDefinition.connection_rate.CounterHelpTitleIndex += dwFirstHelp;
+ NSDataDefinition.throughput.CounterNameTitleIndex += dwFirstCounter;
+ NSDataDefinition.throughput.CounterHelpTitleIndex += dwFirstHelp;
+ NSDataDefinition.total_bytes_written.CounterNameTitleIndex += dwFirstCounter;
+ NSDataDefinition.total_bytes_written.CounterHelpTitleIndex += dwFirstHelp;
+ NSDataDefinition.total_bytes_read.CounterNameTitleIndex += dwFirstCounter;
+ NSDataDefinition.total_bytes_read.CounterHelpTitleIndex += dwFirstHelp;
+ NSDataDefinition.operation_rate.CounterNameTitleIndex += dwFirstCounter;
+ NSDataDefinition.operation_rate.CounterHelpTitleIndex += dwFirstHelp;
+ NSDataDefinition.total_errors.CounterNameTitleIndex += dwFirstCounter;
+ NSDataDefinition.total_errors.CounterHelpTitleIndex += dwFirstHelp;
+ NSDataDefinition.search_rate.CounterNameTitleIndex += dwFirstCounter;
+ NSDataDefinition.search_rate.CounterHelpTitleIndex += dwFirstHelp;
+ NSDataDefinition.add_rate.CounterNameTitleIndex += dwFirstCounter;
+ NSDataDefinition.add_rate.CounterHelpTitleIndex += dwFirstHelp;
+ NSDataDefinition.delete_rate.CounterNameTitleIndex += dwFirstCounter;
+ NSDataDefinition.delete_rate.CounterHelpTitleIndex += dwFirstHelp;
+ NSDataDefinition.modify_rate.CounterNameTitleIndex += dwFirstCounter;
+ NSDataDefinition.modify_rate.CounterHelpTitleIndex += dwFirstHelp;
+ NSDataDefinition.compare_rate.CounterNameTitleIndex += dwFirstCounter;
+ NSDataDefinition.compare_rate.CounterHelpTitleIndex += dwFirstHelp;
+ NSDataDefinition.moddn_rate.CounterNameTitleIndex += dwFirstCounter;
+ NSDataDefinition.moddn_rate.CounterHelpTitleIndex += dwFirstHelp;
+ NSDataDefinition.connections.CounterNameTitleIndex += dwFirstCounter;
+ NSDataDefinition.connections.CounterHelpTitleIndex += dwFirstHelp;
+ NSDataDefinition.bind_rate.CounterNameTitleIndex += dwFirstCounter;
+ NSDataDefinition.bind_rate.CounterHelpTitleIndex += dwFirstHelp;
+ NSDataDefinition.entries_returned.CounterNameTitleIndex += dwFirstCounter;
+ NSDataDefinition.entries_returned.CounterHelpTitleIndex += dwFirstHelp;
+ NSDataDefinition.entries_returned_rate.CounterNameTitleIndex += dwFirstCounter;
+ NSDataDefinition.entries_returned_rate.CounterHelpTitleIndex += dwFirstHelp;
+ NSDataDefinition.referrals_returned.CounterNameTitleIndex += dwFirstCounter;
+ NSDataDefinition.referrals_returned.CounterHelpTitleIndex += dwFirstHelp;
+ NSDataDefinition.referrals_returned_rate.CounterNameTitleIndex += dwFirstCounter;
+ NSDataDefinition.referrals_returned_rate.CounterHelpTitleIndex += dwFirstHelp;
+ NSDataDefinition.bytes_read_rate.CounterNameTitleIndex += dwFirstCounter;
+ NSDataDefinition.bytes_read_rate.CounterHelpTitleIndex += dwFirstHelp;
+ NSDataDefinition.bytes_written_rate.CounterNameTitleIndex += dwFirstCounter;
+ NSDataDefinition.bytes_written_rate.CounterHelpTitleIndex += dwFirstHelp;
+
+ RegCloseKey (hKeyDriverPerf);
+
+ bInitialized = TRUE;
+ }
+
+ dwOpenCount++;
+
+ status = ERROR_SUCCESS;
+
+OpenExitPoint:
+
+ return status;
+}
+
+/* --- Close Function -------------------------------------------------------------------- */
+export DWORD APIENTRY
+CloseNSPerformanceData()
+{
+ instance_list_t *pInstance, *pDead;
+
+ if (!(--dwOpenCount)) {
+
+ for (pDead = NULL, pInstance = pInstanceList; pInstance; pInstance=pInstance->pNext) {
+ if (pDead)
+ free(pDead);
+
+ /* I probably need to free stats too... make sure to add that later */
+ if (pInstance->pData)
+ UnmapSharedMem(&pInstance->pData);
+
+ free(pInstance->pInstanceName);
+ free(pInstance->pConfPath);
+ pDead = pInstance;
+ }
+ if (pDead) /* cleanup last instance */
+ free(pDead);
+
+ MonCloseEventLog();
+
+ bInitialized = FALSE;
+ }
+
+ return ERROR_SUCCESS;
+}
+
+struct _status_struct_s {
+ DWORD connection_rate;
+ DWORD throughput;
+ DWORD tot_bytes_written;
+ DWORD tot_bytes_read;
+ DWORD op_rate;
+ DWORD tot_errs;
+ DWORD search_rate;
+ DWORD add_rate;
+ DWORD delete_rate;
+ DWORD modify_rate;
+ DWORD compare_rate;
+ DWORD moddn_rate;
+ DWORD connections;
+ DWORD bind_rate;
+ DWORD entries_returned;
+ DWORD entries_returned_rate;
+ DWORD referrals_returned;
+ DWORD referrals_returned_rate;
+ DWORD bytes_read_rate;
+ DWORD bytes_written_rate;
+};
+
+void
+Get_Actual_Data(agt_stats_t *smem,
+ struct _status_struct_s *results)
+{
+ /* Copy over the counters from the shared memory region */
+ struct ops_stats_t *pOpsStats = &(smem->ops_stats);
+
+ results->search_rate = pOpsStats->dsSearchOps;
+ results->modify_rate = pOpsStats->dsModifyEntryOps;
+ results->add_rate = pOpsStats->dsAddEntryOps ;
+ results->compare_rate = pOpsStats->dsCompareOps ;
+ results->moddn_rate = pOpsStats->dsModifyRDNOps ;
+ results->delete_rate = pOpsStats->dsRemoveEntryOps ;
+ results->bind_rate = pOpsStats->dsAnonymousBinds + pOpsStats->dsStrongAuthBinds + pOpsStats->dsSimpleAuthBinds ;
+ results->op_rate = results->search_rate + results->add_rate + results->delete_rate +
+ results->modify_rate + results->compare_rate + results->moddn_rate + results->bind_rate;
+ results->connections = 0;
+ results->tot_errs = pOpsStats->dsErrors ;
+ results->connections = pOpsStats->dsConnections ;
+ results->tot_bytes_written = pOpsStats->dsBytesSent ;
+ results->tot_bytes_read = pOpsStats->dsBytesRecv ;
+ results->throughput = pOpsStats->dsBytesSent + pOpsStats->dsBytesRecv;
+ results->connection_rate = pOpsStats->dsConnectionSeq ;
+ results->entries_returned = pOpsStats->dsEntriesReturned ;
+ results->entries_returned_rate = pOpsStats->dsEntriesReturned ;
+ results->referrals_returned = pOpsStats->dsReferralsReturned ;
+ results->referrals_returned_rate = pOpsStats->dsReferralsReturned ;
+ results->bytes_read_rate = pOpsStats->dsBytesRecv ;
+ results->bytes_written_rate = pOpsStats->dsBytesSent ;
+ /* Still to do : connections, throughput, db hit ratio, entry cache hit ratio */
+}
+
+/* --- Collect Function ------------------------------------------------------------------- */
+export DWORD APIENTRY
+CollectNSPerformanceData(
+ IN LPWSTR lpValueName,
+ IN OUT LPVOID *lppData,
+ IN OUT LPDWORD lpcbTotalBytes,
+ IN OUT LPDWORD lpNumObjectTypes
+)
+{
+ ULONG SpaceNeeded;
+ PDWORD pdwCounter;
+ PERF_COUNTER_BLOCK *pPerfCounterBlock;
+ NS_DATA_DEFINITION *pNSDataDefinition;
+ DWORD dwQueryType;
+ instance_list_t *pInstance;
+
+ if (!bInitialized) {
+ *lpcbTotalBytes = (DWORD) 0;
+ *lpNumObjectTypes = (DWORD) 0;
+ return ERROR_SUCCESS;
+ }
+
+ dwQueryType = GetQueryType (lpValueName);
+
+ if (dwQueryType == QUERY_FOREIGN) {
+ // this routine does not service requests for data from
+ // Non-NT computers
+ *lpcbTotalBytes = (DWORD) 0;
+ *lpNumObjectTypes = (DWORD) 0;
+ return ERROR_SUCCESS;
+ }
+
+ if (dwQueryType == QUERY_ITEMS){
+ if ( !(IsNumberInUnicodeList (NSDataDefinition.NS_ObjectType.ObjectNameTitleIndex, lpValueName))) {
+ // request received for data object not provided by this routine
+ *lpcbTotalBytes = (DWORD) 0;
+ *lpNumObjectTypes = (DWORD) 0;
+ return ERROR_SUCCESS;
+ }
+ }
+ /* -------- OK DO THE REAL WORK HERE ---------- */
+
+
+ /* -------------------------------------------- */
+ /* | PERF_DATA_BLOCK (header) | */
+ /* -------------------------------------------- */
+ /* | PERF_OBJECT_TYPE 1 | */
+ /* -------------------------------------------- */
+ /* | PERF_OBJECT_TYPE 2 | */
+ /* -------------------------------------------- */
+ /* | . | */
+ /* | . | */
+ /* | . | */
+ /* | | */
+ /* | | */
+ /* -------------------------------------------- */
+
+
+ /* -------------------------------------------- */
+ /* | PERF_OBJECT_TYPE (header) | */
+ /* -------------------------------------------- */
+ /* | PERF_COUNTER_DEFINITION 1 | */
+ /* -------------------------------------------- */
+ /* | PERF_COUNTER_DEFINITION 2 | */
+ /* -------------------------------------------- */
+ /* | . | */
+ /* | . | */
+ /* | . | */
+ /* | | */
+ /* -------------------------------------------- */
+ /* | PERF_INSTANCE_DEFINITION 1 | */
+ /* -------------------------------------------- */
+ /* | PERF_INSTANCE_DEFINITION 2 | */
+ /* -------------------------------------------- */
+ /* | . | */
+ /* | . | */
+ /* | . | */
+ /* | | */
+ /* | | */
+ /* -------------------------------------------- */
+
+
+ /* -------------------------------------------- */
+ /* | PERF_INSTANCE_DEFINITION (header) | */
+ /* -------------------------------------------- */
+ /* | Instance Name (variable) | */
+ /* -------------------------------------------- */
+ /* | PERF_COUNTER_BLOCK (header) | */
+ /* -------------------------------------------- */
+ /* | Counter Data (variable) | */
+ /* -------------------------------------------- */
+
+
+
+ /* Check to see if there is enough space in caller's buffer */
+
+ pNSDataDefinition = (NS_DATA_DEFINITION *) *lppData;
+
+ SpaceNeeded = sizeof(NS_DATA_DEFINITION) + (dwInstanceCount *
+ (SIZE_OF_NS_PERFORMANCE_DATA + MAX_KEY_SIZE + sizeof(PERF_COUNTER_BLOCK) +
+ sizeof(PERF_INSTANCE_DEFINITION)));
+
+ if ( *lpcbTotalBytes < SpaceNeeded ) {
+ *lpcbTotalBytes = (DWORD) 0;
+ *lpNumObjectTypes = (DWORD) 0;
+ return ERROR_MORE_DATA;
+ }
+
+ /* Set the PERF_OBJECT_TYPE definition and PERF_COUNTER_DEFINITIONs */
+ NSDataDefinition.NS_ObjectType.NumInstances = dwInstanceCount;
+ memmove(pNSDataDefinition, &NSDataDefinition, sizeof(NS_DATA_DEFINITION));
+
+ pdwCounter = (PDWORD) &(pNSDataDefinition[1]);
+
+ for ( pInstance = pInstanceList; pInstance; pInstance=pInstance->pNext) {
+
+ if ( pInstance->pData ) {
+
+ /* Set the PERF_INSTANCE_DEFINITION */
+ memmove(pdwCounter, &(pInstance->instance), sizeof(PERF_INSTANCE_DEFINITION));
+ pdwCounter += ((sizeof(PERF_INSTANCE_DEFINITION))/sizeof(DWORD));
+
+ /* Set the Instance Name */
+ memmove(pdwCounter, pInstance->pInstanceName, pInstance->instance.NameLength);
+ pdwCounter = pdwCounter + ((pInstance->instance.NameLength + sizeof(DWORD)-1)/sizeof(DWORD));
+
+ /* Set the PERF_COUNTER_BLOCK */
+ pPerfCounterBlock = (PERF_COUNTER_BLOCK *) pdwCounter;
+ pPerfCounterBlock->ByteLength = SIZE_OF_NS_PERFORMANCE_DATA + sizeof(PERF_COUNTER_BLOCK);
+ pdwCounter = (PDWORD) (&pPerfCounterBlock[1]);
+
+ /* Set the Instance Data */
+ Get_Actual_Data(pInstance->pData,(struct _status_struct_s*)pdwCounter);
+
+ {
+ DWORD x = (SIZE_OF_NS_PERFORMANCE_DATA) / sizeof(DWORD);
+
+ pdwCounter += x;
+ }
+ }
+ }
+
+ *lppData = (PVOID)(pdwCounter);
+ *lpNumObjectTypes = 1;
+ *lpcbTotalBytes = (PBYTE) pdwCounter - (PBYTE) pNSDataDefinition;
+ pNSDataDefinition->NS_ObjectType.TotalByteLength = *lpcbTotalBytes;
+
+ return ERROR_SUCCESS;
+}
+
diff --git a/ldap/servers/slapd/ntperfdll/nsldapctrdef.h b/ldap/servers/slapd/ntperfdll/nsldapctrdef.h
new file mode 100644
index 00000000..77b5d279
--- /dev/null
+++ b/ldap/servers/slapd/ntperfdll/nsldapctrdef.h
@@ -0,0 +1,33 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+/*
+ * nsctrdef.h
+ *
+ * Defines offsets of netscape server performance monitor counters.
+ */
+
+#define NS_OBJ 0
+#define CONN_RATE 2
+#define THROUGHPUT 4
+#define TOTAL_BYTES_WRITTEN 6
+#define TOTAL_BYTES_READ 8
+#define OP_RATE 10
+#define TOTAL_ERRORS 12
+#define SEARCH_RATE 14
+#define ADD_RATE 16
+#define DELETE_RATE 18
+#define MODIFY_RATE 20
+#define COMPARE_RATE 22
+#define MODDN_RATE 24
+#define CONNECTIONS 26
+#define BIND_RATE 28
+#define ENTRIES_RETURNED 30
+#define ENTRIES_RETURNED_RATE 32
+#define REFERRALS_RETURNED 34
+#define REFERRALS_RETURNED_RATE 36
+#define BYTES_READ_RATE 38
+#define BYTES_WRITTEN_RATE 40
+
diff --git a/ldap/servers/slapd/ntperfdll/nsldapctrmc.h b/ldap/servers/slapd/ntperfdll/nsldapctrmc.h
new file mode 100644
index 00000000..2178d6be
--- /dev/null
+++ b/ldap/servers/slapd/ntperfdll/nsldapctrmc.h
@@ -0,0 +1,122 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+/*
+ * nsctrs.h
+ */
+//
+#ifndef _NSCTRMC_H_
+#define _NSCTRMC_H_
+//
+//
+// Perfutil messages
+//
+//
+// Values are 32 bit values layed out as follows:
+//
+// 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
+// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+// +---+-+-+-----------------------+-------------------------------+
+// |Sev|C|R| Facility | Code |
+// +---+-+-+-----------------------+-------------------------------+
+//
+// where
+//
+// Sev - is the severity code
+//
+// 00 - Success
+// 01 - Informational
+// 10 - Warning
+// 11 - Error
+//
+// C - is the Customer code flag
+//
+// R - is a reserved bit
+//
+// Facility - is the facility code
+//
+// Code - is the facility's status code
+//
+//
+// Define the facility codes
+//
+
+
+//
+// Define the severity codes
+//
+
+
+//
+// MessageId: UTIL_LOG_OPEN
+//
+// MessageText:
+//
+// An extensible counter has opened the Event Log for NSCTRS.DLL
+//
+#define UTIL_LOG_OPEN ((DWORD)0x4000076CL)
+
+//
+//
+// MessageId: UTIL_CLOSING_LOG
+//
+// MessageText:
+//
+// An extensible counter has closed the Event Log for NSCTRS.DLL
+//
+#define UTIL_CLOSING_LOG ((DWORD)0x400007CFL)
+
+//
+//
+// MessageId: NSPERF_OPEN_FILE_MAPPING_ERROR
+//
+// MessageText:
+//
+// Unable to open mapped file containing NS driver performance data.
+//
+#define NSPERF_OPEN_FILE_MAPPING_ERROR ((DWORD)0xC00007D0L)
+
+//
+//
+// MessageId: NSPERF_UNABLE_MAP_VIEW_OF_FILE
+//
+// MessageText:
+//
+// Unable to map to shared memory file containing NS driver performance data.
+//
+#define NSPERF_UNABLE_MAP_VIEW_OF_FILE ((DWORD)0xC00007D1L)
+
+//
+//
+// MessageId: NSPERF_UNABLE_OPEN_DRIVER_KEY
+//
+// MessageText:
+//
+// Unable open "Performance" key of NS driver in registry. Status code is returned in data.
+//
+#define NSPERF_UNABLE_OPEN_DRIVER_KEY ((DWORD)0xC00007D2L)
+
+//
+//
+// MessageId: NSPERF_UNABLE_READ_FIRST_COUNTER
+//
+// MessageText:
+//
+// Unable to read the "First Counter" value under the NS\Performance Key. Status codes returned in data.
+//
+#define NSPERF_UNABLE_READ_FIRST_COUNTER ((DWORD)0xC00007D3L)
+
+//
+//
+// MessageId: NSPERF_UNABLE_READ_FIRST_HELP
+//
+// MessageText:
+//
+// Unable to read the "First Help" value under the NS\Performance Key. Status codes returned in data.
+//
+#define NSPERF_UNABLE_READ_FIRST_HELP ((DWORD)0xC00007D4L)
+
+//
+#endif // _NSCTRMC_H_
diff --git a/ldap/servers/slapd/ntperfdll/nsldapctrmc.mc b/ldap/servers/slapd/ntperfdll/nsldapctrmc.mc
new file mode 100644
index 00000000..10c8341f
--- /dev/null
+++ b/ldap/servers/slapd/ntperfdll/nsldapctrmc.mc
@@ -0,0 +1,74 @@
+; BEGIN COPYRIGHT BLOCK
+; Copyright 2001 Sun Microsystems, Inc.
+; Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+; All rights reserved.
+; END COPYRIGHT BLOCK
+;
+;/*
+; * nsctrs.h
+; */
+;//
+;#ifndef _NSCTRMC_H_
+;#define _NSCTRMC_H_
+;//
+MessageIdTypedef=DWORD
+;//
+;// Perfutil messages
+;//
+MessageId=1900
+Severity=Informational
+Facility=Application
+SymbolicName=UTIL_LOG_OPEN
+Language=English
+An extensible counter has opened the Event Log for NSCTRS.DLL
+.
+;//
+MessageId=1999
+Severity=Informational
+Facility=Application
+SymbolicName=UTIL_CLOSING_LOG
+Language=English
+An extensible counter has closed the Event Log for NSCTRS.DLL
+.
+;//
+MessageId=2000
+Severity=Error
+Facility=Application
+SymbolicName=NSPERF_OPEN_FILE_MAPPING_ERROR
+Language=English
+Unable to open mapped file containing NS driver performance data.
+.
+;//
+MessageId=+1
+Severity=Error
+Facility=Application
+SymbolicName=NSPERF_UNABLE_MAP_VIEW_OF_FILE
+Language=English
+Unable to map to shared memory file containing NS driver performance data.
+.
+;//
+MessageId=+1
+Severity=Error
+Facility=Application
+SymbolicName=NSPERF_UNABLE_OPEN_DRIVER_KEY
+Language=English
+Unable open "Performance" key of NS driver in registry. Status code is returned in data.
+.
+;//
+MessageId=+1
+Severity=Error
+Facility=Application
+SymbolicName=NSPERF_UNABLE_READ_FIRST_COUNTER
+Language=English
+Unable to read the "First Counter" value under the NS\Performance Key. Status codes returned in data.
+.
+;//
+MessageId=+1
+Severity=Error
+Facility=Application
+SymbolicName=NSPERF_UNABLE_READ_FIRST_HELP
+Language=English
+Unable to read the "First Help" value under the NS\Performance Key. Status codes returned in data.
+.
+;//
+;#endif // _NSCTRMC_H_
diff --git a/ldap/servers/slapd/ntperfdll/nsldapctrmsg.h b/ldap/servers/slapd/ntperfdll/nsldapctrmsg.h
new file mode 100644
index 00000000..684ed821
--- /dev/null
+++ b/ldap/servers/slapd/ntperfdll/nsldapctrmsg.h
@@ -0,0 +1,60 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+/*
+ * nsctrmsg.h
+ *
+ * Defines EventLog error handling stuff for performance monitor dll.
+ *
+ */
+
+
+#ifndef _NSCTRMSG_H_
+#define _NSCTRMSG_H_
+//
+// Report error message ID's for Counters
+//
+
+#define APP_NAME "nsctrs"
+
+/* Levels: LOG_NONE = No event log messages ever
+ * LOG_USER = User event log messages (e.g. errors)
+ * LOG_DEBUG = Minimum Debugging
+ * LOG_VERBOSE = Maximum Debugging
+ */
+
+#define LOG_NONE 0
+#define LOG_USER 1
+#define LOG_DEBUG 2
+#define LOG_VERBOSE 3
+
+#define MESSAGE_LEVEL_DEFAULT LOG_USER
+
+#define REPORT_SUCCESS(i,l) (MESSAGE_LEVEL >= l ? ReportEvent (hEventLog, EVENTLOG_INFORMATION_TYPE, \
+ 0, i, (PSID)NULL, 0, 0, NULL, (PVOID)NULL) : FALSE)
+
+#define REPORT_INFORMATION(i,l) (MESSAGE_LEVEL >= l ? ReportEvent (hEventLog, EVENTLOG_INFORMATION_TYPE, \
+ 0, i, (PSID)NULL, 0, 0, NULL, (PVOID)NULL) : FALSE)
+
+#define REPORT_WARNING(i,l) (MESSAGE_LEVEL >= l ? ReportEvent (hEventLog, EVENTLOG_WARNING_TYPE, \
+ 0, i, (PSID)NULL, 0, 0, NULL, (PVOID)NULL) : FALSE)
+
+#define REPORT_ERROR(i,l) (MESSAGE_LEVEL >= l ? ReportEvent (hEventLog, EVENTLOG_ERROR_TYPE, \
+ 0, i, (PSID)NULL, 0, 0, NULL, (PVOID)NULL) : FALSE)
+
+#define REPORT_INFORMATION_DATA(i,l,d,s) (MESSAGE_LEVEL >= l ? ReportEvent (hEventLog, EVENTLOG_INFORMATION_TYPE, \
+ 0, i, (PSID)NULL, 0, s, NULL, (PVOID)(d)) : FALSE)
+
+#define REPORT_WARNING_DATA(i,l,d,s) (MESSAGE_LEVEL >= l ? ReportEvent (hEventLog, EVENTLOG_WARNING_TYPE, \
+ 0, i, (PSID)NULL, 0, s, NULL, (PVOID)(d)) : FALSE)
+
+#define REPORT_ERROR_DATA(i,l,d,s) (MESSAGE_LEVEL >= l ? ReportEvent (hEventLog, EVENTLOG_ERROR_TYPE, \
+ 0, i, (PSID)NULL, 0, s, NULL, (PVOID)(d)) : FALSE)
+
+extern HANDLE hEventLog; /* handle to event log */
+extern DWORD dwLogUsers; /* counter of event log using routines */
+extern DWORD MESSAGE_LEVEL; /* event logging detail level */
+
+#endif /* _NSCTRMSG_H_ */
diff --git a/ldap/servers/slapd/ntperfdll/nsldapctrs.h b/ldap/servers/slapd/ntperfdll/nsldapctrs.h
new file mode 100644
index 00000000..3bd4c70a
--- /dev/null
+++ b/ldap/servers/slapd/ntperfdll/nsldapctrs.h
@@ -0,0 +1,67 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+/*
+
+ nsctrs.h
+
+ */
+
+#ifndef _NSCTRS_H_
+#define _NSCTRS_H_
+
+#pragma pack (4)
+
+#define NS_NUM_PERF_OBJECT_TYPES 1
+#define NUM_CONN_RATE_OFFSET sizeof(DWORD)
+#define NUM_THROUGHPUT_OFFSET NUM_CONN_RATE_OFFSET + sizeof(DWORD)
+#define NUM_TOTAL_BYTES_WRITTEN_OFFSET NUM_THROUGHPUT_OFFSET + sizeof(DWORD)
+#define NUM_TOTAL_BYTES_READ_OFFSET NUM_TOTAL_BYTES_WRITTEN_OFFSET + sizeof(DWORD)
+#define NUM_OP_RATE_OFFSET NUM_TOTAL_BYTES_READ_OFFSET + sizeof(DWORD)
+#define NUM_TOTAL_ERRORS_OFFSET NUM_OP_RATE_OFFSET + sizeof(DWORD)
+#define NUM_SEARCH_RATE_OFFSET NUM_TOTAL_ERRORS_OFFSET + sizeof(DWORD)
+#define ADD_RATE_OFFSET NUM_SEARCH_RATE_OFFSET + sizeof(DWORD)
+#define DELETE_RATE_OFFSET ADD_RATE_OFFSET + sizeof(DWORD)
+#define MODIFY_RATE_OFFSET DELETE_RATE_OFFSET + sizeof(DWORD)
+#define COMPARE_RATE_OFFSET MODIFY_RATE_OFFSET + sizeof(DWORD)
+#define MODDN_RATE_OFFSET COMPARE_RATE_OFFSET + sizeof(DWORD)
+#define CONNECTIONS_OFFSET MODDN_RATE_OFFSET + sizeof(DWORD)
+#define BIND_RATE_OFFSET CONNECTIONS_OFFSET + sizeof(DWORD)
+#define ENTRIES_RETURNED_OFFSET BIND_RATE_OFFSET + sizeof(DWORD)
+#define ENTRIES_RETURNED_RATE_OFFSET ENTRIES_RETURNED_OFFSET + sizeof(DWORD)
+#define REFERRALS_RETURNED_OFFSET ENTRIES_RETURNED_RATE_OFFSET + sizeof(DWORD)
+#define REFERRALS_RETURNED_RATE_OFFSET REFERRALS_RETURNED_OFFSET + sizeof(DWORD)
+#define BYTES_READ_RATE_OFFSET REFERRALS_RETURNED_RATE_OFFSET + sizeof(DWORD)
+#define BYTES_WRITTEN_RATE_OFFSET BYTES_READ_RATE_OFFSET + sizeof(DWORD)
+#define SIZE_OF_NS_PERFORMANCE_DATA BYTES_WRITTEN_RATE_OFFSET + sizeof(DWORD)
+
+typedef struct _NS_DATA_DEFINITION {
+ PERF_OBJECT_TYPE NS_ObjectType;
+ PERF_COUNTER_DEFINITION connection_rate;
+ PERF_COUNTER_DEFINITION throughput;
+ PERF_COUNTER_DEFINITION total_bytes_written;
+ PERF_COUNTER_DEFINITION total_bytes_read;
+ PERF_COUNTER_DEFINITION operation_rate;
+ PERF_COUNTER_DEFINITION total_errors;
+ PERF_COUNTER_DEFINITION search_rate;
+ PERF_COUNTER_DEFINITION add_rate;
+ PERF_COUNTER_DEFINITION delete_rate;
+ PERF_COUNTER_DEFINITION modify_rate;
+ PERF_COUNTER_DEFINITION compare_rate;
+ PERF_COUNTER_DEFINITION moddn_rate;
+ PERF_COUNTER_DEFINITION connections;
+ PERF_COUNTER_DEFINITION bind_rate;
+ PERF_COUNTER_DEFINITION entries_returned;
+ PERF_COUNTER_DEFINITION entries_returned_rate;
+ PERF_COUNTER_DEFINITION referrals_returned;
+ PERF_COUNTER_DEFINITION referrals_returned_rate;
+ PERF_COUNTER_DEFINITION bytes_read_rate;
+ PERF_COUNTER_DEFINITION bytes_written_rate;
+} NS_DATA_DEFINITION;
+
+#pragma pack ()
+
+#endif /* _NSCTRS_H_ */
+
diff --git a/ldap/servers/slapd/ntperfdll/nsldapctrs.ini b/ldap/servers/slapd/ntperfdll/nsldapctrs.ini
new file mode 100644
index 00000000..82db3140
--- /dev/null
+++ b/ldap/servers/slapd/ntperfdll/nsldapctrs.ini
@@ -0,0 +1,57 @@
+#
+# BEGIN COPYRIGHT BLOCK
+# Copyright 2001 Sun Microsystems, Inc.
+# Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+# All rights reserved.
+# END COPYRIGHT BLOCK
+#
+[info]
+drivername=slapd7
+symbolfile=nsldapctrdef.h
+
+[languages]
+009=English
+
+[text]
+NS_OBJ_009_NAME=Netscape Directory Server 7.0
+NS_OBJ_009_HELP=Netscape Directory Server
+CONN_RATE_009_NAME=Client Connections/sec
+CONN_RATE_009_HELP=Rate of incoming client connections
+THROUGHPUT_009_NAME=Server Network Throughput (bytes/sec)
+THROUGHPUT_009_HELP=Number of bytes both sent and received per second on client connections
+TOTAL_BYTES_WRITTEN_009_NAME=Total Bytes Sent
+TOTAL_BYTES_WRITTEN_009_HELP=Total number of Bytes sent by the server since startup
+TOTAL_BYTES_READ_009_NAME=Total Bytes Received
+TOTAL_BYTES_READ_009_HELP=Total number of Bytes received by the server since startup
+OP_RATE_009_NAME=Operations/sec
+OP_RATE_009_HELP=Number of Operations (total of search, bind, modify, compare, modDN, delete) serviced per second
+SEARCH_RATE_009_NAME=Searches/sec
+SEARCH_RATE_009_HELP=Number of Search operations performed per second
+TOTAL_ERRORS_009_NAME=Total Number of Errors
+TOTAL_ERRORS_009_HELP=Total number of Errors seen by the server since startup
+ADD_RATE_009_NAME=Adds/sec
+ADD_RATE_009_HELP=Number of Add operations performed per second
+DELETE_RATE_009_NAME=Deletes/sec
+DELETE_RATE_009_HELP=Number of Delete operations performed per second
+MODIFY_RATE_009_NAME=Modifies/sec
+MODIFY_RATE_009_HELP=Number of Modify operations performed per second
+COMPARE_RATE_009_NAME=Compares/sec
+COMPARE_RATE_009_HELP=Number of Compare operations performed per second
+MODDN_RATE_009_NAME=ModDNs/sec
+MODDN_RATE_009_HELP=Number of ModDN operations performed per second
+CONNECTIONS_009_NAME=Connected Clients
+CONNECTIONS_009_HELP=Number of client sessions currently connected
+BIND_RATE_009_NAME=Binds/sec
+BIND_RATE_009_HELP=Number of Bind operations performed per second
+ENTRIES_RETURNED_009_NAME=Entries Returned
+ENTRIES_RETURNED_009_HELP=Number of entries returned to clients since startup
+ENTRIES_RETURNED_RATE_009_NAME=Entries Returned/sec
+ENTRIES_RETURNED_RATE_009_HELP=Number of entries returned to clients per second
+REFERRALS_RETURNED_009_NAME=Referrals Returned
+REFERRALS_RETURNED_009_HELP=Number of referrals returned to clients since startup
+REFERRALS_RETURNED_RATE_009_NAME=Referrals Returned/sec
+REFERRALS_RETURNED_RATE_009_HELP=Number of referrals returned to clients per second
+BYTES_READ_RATE_009_NAME=Network Bytes Read/sec
+BYTES_READ_RATE_009_HELP=Number of bytes per second read from connected clients
+BYTES_WRITTEN_RATE_009_NAME=Network Bytes Written/sec
+BYTES_WRITTEN_RATE_009_HELP=Number of bytes per second written to connected clients
diff --git a/ldap/servers/slapd/ntperfdll/nsldapctrutil.cpp b/ldap/servers/slapd/ntperfdll/nsldapctrutil.cpp
new file mode 100644
index 00000000..1783aee2
--- /dev/null
+++ b/ldap/servers/slapd/ntperfdll/nsldapctrutil.cpp
@@ -0,0 +1,364 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+/*
+
+ nsctrutil.c
+
+ Performance Monitor utility functions
+
+ This file implements the utility routines used to construct the
+ common parts of a PERF_INSTANCE_DEFINITION (see winperf.h) and
+ perform event logging functions.
+
+ */
+
+#include <windows.h>
+#include <string.h>
+#include <winperf.h>
+#include "nsldapctrmc.h"
+#include "nsldapctrmsg.h"
+#include "nsldapctrutil.h"
+
+#define INITIAL_SIZE 1024L
+#define EXTEND_SIZE 1024L
+
+//
+// Global data definitions.
+//
+
+ULONG ulInfoBufferSize = 0;
+
+HANDLE hEventLog; // handle to event log
+
+DWORD dwLogUsers = 0; // count of functions using event log
+
+DWORD MESSAGE_LEVEL = 0;
+
+WCHAR GLOBAL_STRING[] = L"Global";
+WCHAR FOREIGN_STRING[] = L"Foreign";
+WCHAR COSTLY_STRING[] = L"Costly";
+
+WCHAR NULL_STRING[] = L"\0"; // pointer to null string
+
+// test for delimiter, end of line and non-digit characters
+// used by IsNumberInUnicodeList routine
+//
+#define DIGIT 1
+#define DELIMITER 2
+#define INVALID 3
+
+#define EvalThisChar(c,d) ( \
+ (c == d) ? DELIMITER : \
+ (c == 0) ? DELIMITER : \
+ (c < (WCHAR)'0') ? INVALID : \
+ (c > (WCHAR)'9') ? INVALID : \
+ DIGIT)
+
+HANDLE
+MonOpenEventLog (
+)
+/*++
+
+Routine Description:
+
+ Reads the level of event logging from the registry and opens the
+ channel to the event logger for subsequent event log entries.
+
+Arguments:
+
+ None
+
+Return Value:
+
+ Handle to the event log for reporting events.
+ NULL if open not successful.
+
+--*/
+
+
+{
+
+
+ HKEY hAppKey;
+
+
+ TCHAR LogLevelKeyName[] = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Perflib";
+
+
+ TCHAR LogLevelValueName[] = "EventLogLevel";
+
+ LONG lStatus;
+
+ DWORD dwLogLevel;
+ DWORD dwValueType;
+ DWORD dwValueSize;
+
+ // if global value of the logging level not initialized or is disabled,
+ // check the registry to see if it should be updated.
+
+ if (!MESSAGE_LEVEL) {
+
+ lStatus = RegOpenKeyEx (HKEY_LOCAL_MACHINE,
+ LogLevelKeyName,
+ 0,
+ KEY_READ,
+ &hAppKey);
+
+ dwValueSize = sizeof (dwLogLevel);
+
+ if (lStatus == ERROR_SUCCESS) {
+ lStatus = RegQueryValueEx (hAppKey,
+ LogLevelValueName,
+ (LPDWORD)NULL,
+ &dwValueType,
+ (LPBYTE)&dwLogLevel,
+ &dwValueSize);
+
+ if (lStatus == ERROR_SUCCESS) {
+ MESSAGE_LEVEL = dwLogLevel;
+ } else {
+ MESSAGE_LEVEL = MESSAGE_LEVEL_DEFAULT;
+ }
+ RegCloseKey (hAppKey);
+ } else {
+
+
+ MESSAGE_LEVEL = MESSAGE_LEVEL_DEFAULT;
+ }
+ }
+
+ if (hEventLog == NULL){
+ hEventLog = RegisterEventSource (
+ (LPTSTR)NULL, // Use Local Machine
+ APP_NAME); // event log app name to find in registry
+ }
+
+ if (hEventLog != NULL) {
+ dwLogUsers++; // increment count of perfctr log users
+ }
+ return (hEventLog);
+}
+
+VOID
+MonCloseEventLog (
+)
+/*++
+
+Routine Description:
+
+ Closes the handle to the event logger if this is the last caller
+
+Arguments:
+
+ None
+
+Return Value:
+
+ None
+
+--*/
+{
+ if (hEventLog != NULL) {
+ dwLogUsers--; // decrement usage
+ if (dwLogUsers <= 0) { // and if we're the last, then close up log
+ DeregisterEventSource (hEventLog);
+ }
+ }
+}
+
+DWORD
+GetQueryType (
+ IN LPWSTR lpValue
+)
+/*++
+
+GetQueryType
+
+ returns the type of query described in the lpValue string so that
+ the appropriate processing method may be used
+
+Arguments
+
+ IN lpValue
+ string passed to PerfRegQuery Value for processing
+
+Return Value
+
+ QUERY_GLOBAL
+ if lpValue == 0 (null pointer)
+ lpValue == pointer to Null string
+ lpValue == pointer to "Global" string
+
+ QUERY_FOREIGN
+ if lpValue == pointer to "Foreign" string
+
+ QUERY_COSTLY
+ if lpValue == pointer to "Costly" string
+
+ otherwise:
+
+ QUERY_ITEMS
+
+--*/
+{
+ WCHAR *pwcArgChar, *pwcTypeChar;
+ BOOL bFound;
+
+ if (lpValue == 0) {
+ return QUERY_GLOBAL;
+ } else if (*lpValue == 0) {
+ return QUERY_GLOBAL;
+ }
+
+ // check for "Global" request
+
+ pwcArgChar = lpValue;
+ pwcTypeChar = GLOBAL_STRING;
+ bFound = TRUE; // assume found until contradicted
+
+ // check to the length of the shortest string
+
+ while ((*pwcArgChar != 0) && (*pwcTypeChar != 0)) {
+ if (*pwcArgChar++ != *pwcTypeChar++) {
+ bFound = FALSE; // no match
+ break; // bail out now
+ }
+ }
+
+ if (bFound) return QUERY_GLOBAL;
+
+ // check for "Foreign" request
+
+ pwcArgChar = lpValue;
+ pwcTypeChar = FOREIGN_STRING;
+ bFound = TRUE; // assume found until contradicted
+
+ // check to the length of the shortest string
+
+ while ((*pwcArgChar != 0) && (*pwcTypeChar != 0)) {
+ if (*pwcArgChar++ != *pwcTypeChar++) {
+ bFound = FALSE; // no match
+ break; // bail out now
+ }
+ }
+
+ if (bFound) return QUERY_FOREIGN;
+
+ // check for "Costly" request
+
+ pwcArgChar = lpValue;
+ pwcTypeChar = COSTLY_STRING;
+ bFound = TRUE; // assume found until contradicted
+
+ // check to the length of the shortest string
+
+ while ((*pwcArgChar != 0) && (*pwcTypeChar != 0)) {
+ if (*pwcArgChar++ != *pwcTypeChar++) {
+ bFound = FALSE; // no match
+ break; // bail out now
+ }
+ }
+
+ if (bFound) return QUERY_COSTLY;
+
+ // if not Global and not Foreign and not Costly,
+ // then it must be an item list
+
+ return QUERY_ITEMS;
+
+}
+
+BOOL
+IsNumberInUnicodeList (
+ IN DWORD dwNumber,
+ IN LPWSTR lpwszUnicodeList
+)
+/*++
+
+IsNumberInUnicodeList
+
+Arguments:
+
+ IN dwNumber
+ DWORD number to find in list
+
+ IN lpwszUnicodeList
+ Null terminated, Space delimited list of decimal numbers
+
+Return Value:
+
+ TRUE:
+ dwNumber was found in the list of unicode number strings
+
+ FALSE:
+ dwNumber was not found in the list.
+
+--*/
+{
+ DWORD dwThisNumber;
+ WCHAR *pwcThisChar;
+ BOOL bValidNumber;
+ BOOL bNewItem;
+ //BOOL bReturnValue;
+ WCHAR wcDelimiter; // could be an argument to be more flexible
+
+ if (lpwszUnicodeList == 0) return FALSE; // null pointer, # not found
+
+ pwcThisChar = lpwszUnicodeList;
+ dwThisNumber = 0;
+ wcDelimiter = (WCHAR)' ';
+ bValidNumber = FALSE;
+ bNewItem = TRUE;
+
+ while (TRUE) {
+ switch (EvalThisChar (*pwcThisChar, wcDelimiter)) {
+ case DIGIT:
+ // if this is the first digit after a delimiter, then
+ // set flags to start computing the new number
+ if (bNewItem) {
+ bNewItem = FALSE;
+ bValidNumber = TRUE;
+ }
+ if (bValidNumber) {
+ dwThisNumber *= 10;
+ dwThisNumber += (*pwcThisChar - (WCHAR)'0');
+ }
+ break;
+
+ case DELIMITER:
+ // a delimiter is either the delimiter character or the
+ // end of the string ('\0') if when the delimiter has been
+ // reached a valid number was found, then compare it to the
+ // number from the argument list. if this is the end of the
+ // string and no match was found, then return.
+ //
+ if (bValidNumber) {
+ if (dwThisNumber == dwNumber) return TRUE;
+ bValidNumber = FALSE;
+ }
+ if (*pwcThisChar == 0) {
+ return FALSE;
+ } else {
+ bNewItem = TRUE;
+ dwThisNumber = 0;
+ }
+ break;
+
+ case INVALID:
+ // if an invalid character was encountered, ignore all
+ // characters up to the next delimiter and then start fresh.
+ // the invalid number is not compared.
+ bValidNumber = FALSE;
+ break;
+
+ default:
+ break;
+
+ }
+ pwcThisChar++;
+ }
+
+} // IsNumberInUnicodeList
diff --git a/ldap/servers/slapd/ntperfdll/nsldapctrutil.h b/ldap/servers/slapd/ntperfdll/nsldapctrutil.h
new file mode 100644
index 00000000..37384b3a
--- /dev/null
+++ b/ldap/servers/slapd/ntperfdll/nsldapctrutil.h
@@ -0,0 +1,120 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+
+
+/*++ BUILD Version: 0001 // Increment this if a change has global effects
+
+Copyright (c) 1992 Microsoft Corporation
+
+Module Name:
+
+ perfutil.h
+
+Abstract:
+
+
+
+ This file supports routines used to parse and create Performance Monitor Data
+ Structures. It actually supports Performance Object types with multiple instances
+
+
+
+Revision History:
+
+--*/
+#ifndef _PERFUTIL_H_
+#define _PERFUTIL_H_
+
+// enable this define to log process heap data to the event log
+#ifdef PROBE_HEAP_USAGE
+#undef PROBE_HEAP_USAGE
+#endif
+//
+
+
+// Utility macro. This is used to reserve a DWORD multiple of bytes for Unicode strings
+// embedded in the definitional data, viz., object instance names.
+
+
+//
+
+
+#define DWORD_MULTIPLE(x) (((x+sizeof(DWORD)-1)/sizeof(DWORD))*sizeof(DWORD))
+
+
+
+// (assumes dword is 4 bytes long and pointer is a dword in size)
+
+
+#define ALIGN_ON_DWORD(x) ((VOID *)( ((DWORD) x & 0x00000003) ? ( ((DWORD) x & 0xFFFFFFFC) + 4 ) : ( (DWORD) x ) ))
+
+
+
+extern WCHAR GLOBAL_STRING[]; // Global command (get all local ctrs)
+extern WCHAR FOREIGN_STRING[]; // get data from foreign computers
+extern WCHAR COSTLY_STRING[];
+
+
+extern WCHAR NULL_STRING[];
+
+
+
+#define QUERY_GLOBAL 1
+#define QUERY_ITEMS 2
+#define QUERY_FOREIGN 3
+#define QUERY_COSTLY 4
+
+//
+
+
+// The definition of the only routine of perfutil.c, It builds part of a performance data
+// instance (PERF_INSTANCE_DEFINITION) as described in winperf.h
+
+
+//
+
+HANDLE MonOpenEventLog ();
+VOID MonCloseEventLog ();
+DWORD GetQueryType (IN LPWSTR);
+BOOL IsNumberInUnicodeList (DWORD, LPWSTR);
+
+typedef struct _LOCAL_HEAP_INFO_BLOCK {
+ DWORD AllocatedEntries;
+ DWORD AllocatedBytes;
+ DWORD FreeEntries;
+ DWORD FreeBytes;
+} LOCAL_HEAP_INFO, *PLOCAL_HEAP_INFO;
+
+
+//
+// Memory Probe macro
+//
+#ifdef PROBE_HEAP_USAGE
+
+#define HEAP_PROBE() { \
+ DWORD dwHeapStatus[5]; \
+ NTSTATUS CallStatus; \
+ dwHeapStatus[4] = __LINE__; \
+ if (!(CallStatus = memprobe (dwHeapStatus, 16L, NULL))) { \
+ REPORT_INFORMATION_DATA (VGA_HEAP_STATUS, LOG_DEBUG, \
+ &dwHeapStatus, sizeof(dwHeapStatus)); \
+ } else { \
+ REPORT_ERROR_DATA (VGA_HEAP_STATUS_ERROR, LOG_DEBUG, \
+ &CallStatus, sizeof (DWORD)); \
+ } \
+}
+
+#else
+
+#define HEAP_PROBE() ;
+
+
+
+
+
+#endif
+
+#endif //_PERFUTIL_H_
diff --git a/ldap/servers/slapd/ntperfdll/nsldapreg.ini b/ldap/servers/slapd/ntperfdll/nsldapreg.ini
new file mode 100644
index 00000000..6ca7a2c2
--- /dev/null
+++ b/ldap/servers/slapd/ntperfdll/nsldapreg.ini
@@ -0,0 +1,18 @@
+#
+# BEGIN COPYRIGHT BLOCK
+# Copyright 2001 Sun Microsystems, Inc.
+# Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+# All rights reserved.
+# END COPYRIGHT BLOCK
+#
+\Registry\Machine
+ System
+ CurrentControlSet
+ Services
+ slapd7
+ Performance
+ Close = REG_SZ CloseNSPerformanceData
+ Collect = REG_SZ CollectNSPerformanceData
+ Library = REG_SZ nsctr.dll
+ Open = REG_SZ OpenNSPerformanceData
+