ldap-agent.h 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. /* --- BEGIN COPYRIGHT BLOCK ---
  2. * This Program is free software; you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation; version 2 of the License.
  5. *
  6. * This Program is distributed in the hope that it will be useful, but WITHOUT
  7. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  8. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  9. *
  10. * You should have received a copy of the GNU General Public License along with
  11. * this Program; if not, write to the Free Software Foundation, Inc., 59 Temple
  12. * Place, Suite 330, Boston, MA 02111-1307 USA.
  13. *
  14. * In addition, as a special exception, Red Hat, Inc. gives You the additional
  15. * right to link the code of this Program with code not covered under the GNU
  16. * General Public License ("Non-GPL Code") and to distribute linked combinations
  17. * including the two, subject to the limitations in this paragraph. Non-GPL Code
  18. * permitted under this exception must only link to the code of this Program
  19. * through those well defined interfaces identified in the file named EXCEPTION
  20. * found in the source code files (the "Approved Interfaces"). The files of
  21. * Non-GPL Code may instantiate templates or use macros or inline functions from
  22. * the Approved Interfaces without causing the resulting work to be covered by
  23. * the GNU General Public License. Only Red Hat, Inc. may make changes or
  24. * additions to the list of Approved Interfaces. You must obey the GNU General
  25. * Public License in all respects for all of the Program code and other code used
  26. * in conjunction with the Program except the Non-GPL Code covered by this
  27. * exception. If you modify this file, you may extend this exception to your
  28. * version of the file, but you are not obligated to do so. If you do not wish to
  29. * provide this exception without modification, you must delete this exception
  30. * statement from your version and license this file solely under the GPL without
  31. * exception.
  32. *
  33. *
  34. * Copyright (C) 2005 Red Hat, Inc.
  35. * All rights reserved.
  36. * --- END COPYRIGHT BLOCK --- */
  37. #ifdef HAVE_CONFIG_H
  38. # include <config.h>
  39. #endif
  40. #ifndef DSOPSTABLE_H
  41. #define DSOPSTABLE_H
  42. #ifdef __cplusplus
  43. extern "C" {
  44. #endif
  45. /* net-snmp-config.h defines
  46. all of these unconditionally - so we undefine
  47. them here to make the compiler warnings shut up
  48. hopefully we don't need the real versions
  49. of these, but then with no warnings the compiler
  50. will just silently redefine them to the wrong
  51. ones anyway
  52. Then undefine them after the include so that
  53. our own local defines will take effect
  54. */
  55. #undef PACKAGE_BUGREPORT
  56. #undef PACKAGE_NAME
  57. #undef PACKAGE_STRING
  58. #undef PACKAGE_TARNAME
  59. #undef PACKAGE_VERSION
  60. #include <net-snmp/net-snmp-config.h>
  61. #undef PACKAGE_BUGREPORT
  62. #undef PACKAGE_NAME
  63. #undef PACKAGE_STRING
  64. #undef PACKAGE_TARNAME
  65. #undef PACKAGE_VERSION
  66. #include <net-snmp/net-snmp-includes.h>
  67. #include <net-snmp/agent/net-snmp-agent-includes.h>
  68. #include <net-snmp/library/snmp_assert.h>
  69. #include <net-snmp/library/container.h>
  70. #include <net-snmp/agent/table_array.h>
  71. #include "../slapd/agtmmap.h"
  72. #include <semaphore.h>
  73. #include <fcntl.h>
  74. #ifdef HPUX
  75. /* HP-UX doesn't define SEM_FAILED like other platforms, so
  76. * we define it ourselves. We make this define HP-UX specific
  77. * since sem_open() doesn't seem to return the same value on
  78. * all platforms in a failure case (it's 1 on some platforms,
  79. * and 0 on others). */
  80. #define SEM_FAILED ((sem_t *)(-1))
  81. #endif
  82. #define MAXLINE 4096
  83. #define CACHE_REFRESH_INTERVAL 15
  84. #define UPDATE_THRESHOLD 20
  85. #define SNMP_NUM_SEM_WAITS 10
  86. #define LDAP_AGENT_PIDFILE ".ldap-agent.pid"
  87. #define LDAP_AGENT_LOGFILE "ldap-agent.log"
  88. /*************************************************************
  89. * Trap value defines
  90. */
  91. #define SERVER_UP 6002
  92. #define SERVER_DOWN 6001
  93. #define STATE_UNKNOWN 0
  94. /*************************************************************
  95. * Structures
  96. */
  97. typedef struct server_instance_s {
  98. PRUint32 port;
  99. int server_state;
  100. char *stats_file;
  101. char *stats_sem_name;
  102. char *dse_ldif;
  103. struct server_instance_s *next;
  104. } server_instance;
  105. typedef struct stats_table_context_s {
  106. netsnmp_index index;
  107. struct hdr_stats_t hdr_tbl;
  108. struct ops_stats_t ops_tbl;
  109. struct entries_stats_t entries_tbl;
  110. server_instance *entity_tbl;
  111. } stats_table_context;
  112. /*************************************************************
  113. * Function Declarations
  114. */
  115. void exit_usage();
  116. void load_config(char *);
  117. void init_ldap_agent(void);
  118. void initialize_stats_table(void);
  119. int load_stats_table(netsnmp_cache *, void *);
  120. void free_stats_table(netsnmp_cache *, void *);
  121. stats_table_context *stats_table_create_row(unsigned long);
  122. stats_table_context *stats_table_find_row(unsigned long);
  123. int dsOpsTable_get_value(netsnmp_request_info *,
  124. netsnmp_index *,
  125. netsnmp_table_request_info *);
  126. int dsEntriesTable_get_value(netsnmp_request_info *,
  127. netsnmp_index *,
  128. netsnmp_table_request_info *);
  129. int dsEntityTable_get_value(netsnmp_request_info *,
  130. netsnmp_index *,
  131. netsnmp_table_request_info *);
  132. int send_DirectoryServerDown_trap(server_instance *);
  133. int send_DirectoryServerStart_trap(server_instance *);
  134. /*************************************************************
  135. * Oid Declarations
  136. */
  137. extern oid dsOpsTable_oid[];
  138. extern size_t dsOpsTable_oid_len;
  139. extern oid dsEntriesTable_oid[];
  140. extern size_t dsEntriesTable_oid_len;
  141. extern oid dsEntityTable_oid[];
  142. extern size_t dsEntityTable_oid_len;
  143. extern oid snmptrap_oid[];
  144. extern size_t snmptrap_oid_len;
  145. #define enterprise_OID 1,3,6,1,4,1,2312
  146. #define dsOpsTable_TABLE_OID enterprise_OID,6,1
  147. #define dsEntriesTable_TABLE_OID enterprise_OID,6,2
  148. #define dsEntityTable_TABLE_OID enterprise_OID,6,5
  149. #define snmptrap_OID 1,3,6,1,6,3,1,1,4,1,0
  150. #define DirectoryServerDown_OID enterprise_OID,0,6001
  151. #define DirectoryServerStart_OID enterprise_OID,0,6002
  152. /*************************************************************
  153. * dsOpsTable column defines
  154. */
  155. #define COLUMN_DSANONYMOUSBINDS 1
  156. #define COLUMN_DSUNAUTHBINDS 2
  157. #define COLUMN_DSSIMPLEAUTHBINDS 3
  158. #define COLUMN_DSSTRONGAUTHBINDS 4
  159. #define COLUMN_DSBINDSECURITYERRORS 5
  160. #define COLUMN_DSINOPS 6
  161. #define COLUMN_DSREADOPS 7
  162. #define COLUMN_DSCOMPAREOPS 8
  163. #define COLUMN_DSADDENTRYOPS 9
  164. #define COLUMN_DSREMOVEENTRYOPS 10
  165. #define COLUMN_DSMODIFYENTRYOPS 11
  166. #define COLUMN_DSMODIFYRDNOPS 12
  167. #define COLUMN_DSLISTOPS 13
  168. #define COLUMN_DSSEARCHOPS 14
  169. #define COLUMN_DSONELEVELSEARCHOPS 15
  170. #define COLUMN_DSWHOLESUBTREESEARCHOPS 16
  171. #define COLUMN_DSREFERRALS 17
  172. #define COLUMN_DSCHAININGS 18
  173. #define COLUMN_DSSECURITYERRORS 19
  174. #define COLUMN_DSERRORS 20
  175. #define dsOpsTable_COL_MIN 1
  176. #define dsOpsTable_COL_MAX 20
  177. /*************************************************************
  178. * dsEntriesTable column defines
  179. */
  180. #define COLUMN_DSMASTERENTRIES 1
  181. #define COLUMN_DSCOPYENTRIES 2
  182. #define COLUMN_DSCACHEENTRIES 3
  183. #define COLUMN_DSCACHEHITS 4
  184. #define COLUMN_DSSLAVEHITS 5
  185. #define dsEntriesTable_COL_MIN 1
  186. #define dsEntriesTable_COL_MAX 5
  187. /*************************************************************
  188. * dsEntityTable column defines
  189. */
  190. #define COLUMN_DSENTITYDESCR 1
  191. #define COLUMN_DSENTITYVERS 2
  192. #define COLUMN_DSENTITYORG 3
  193. #define COLUMN_DSENTITYLOCATION 4
  194. #define COLUMN_DSENTITYCONTACT 5
  195. #define COLUMN_DSENTITYNAME 6
  196. #define dsEntityTable_COL_MIN 1
  197. #define dsEntityTable_COL_MAX 6
  198. #ifdef __cplusplus
  199. }
  200. #endif
  201. #endif /** DSOPSTABLE_H */