ldap-agent.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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. #define MAXLINE 4096
  73. #define CACHE_REFRESH_INTERVAL 15
  74. #define UPDATE_THRESHOLD 20
  75. #define LDAP_AGENT_PIDFILE ".ldap-agent.pid"
  76. #define LDAP_AGENT_LOGFILE "ldap-agent.log"
  77. /*************************************************************
  78. * Trap value defines
  79. */
  80. #define SERVER_UP 6002
  81. #define SERVER_DOWN 6001
  82. #define STATE_UNKNOWN 0
  83. /*************************************************************
  84. * Structures
  85. */
  86. typedef struct server_instance_s {
  87. PRUint32 port;
  88. int server_state;
  89. char *stats_file;
  90. char *dse_ldif;
  91. struct server_instance_s *next;
  92. } server_instance;
  93. typedef struct stats_table_context_s {
  94. netsnmp_index index;
  95. struct hdr_stats_t hdr_tbl;
  96. struct ops_stats_t ops_tbl;
  97. struct entries_stats_t entries_tbl;
  98. server_instance *entity_tbl;
  99. } stats_table_context;
  100. /*************************************************************
  101. * Function Declarations
  102. */
  103. void exit_usage();
  104. void load_config(char *);
  105. void init_ldap_agent(void);
  106. void initialize_stats_table(void);
  107. int load_stats_table(netsnmp_cache *, void *);
  108. void free_stats_table(netsnmp_cache *, void *);
  109. stats_table_context *stats_table_create_row(unsigned long);
  110. stats_table_context *stats_table_find_row(unsigned long);
  111. int dsOpsTable_get_value(netsnmp_request_info *,
  112. netsnmp_index *,
  113. netsnmp_table_request_info *);
  114. int dsEntriesTable_get_value(netsnmp_request_info *,
  115. netsnmp_index *,
  116. netsnmp_table_request_info *);
  117. int dsEntityTable_get_value(netsnmp_request_info *,
  118. netsnmp_index *,
  119. netsnmp_table_request_info *);
  120. int send_DirectoryServerDown_trap(server_instance *);
  121. int send_DirectoryServerStart_trap(server_instance *);
  122. /*************************************************************
  123. * Oid Declarations
  124. */
  125. extern oid dsOpsTable_oid[];
  126. extern size_t dsOpsTable_oid_len;
  127. extern oid dsEntriesTable_oid[];
  128. extern size_t dsEntriesTable_oid_len;
  129. extern oid dsEntityTable_oid[];
  130. extern size_t dsEntityTable_oid_len;
  131. extern oid snmptrap_oid[];
  132. extern size_t snmptrap_oid_len;
  133. #define enterprise_OID 1,3,6,1,4,1,2312
  134. #define dsOpsTable_TABLE_OID enterprise_OID,6,1
  135. #define dsEntriesTable_TABLE_OID enterprise_OID,6,2
  136. #define dsEntityTable_TABLE_OID enterprise_OID,6,5
  137. #define snmptrap_OID 1,3,6,1,6,3,1,1,4,1,0
  138. #define DirectoryServerDown_OID enterprise_OID,0,6001
  139. #define DirectoryServerStart_OID enterprise_OID,0,6002
  140. /*************************************************************
  141. * dsOpsTable column defines
  142. */
  143. #define COLUMN_DSANONYMOUSBINDS 1
  144. #define COLUMN_DSUNAUTHBINDS 2
  145. #define COLUMN_DSSIMPLEAUTHBINDS 3
  146. #define COLUMN_DSSTRONGAUTHBINDS 4
  147. #define COLUMN_DSBINDSECURITYERRORS 5
  148. #define COLUMN_DSINOPS 6
  149. #define COLUMN_DSREADOPS 7
  150. #define COLUMN_DSCOMPAREOPS 8
  151. #define COLUMN_DSADDENTRYOPS 9
  152. #define COLUMN_DSREMOVEENTRYOPS 10
  153. #define COLUMN_DSMODIFYENTRYOPS 11
  154. #define COLUMN_DSMODIFYRDNOPS 12
  155. #define COLUMN_DSLISTOPS 13
  156. #define COLUMN_DSSEARCHOPS 14
  157. #define COLUMN_DSONELEVELSEARCHOPS 15
  158. #define COLUMN_DSWHOLESUBTREESEARCHOPS 16
  159. #define COLUMN_DSREFERRALS 17
  160. #define COLUMN_DSCHAININGS 18
  161. #define COLUMN_DSSECURITYERRORS 19
  162. #define COLUMN_DSERRORS 20
  163. #define dsOpsTable_COL_MIN 1
  164. #define dsOpsTable_COL_MAX 20
  165. /*************************************************************
  166. * dsEntriesTable column defines
  167. */
  168. #define COLUMN_DSMASTERENTRIES 1
  169. #define COLUMN_DSCOPYENTRIES 2
  170. #define COLUMN_DSCACHEENTRIES 3
  171. #define COLUMN_DSCACHEHITS 4
  172. #define COLUMN_DSSLAVEHITS 5
  173. #define dsEntriesTable_COL_MIN 1
  174. #define dsEntriesTable_COL_MAX 5
  175. /*************************************************************
  176. * dsEntityTable column defines
  177. */
  178. #define COLUMN_DSENTITYDESCR 1
  179. #define COLUMN_DSENTITYVERS 2
  180. #define COLUMN_DSENTITYORG 3
  181. #define COLUMN_DSENTITYLOCATION 4
  182. #define COLUMN_DSENTITYCONTACT 5
  183. #define COLUMN_DSENTITYNAME 6
  184. #define dsEntityTable_COL_MIN 1
  185. #define dsEntityTable_COL_MAX 6
  186. #ifdef __cplusplus
  187. }
  188. #endif
  189. #endif /** DSOPSTABLE_H */