agtmmap.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. /** BEGIN COPYRIGHT BLOCK
  2. * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  3. * Copyright (C) 2005 Red Hat, Inc.
  4. * All rights reserved.
  5. *
  6. * License: GPL (version 3 or any later version).
  7. * See LICENSE for details.
  8. * END COPYRIGHT BLOCK **/
  9. #ifdef HAVE_CONFIG_H
  10. # include <config.h>
  11. #endif
  12. /********************************************************************
  13. *
  14. * agtmmap.h: Memory Map interface for SNMP sub-agent for
  15. * Directory Server stats (for UNIX environment).
  16. *
  17. * Revision History:
  18. * 07/22/97 Created Steve Ross
  19. *
  20. *
  21. *
  22. **********************************************************************/
  23. #include <sys/types.h>
  24. #include <sys/stat.h>
  25. #include <fcntl.h>
  26. #include <errno.h>
  27. #include "nspr.h"
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31. #define NUM_SNMP_INT_TBL_ROWS 5
  32. #define SNMP_FIELD_LENGTH 100
  33. extern int errno;
  34. #if !defined(_MAX_PATH)
  35. #define _MAX_PATH 256
  36. #endif
  37. #define AGT_STATS_EXTENSION ".stats"
  38. #define AGT_STATS_FILE "slapd" AGT_STATS_EXTENSION
  39. #define AGT_MJR_VERSION 1
  40. #define AGT_MNR_VERSION 0
  41. typedef enum { AGT_MAP_UNINIT = 0, AGT_MAP_READ, AGT_MAP_RDWR } agt_mmap_type;
  42. typedef struct
  43. {
  44. agt_mmap_type maptype;
  45. int fd;
  46. caddr_t fp;
  47. } agt_mmap_context_t;
  48. struct hdr_stats_t{
  49. /*
  50. * Header
  51. */
  52. int restarted; /* 1/0 = Yes/No */
  53. time_t startTime;
  54. time_t updateTime;
  55. char dsVersion[SNMP_FIELD_LENGTH];
  56. char dsName[SNMP_FIELD_LENGTH];
  57. char dsDescription[SNMP_FIELD_LENGTH];
  58. char dsOrganization[SNMP_FIELD_LENGTH];
  59. char dsLocation[SNMP_FIELD_LENGTH];
  60. char dsContact[SNMP_FIELD_LENGTH];
  61. };
  62. struct ops_stats_t{
  63. /*
  64. * Ops Table attributes
  65. */
  66. PRUint64 dsAnonymousBinds;
  67. PRUint64 dsUnAuthBinds;
  68. PRUint64 dsSimpleAuthBinds;
  69. PRUint64 dsStrongAuthBinds;
  70. PRUint64 dsBindSecurityErrors;
  71. PRUint64 dsInOps;
  72. PRUint64 dsReadOps;
  73. PRUint64 dsCompareOps;
  74. PRUint64 dsAddEntryOps;
  75. PRUint64 dsRemoveEntryOps;
  76. PRUint64 dsModifyEntryOps;
  77. PRUint64 dsModifyRDNOps;
  78. PRUint64 dsListOps;
  79. PRUint64 dsSearchOps;
  80. PRUint64 dsOneLevelSearchOps;
  81. PRUint64 dsWholeSubtreeSearchOps;
  82. PRUint64 dsReferrals;
  83. PRUint64 dsChainings;
  84. PRUint64 dsSecurityErrors;
  85. PRUint64 dsErrors;
  86. PRUint64 dsConnections; /* Number of currently connected clients */
  87. PRUint64 dsConnectionSeq; /* Monotonically increasing number bumped on each new conn est */
  88. PRUint64 dsMaxThreadsHit; /* Number of times a connection hit max threads */
  89. PRUint64 dsConnectionsInMaxThreads; /* current number of connections that are in max threads */
  90. PRUint64 dsBytesRecv; /* Count of bytes read from clients */
  91. PRUint64 dsBytesSent; /* Count of bytes sent to clients */
  92. PRUint64 dsEntriesReturned; /* Number of entries returned by the server */
  93. PRUint64 dsReferralsReturned; /* Number of entries returned by the server */
  94. };
  95. struct entries_stats_t
  96. {
  97. /*
  98. * Entries Table Attributes
  99. */
  100. PRUint64 dsMasterEntries;
  101. PRUint64 dsCopyEntries;
  102. PRUint64 dsCacheEntries;
  103. PRUint64 dsCacheHits;
  104. PRUint64 dsSlaveHits;
  105. };
  106. struct int_stats_t
  107. {
  108. /*
  109. * Interaction Table Attributes
  110. */
  111. PRUint32 dsIntIndex;
  112. char dsName[SNMP_FIELD_LENGTH];
  113. time_t dsTimeOfCreation;
  114. time_t dsTimeOfLastAttempt;
  115. time_t dsTimeOfLastSuccess;
  116. PRUint32 dsFailuresSinceLastSuccess;
  117. PRUint32 dsFailures;
  118. PRUint32 dsSuccesses;
  119. char dsURL[SNMP_FIELD_LENGTH];
  120. };
  121. struct agt_stats_t
  122. {
  123. struct hdr_stats_t hdr_stats;
  124. struct ops_stats_t ops_stats;
  125. struct entries_stats_t entries_stats;
  126. struct int_stats_t int_stats[NUM_SNMP_INT_TBL_ROWS];
  127. } ;
  128. extern agt_mmap_context_t mmap_tbl[];
  129. /****************************************************************************
  130. *
  131. * agt_mopen_stats () - open and Memory Map the stats file. agt_mclose_stats()
  132. * must be called prior to invoking agt_mopen_stats() again.
  133. * Inputs:
  134. * statsfile -> Name of stats file including full path or NULL.
  135. * If NULL, default ($NETSITE_ROOT/daemonstats.ldap) is assumed.
  136. * mode -> Must be one of O_RDONLY / O_RDWR.
  137. * O_RDWR creates the file if it does not exist.
  138. * Outputs:
  139. * hdl -> Opaque handle to the mapped file. Should be
  140. * passed to a subsequent agt_mupdate_stats() or
  141. * agt_mread_stats() or agt_mclose_stats() call.
  142. * Return Values:
  143. * Returns 0 on successfully doing the memmap or error
  144. * codes as defined in <errno.h>, otherwise.
  145. *
  146. ****************************************************************************/
  147. int agt_mopen_stats (char * statsfile, int mode, int *hdl);
  148. /****************************************************************************
  149. *
  150. * agt_mclose_stats () - Close the Memory Map'ed stats file.
  151. *
  152. *
  153. * Inputs:
  154. * hdl -> Opaque handle to the mapped file. Should have been
  155. * returned by an earlier call to agt_mopen_stats().
  156. *
  157. * Outputs: <NONE>
  158. *
  159. * Return Values: Returns 0 on normal completion or error codes
  160. * as defined in <errno.h>, otherwise.
  161. *
  162. ****************************************************************************/
  163. int agt_mclose_stats (int hdl);
  164. int agt_mread_stats(int hdl, struct hdr_stats_t *, struct ops_stats_t *,
  165. struct entries_stats_t *);
  166. #ifdef __cplusplus
  167. }
  168. #endif