summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorJeremy T. Bouse <undrgrid@users.sourceforge.net>2003-06-29 19:54:50 +0000
committerJeremy T. Bouse <undrgrid@users.sourceforge.net>2003-06-29 19:54:50 +0000
commit84a71d088a6eb74d5e9d31fc6769e79b9e42f5b0 (patch)
tree507d38e8afc9e0c0826423a22c664c3f8bdac9b9 /plugins
parent58f124b80330917c003e24b35748d4ef7cb38056 (diff)
downloadmonitoring-plugins-84a71d088a6eb74d5e9d31fc6769e79b9e42f5b0.tar.gz
Included patch for check_ldap from Patch #753621 by Ziya Suzen
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@571 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_ldap.c42
1 files changed, 40 insertions, 2 deletions
diff --git a/plugins/check_ldap.c b/plugins/check_ldap.c
index 5b983f4b..8eb89569 100644
--- a/plugins/check_ldap.c
+++ b/plugins/check_ldap.c
@@ -33,6 +33,9 @@ const char *revision = "$Revision$";
33 33
34enum { 34enum {
35 UNDEFINED = -1, 35 UNDEFINED = -1,
36#ifdef HAVE_LDAP_SET_OPTION
37 DEFAULT_PROTOCOL = 2,
38#endif
36 DEFAULT_PORT = 389 39 DEFAULT_PORT = 389
37}; 40};
38 41
@@ -48,6 +51,9 @@ char *ld_base = "";
48char *ld_passwd = NULL; 51char *ld_passwd = NULL;
49char *ld_binddn = NULL; 52char *ld_binddn = NULL;
50unsigned int ld_port = DEFAULT_PORT; 53unsigned int ld_port = DEFAULT_PORT;
54#ifdef HAVE_LDAP_SET_OPTION
55int ld_protocol = DEFAULT_PROTOCOL;
56#endif
51int warn_time = UNDEFINED; 57int warn_time = UNDEFINED;
52int crit_time = UNDEFINED; 58int crit_time = UNDEFINED;
53 59
@@ -80,6 +86,14 @@ main (int argc, char *argv[])
80 return STATE_CRITICAL; 86 return STATE_CRITICAL;
81 } 87 }
82 88
89#ifdef HAVE_LDAP_SET_OPTION
90 /* set ldap options */
91 if (ldap_set_option (ld, LDAP_OPT_PROTOCOL_VERSION, &ld_protocol) !=
92 LDAP_OPT_SUCCESS ) {
93 printf("Could not set protocol version %d\n", ld_protocol);
94 return STATE_CRITICAL;
95 }
96#endif
83 /* bind to the ldap server */ 97 /* bind to the ldap server */
84 if (ldap_bind_s (ld, ld_binddn, ld_passwd, LDAP_AUTH_SIMPLE) != 98 if (ldap_bind_s (ld, ld_binddn, ld_passwd, LDAP_AUTH_SIMPLE) !=
85 LDAP_SUCCESS) { 99 LDAP_SUCCESS) {
@@ -141,6 +155,10 @@ process_arguments (int argc, char **argv)
141 {"attr", required_argument, 0, 'a'}, 155 {"attr", required_argument, 0, 'a'},
142 {"bind", required_argument, 0, 'D'}, 156 {"bind", required_argument, 0, 'D'},
143 {"pass", required_argument, 0, 'P'}, 157 {"pass", required_argument, 0, 'P'},
158#ifdef HAVE_LDAP_SET_OPTION
159 {"ver2", no_argument, 0, '2'},
160 {"ver3", no_argument, 0, '3'},
161#endif
144 {"port", required_argument, 0, 'p'}, 162 {"port", required_argument, 0, 'p'},
145 {"warn", required_argument, 0, 'w'}, 163 {"warn", required_argument, 0, 'w'},
146 {"crit", required_argument, 0, 'c'}, 164 {"crit", required_argument, 0, 'c'},
@@ -156,7 +174,7 @@ process_arguments (int argc, char **argv)
156 } 174 }
157 175
158 while (1) { 176 while (1) {
159 c = getopt_long (argc, argv, "hVt:c:w:H:b:p:a:D:P:", longopts, &option_index); 177 c = getopt_long (argc, argv, "hV23t:c:w:H:b:p:a:D:P:", longopts, &option_index);
160 178
161 if (c == -1 || c == EOF) 179 if (c == -1 || c == EOF)
162 break; 180 break;
@@ -197,6 +215,14 @@ process_arguments (int argc, char **argv)
197 case 'c': 215 case 'c':
198 crit_time = atoi (optarg); 216 crit_time = atoi (optarg);
199 break; 217 break;
218#ifdef HAVE_LDAP_SET_OPTION
219 case '2':
220 ld_protocol = 2;
221 break;
222 case '3':
223 ld_protocol = 3;
224 break;
225#endif
200 default: 226 default:
201 usage ("check_ldap: could not parse unknown arguments\n"); 227 usage ("check_ldap: could not parse unknown arguments\n");
202 break; 228 break;
@@ -244,9 +270,18 @@ print_help ()
244 "\t-D [--bind] ... ldap bind DN (if required)\n" 270 "\t-D [--bind] ... ldap bind DN (if required)\n"
245 "\t-P [--pass] ... ldap password (if required)\n" 271 "\t-P [--pass] ... ldap password (if required)\n"
246 "\t-p [--port] ... ldap port (default: %d)\n" 272 "\t-p [--port] ... ldap port (default: %d)\n"
273#ifdef HAVE_LDAP_SET_OPTION
274 "\t-2 [--ver2] ... use ldap porotocol version 2\n"
275 "\t-3 [--ver3] ... use ldap porotocol version 3\n"
276 "\t\t(default protocol version: %d)\n"
277#endif
247 "\t-w [--warn] ... time in secs. - if the exceeds <warn> the STATE_WARNING will be returned\n" 278 "\t-w [--warn] ... time in secs. - if the exceeds <warn> the STATE_WARNING will be returned\n"
248 "\t-c [--crit] ... time in secs. - if the exceeds <crit> the STATE_CRITICAL will be returned\n" 279 "\t-c [--crit] ... time in secs. - if the exceeds <crit> the STATE_CRITICAL will be returned\n"
249 "\n", DEFAULT_PORT); 280 "\n", DEFAULT_PORT
281#ifdef HAVE_LDAP_SET_OPTION
282 , DEFAULT_PROTOCOL
283#endif
284 );
250} 285}
251 286
252 287
@@ -256,5 +291,8 @@ print_usage ()
256 printf 291 printf
257 ("Usage: %s -H <host> -b <base_dn> [-p <port>] [-a <attr>] [-D <binddn>]\n" 292 ("Usage: %s -H <host> -b <base_dn> [-p <port>] [-a <attr>] [-D <binddn>]\n"
258 " [-P <password>] [-w <warn_time>] [-c <crit_time>] [-t timeout]\n" 293 " [-P <password>] [-w <warn_time>] [-c <crit_time>] [-t timeout]\n"
294#ifdef HAVE_LDAP_SET_OPTION
295 " [-2|-3]\n"
296#endif
259 "(Note: all times are in seconds.)\n", progname); 297 "(Note: all times are in seconds.)\n", progname);
260} 298}