diff options
author | Nathan Kinder <nkinder@redhat.com> | 2005-02-25 22:47:13 +0000 |
---|---|---|
committer | Nathan Kinder <nkinder@redhat.com> | 2005-02-25 22:47:13 +0000 |
commit | 791b7e016853125fc759ee750959e6ce121533c0 (patch) | |
tree | 5a3d5f877435bd7621b1f85902088eaaf00b0b48 /ldap/servers/slapd | |
parent | 6703f63899ba102659292134a5abccc690fecae6 (diff) | |
download | ds-791b7e016853125fc759ee750959e6ce121533c0.tar.gz ds-791b7e016853125fc759ee750959e6ce121533c0.tar.xz ds-791b7e016853125fc759ee750959e6ce121533c0.zip |
New net-snmp subagent
Diffstat (limited to 'ldap/servers/slapd')
-rw-r--r-- | ldap/servers/slapd/agtmmap.c | 67 | ||||
-rw-r--r-- | ldap/servers/slapd/agtmmap.h | 107 | ||||
-rw-r--r-- | ldap/servers/slapd/slap.h | 70 | ||||
-rw-r--r-- | ldap/servers/slapd/snmp_collator.c | 6 |
4 files changed, 158 insertions, 92 deletions
diff --git a/ldap/servers/slapd/agtmmap.c b/ldap/servers/slapd/agtmmap.c index 65fbbe4b..73536654 100644 --- a/ldap/servers/slapd/agtmmap.c +++ b/ldap/servers/slapd/agtmmap.c @@ -28,6 +28,7 @@ #include <stdio.h> #include <stdlib.h> +#include <string.h> #include <sys/stat.h> #ifndef _WIN32 @@ -328,3 +329,69 @@ agt_mclose_stats (int hdl) return EINVAL; } /* agt_mclose_stats () */ + + +int +agt_mread_stats (int hdl, struct hdr_stats_t *pHdrInfo, struct ops_stats_t *pDsOpsTbl, + struct entries_stats_t *pDsEntTbl) { + struct agt_stats_t *pfile_stats; + + if ( (hdl > 1) || (hdl < 0) ) { + return (EINVAL); + } + + if ((mmap_tbl [hdl].maptype != AGT_MAP_READ) && (mmap_tbl [hdl].maptype != AGT_MAP_RDWR)) { + return (EINVAL); /* Inavlid handle */ + } + + if (mmap_tbl [hdl].fp <= (caddr_t) 0) { + return (EFAULT); /* Something got corrupted */ + } + + pfile_stats = (struct agt_stats_t *) (mmap_tbl [hdl].fp); + + if (pHdrInfo != NULL) { + /* Header */ + pHdrInfo->restarted = pfile_stats->hdr_stats.restarted; + pHdrInfo->startTime = pfile_stats->hdr_stats.startTime; + pHdrInfo->updateTime = pfile_stats->hdr_stats.updateTime; + strncpy(pHdrInfo->dsVersion, pfile_stats->hdr_stats.dsVersion, + (sizeof(pHdrInfo->dsVersion)/sizeof(char)) - 1); + } + + if (pDsOpsTbl != NULL) { + /* Ops Table */ + pDsOpsTbl->dsAnonymousBinds = pfile_stats->ops_stats.dsAnonymousBinds; + pDsOpsTbl->dsUnAuthBinds = pfile_stats->ops_stats.dsUnAuthBinds; + pDsOpsTbl->dsSimpleAuthBinds = pfile_stats->ops_stats.dsSimpleAuthBinds; + pDsOpsTbl->dsStrongAuthBinds = pfile_stats->ops_stats.dsStrongAuthBinds; + pDsOpsTbl->dsBindSecurityErrors = pfile_stats->ops_stats.dsBindSecurityErrors; + pDsOpsTbl->dsInOps = pfile_stats->ops_stats.dsInOps; + pDsOpsTbl->dsReadOps = pfile_stats->ops_stats.dsReadOps; + pDsOpsTbl->dsCompareOps = pfile_stats->ops_stats.dsCompareOps; + pDsOpsTbl->dsAddEntryOps = pfile_stats->ops_stats.dsAddEntryOps; + pDsOpsTbl->dsRemoveEntryOps = pfile_stats->ops_stats.dsRemoveEntryOps; + pDsOpsTbl->dsModifyEntryOps = pfile_stats->ops_stats.dsModifyEntryOps; + pDsOpsTbl->dsModifyRDNOps = pfile_stats->ops_stats.dsModifyRDNOps; + pDsOpsTbl->dsListOps = pfile_stats->ops_stats.dsListOps; + pDsOpsTbl->dsSearchOps = pfile_stats->ops_stats.dsSearchOps; + pDsOpsTbl->dsOneLevelSearchOps = pfile_stats->ops_stats.dsOneLevelSearchOps; + pDsOpsTbl->dsWholeSubtreeSearchOps = pfile_stats->ops_stats.dsWholeSubtreeSearchOps; + pDsOpsTbl->dsReferrals = pfile_stats->ops_stats.dsReferrals; + pDsOpsTbl->dsChainings = pfile_stats->ops_stats.dsChainings; + pDsOpsTbl->dsSecurityErrors = pfile_stats->ops_stats.dsSecurityErrors; + pDsOpsTbl->dsErrors = pfile_stats->ops_stats.dsErrors; + } + + if (pDsEntTbl != NULL) { + /* Entries Table */ + pDsEntTbl->dsMasterEntries = pfile_stats->entries_stats.dsMasterEntries; + pDsEntTbl->dsCopyEntries = pfile_stats->entries_stats.dsCopyEntries; + pDsEntTbl->dsCacheEntries = pfile_stats->entries_stats.dsCacheEntries; + pDsEntTbl->dsCacheHits = pfile_stats->entries_stats.dsCacheHits; + pDsEntTbl->dsSlaveHits = pfile_stats->entries_stats.dsSlaveHits; + } + + return (0); +} + diff --git a/ldap/servers/slapd/agtmmap.h b/ldap/servers/slapd/agtmmap.h index 1a9cd6b7..b7c3a205 100644 --- a/ldap/servers/slapd/agtmmap.h +++ b/ldap/servers/slapd/agtmmap.h @@ -21,6 +21,7 @@ #include <sys/stat.h> #include <fcntl.h> #include <errno.h> +#include "nspr.h" #ifdef _WIN32 #include <windows.h> #define caddr_t PCHAR @@ -67,83 +68,78 @@ struct hdr_stats_t{ /* * Header */ - int hdrVersionMjr; - int hdrVersionMnr; int restarted; /* 1/0 = Yes/No */ time_t startTime; time_t updateTime; - + char dsVersion[100]; }; struct ops_stats_t{ /* * Ops Table attributes */ - int dsAnonymousBinds; - int dsUnAuthBinds; - int dsSimpleAuthBinds; - int dsStrongAuthBinds; - int dsBindSecurityErrors; - int dsInOps; - int dsReadOps; - int dsCompareOps; - int dsAddEntryOps; - int dsRemoveEntryOps; - int dsModifyEntryOps; - int dsModifyRDNOps; - int dsListOps; - int dsSearchOps; - int dsOneLevelSearchOps; - int dsWholeSubtreeSearchOps; - int dsReferrals; - int dsChainings; - int dsSecurityErrors; - int dsErrors; - int dsConnections; /* Number of currently connected clients */ - int dsConnectionSeq; /* Monotonically increasing number bumped on each new conn est */ - int dsBytesRecv; /* Count of bytes read from clients */ - int dsBytesSent; /* Count of bytes sent to clients */ - int dsEntriesReturned; /* Number of entries returned by the server */ - int dsReferralsReturned; /* Number of entries returned by the server */ + PRUint32 dsAnonymousBinds; + PRUint32 dsUnAuthBinds; + PRUint32 dsSimpleAuthBinds; + PRUint32 dsStrongAuthBinds; + PRUint32 dsBindSecurityErrors; + PRUint32 dsInOps; + PRUint32 dsReadOps; + PRUint32 dsCompareOps; + PRUint32 dsAddEntryOps; + PRUint32 dsRemoveEntryOps; + PRUint32 dsModifyEntryOps; + PRUint32 dsModifyRDNOps; + PRUint32 dsListOps; + PRUint32 dsSearchOps; + PRUint32 dsOneLevelSearchOps; + PRUint32 dsWholeSubtreeSearchOps; + PRUint32 dsReferrals; + PRUint32 dsChainings; + PRUint32 dsSecurityErrors; + PRUint32 dsErrors; + PRUint32 dsConnections; /* Number of currently connected clients */ + PRUint32 dsConnectionSeq; /* Monotonically increasing number bumped on each new conn est */ + PRUint32 dsBytesRecv; /* Count of bytes read from clients */ + PRUint32 dsBytesSent; /* Count of bytes sent to clients */ + PRUint32 dsEntriesReturned; /* Number of entries returned by the server */ + PRUint32 dsReferralsReturned; /* Number of entries returned by the server */ }; struct entries_stats_t { - /* - * Entries Table Attributes - */ - - int dsMasterEntries; - int dsCopyEntries; - int dsCacheEntries; - int dsCacheHits; - int dsSlaveHits; - + /* + * Entries Table Attributes + */ + PRUint32 dsMasterEntries; + PRUint32 dsCopyEntries; + PRUint32 dsCacheEntries; + PRUint32 dsCacheHits; + PRUint32 dsSlaveHits; }; + struct int_stats_t { - /* - * Interaction Table Attributes - */ - - int dsIntIndex; - char dsName[100]; - time_t dsTimeOfCreation; - time_t dsTimeOfLastAttempt; - time_t dsTimeOfLastSuccess; - int dsFailuresSinceLastSuccess; - int dsFailures; - int dsSuccesses; - char dsURL[100]; - + /* + * Interaction Table Attributes + */ + PRUint32 dsIntIndex; + char dsName[100]; + time_t dsTimeOfCreation; + time_t dsTimeOfLastAttempt; + time_t dsTimeOfLastSuccess; + PRUint32 dsFailuresSinceLastSuccess; + PRUint32 dsFailures; + PRUint32 dsSuccesses; + char dsURL[100]; }; + struct agt_stats_t { struct hdr_stats_t hdr_stats; struct ops_stats_t ops_stats; struct entries_stats_t entries_stats; struct int_stats_t int_stats[NUM_SNMP_INT_TBL_ROWS]; - } ; extern agt_mmap_context_t mmap_tbl[]; @@ -186,6 +182,9 @@ int agt_mopen_stats (char * statsfile, int mode, int *hdl); ****************************************************************************/ int agt_mclose_stats (int hdl); +int agt_mread_stats(int hdl, struct hdr_stats_t *, struct ops_stats_t *, + struct entries_stats_t *); + #ifdef __cplusplus } #endif diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h index 0172384b..3569a198 100644 --- a/ldap/servers/slapd/slap.h +++ b/ldap/servers/slapd/slap.h @@ -1437,54 +1437,54 @@ LDAPMod** entry2mods(Slapi_Entry *, LDAPMod **, int *, int); /* SNMP Variables */ struct snmp_ops_tbl_t{ - PRInt32 *dsAnonymousBinds; - PRInt32 *dsUnAuthBinds; - PRInt32 *dsSimpleAuthBinds; - PRInt32 *dsStrongAuthBinds; - PRInt32 *dsBindSecurityErrors; - PRInt32 *dsInOps; - PRInt32 *dsReadOps; - PRInt32 *dsCompareOps; - PRInt32 *dsAddEntryOps; - PRInt32 *dsRemoveEntryOps; - PRInt32 *dsModifyEntryOps; - PRInt32 *dsModifyRDNOps; - PRInt32 *dsListOps; - PRInt32 *dsSearchOps; - PRInt32 *dsOneLevelSearchOps; - PRInt32 *dsWholeSubtreeSearchOps; - PRInt32 *dsReferrals; - PRInt32 *dsChainings; - PRInt32 *dsSecurityErrors; - PRInt32 *dsErrors; - PRInt32 *dsConnections; /* Number of currently connected clients */ - PRInt32 *dsConnectionSeq; /* Monotonically increasing number bumped on each new conn est */ - PRInt32 *dsBytesRecv; /* Count of bytes read from clients */ - PRInt32 *dsBytesSent; /* Count of bytes sent to clients */ - PRInt32 *dsEntriesReturned; - PRInt32 *dsReferralsReturned; + PRUint32 *dsAnonymousBinds; + PRUint32 *dsUnAuthBinds; + PRUint32 *dsSimpleAuthBinds; + PRUint32 *dsStrongAuthBinds; + PRUint32 *dsBindSecurityErrors; + PRUint32 *dsInOps; + PRUint32 *dsReadOps; + PRUint32 *dsCompareOps; + PRUint32 *dsAddEntryOps; + PRUint32 *dsRemoveEntryOps; + PRUint32 *dsModifyEntryOps; + PRUint32 *dsModifyRDNOps; + PRUint32 *dsListOps; + PRUint32 *dsSearchOps; + PRUint32 *dsOneLevelSearchOps; + PRUint32 *dsWholeSubtreeSearchOps; + PRUint32 *dsReferrals; + PRUint32 *dsChainings; + PRUint32 *dsSecurityErrors; + PRUint32 *dsErrors; + PRUint32 *dsConnections; /* Number of currently connected clients */ + PRUint32 *dsConnectionSeq; /* Monotonically increasing number bumped on each new conn est */ + PRUint32 *dsBytesRecv; /* Count of bytes read from clients */ + PRUint32 *dsBytesSent; /* Count of bytes sent to clients */ + PRUint32 *dsEntriesReturned; + PRUint32 *dsReferralsReturned; }; struct snmp_entries_tbl_t{ /* entries table */ - PRInt32 *dsMasterEntries; - PRInt32 *dsCopyEntries; - PRInt32 *dsCacheEntries; - PRInt32 *dsCacheHits; - PRInt32 *dsSlaveHits; + PRUint32 *dsMasterEntries; + PRUint32 *dsCopyEntries; + PRUint32 *dsCacheEntries; + PRUint32 *dsCacheHits; + PRUint32 *dsSlaveHits; }; struct snmp_int_tbl_t{ /* interaction table */ - PRInt32 *dsIntIndex; + PRUint32 *dsIntIndex; char *dsName; time_t *dsTimeOfCreation; time_t *dsTimeOfLastAttempt; time_t *dsTimeOfLastSuccess; - PRInt32 *dsFailuresSinceLastSuccess; - PRInt32 *dsFailures; - PRInt32 *dsSuccesses; + PRUint32 *dsFailuresSinceLastSuccess; + PRUint32 *dsFailures; + PRUint32 *dsSuccesses; char *dsURL; }; diff --git a/ldap/servers/slapd/snmp_collator.c b/ldap/servers/slapd/snmp_collator.c index 320c7fe9..75e033ed 100644 --- a/ldap/servers/slapd/snmp_collator.c +++ b/ldap/servers/slapd/snmp_collator.c @@ -76,14 +76,14 @@ int snmp_collator_init(){ * Initialize the mmap structure */ memset((void *) stats, 0, sizeof(*stats)); - stats->hdr_stats.hdrVersionMjr = AGT_MJR_VERSION; - stats->hdr_stats.hdrVersionMnr = AGT_MNR_VERSION; + strncpy(stats->hdr_stats.dsVersion, SLAPD_VERSION_STR, + (sizeof(stats->hdr_stats.dsVersion)/sizeof(char)) - 1); stats->hdr_stats.restarted = 0; stats->hdr_stats.startTime = time(0); /* This is a bit off, hope it's ok */ /* point these at the mmaped data */ g_get_global_snmp_vars()->ops_tbl.dsAnonymousBinds = &(stats->ops_stats.dsAnonymousBinds); - g_get_global_snmp_vars()->ops_tbl.dsUnAuthBinds = &(stats->ops_stats.dsUnAuthBinds); + g_get_global_snmp_vars()->ops_tbl.dsUnAuthBinds = &(stats->ops_stats.dsUnAuthBinds); g_get_global_snmp_vars()->ops_tbl.dsSimpleAuthBinds = &(stats->ops_stats.dsSimpleAuthBinds); g_get_global_snmp_vars()->ops_tbl.dsStrongAuthBinds = &(stats->ops_stats.dsStrongAuthBinds); g_get_global_snmp_vars()->ops_tbl.dsBindSecurityErrors = &(stats->ops_stats.dsBindSecurityErrors); |