summaryrefslogtreecommitdiffstats
path: root/plugins/check_ldap.c
diff options
context:
space:
mode:
authorKarl DeBisschop <kdebisschop@users.sourceforge.net>2003-08-03 06:05:14 (GMT)
committerKarl DeBisschop <kdebisschop@users.sourceforge.net>2003-08-03 06:05:14 (GMT)
commit3f04b037dd31251d8cd7a43f5184b5241d888cd0 (patch)
tree018e6c906d05ad87ee4ee8a93e3315c30d050a6f /plugins/check_ldap.c
parent099a9023f6b685ce071c4de2a3918a0d3edbcb28 (diff)
downloadmonitoring-plugins-3f04b037dd31251d8cd7a43f5184b5241d888cd0.tar.gz
markup for translation
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@639 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/check_ldap.c')
-rw-r--r--plugins/check_ldap.c173
1 files changed, 86 insertions, 87 deletions
diff --git a/plugins/check_ldap.c b/plugins/check_ldap.c
index af919f2..b8b3411 100644
--- a/plugins/check_ldap.c
+++ b/plugins/check_ldap.c
@@ -1,27 +1,25 @@
1/***************************************************************************** * 1/******************************************************************************
2 * CHECK_LDAP.C 2*
3 * 3* This program is free software; you can redistribute it and/or modify
4 * Program: Ldap plugin for Nagios 4* it under the terms of the GNU General Public License as published by
5 * License: GPL 5* the Free Software Foundation; either version 2 of the License, or
6 * Copyright (c) 1999 Didi Rieder (adrieder@sbox.tu-graz.ac.at) 6* (at your option) any later version.
7 * 7*
8 * Last Modified: $Date$ 8* This program is distributed in the hope that it will be useful,
9 * 9* but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * Command line: check_ldap -H <host> -b <base_dn> -p <port> -w <warn_time> -w <crit_time> 10* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * 11* GNU General Public License for more details.
12 * Description: 12*
13 * 13* You should have received a copy of the GNU General Public License
14 * This plugin is for testing a ldap server. 14* along with this program; if not, write to the Free Software
15 * 15* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 * Modifications: 16*
17 * 17******************************************************************************/
18 * 08-25-1999 Ethan Galstad (nagios@nagios.org)
19 * Modified to use common plugin include file
20 *
21 *****************************************************************************/
22 18
23const char *progname = "check_ldap"; 19const char *progname = "check_ldap";
24const char *revision = "$Revision$"; 20const char *revision = "$Revision$";
21const char *copyright = "2000-2003";
22const char *email = "nagiosplug-devel@lists.sourceforge.net";
25 23
26#include "config.h" 24#include "config.h"
27#include "common.h" 25#include "common.h"
@@ -39,10 +37,61 @@ enum {
39 DEFAULT_PORT = 389 37 DEFAULT_PORT = 389
40}; 38};
41 39
40void
41print_usage ()
42{
43 printf (_("\
44Usage: %s -H <host> -b <base_dn> [-p <port>] [-a <attr>] [-D <binddn>]\n\
45 [-P <password>] [-w <warn_time>] [-c <crit_time>] [-t timeout]%s\n\
46(Note: all times are in seconds.)\n"),
47 progname, (HAVE_LDAP_SET_OPTION ? "[-2|-3] [-4|-6]" : ""));
48 printf (_(UT_HLP_VRS), progname, progname);
49}
50
51void
52print_help ()
53{
54 char *myport;
55 asprintf (&myport, "%d", DEFAULT_PORT);
56
57 print_revision (progname, revision);
58
59 printf (_("Copyright (c) 1999 Didi Rieder (adrieder@sbox.tu-graz.ac.at)\n"));
60 printf (_(COPYRIGHT), copyright, email);
61
62 print_usage ();
63
64 printf (_(UT_HELP_VRSN));
65
66 printf (_(UT_HOST_PORT), 'p', myport);
67
68 printf (_(UT_IPv46));
69
70 printf (_("\
71 -a [--attr]\n\
72 ldap attribute to search (default: \"(objectclass=*)\"\n\
73 -b [--base]\n\
74 ldap base (eg. ou=my unit, o=my org, c=at)\n\
75 -D [--bind]\n\
76 ldap bind DN (if required)\n\
77 -P [--pass]\n\
78 ldap password (if required)\n"));
79
80#ifdef HAVE_LDAP_SET_OPTION
81 printf (_("\
82 -2 [--ver2]\n\
83 use ldap protocol version 2\n\
84 -3 [--ver3]\n\
85 use ldap protocol version 3\n\
86 (default protocol version: %d)\n"),
87 DEFAULT_PROTOCOL);
88#endif
89
90 printf (_(UT_WARN_CRIT));
91}
92
42int process_arguments (int, char **); 93int process_arguments (int, char **);
43int validate_arguments (void); 94int validate_arguments (void);
44void print_help (void);
45void print_usage (void);
46 95
47char ld_defattr[] = "(objectclass=*)"; 96char ld_defattr[] = "(objectclass=*)";
48char *ld_attr = ld_defattr; 97char *ld_attr = ld_defattr;
@@ -68,7 +117,7 @@ main (int argc, char *argv[])
68 time_t time0, time1; 117 time_t time0, time1;
69 118
70 if (process_arguments (argc, argv) == ERROR) 119 if (process_arguments (argc, argv) == ERROR)
71 usage ("check_ldap: could not parse arguments\n"); 120 usage (_("check_ldap: could not parse arguments\n"));
72 121
73 /* initialize alarm signal handling */ 122 /* initialize alarm signal handling */
74 signal (SIGALRM, socket_timeout_alarm_handler); 123 signal (SIGALRM, socket_timeout_alarm_handler);
@@ -82,7 +131,7 @@ main (int argc, char *argv[])
82 /* initialize ldap */ 131 /* initialize ldap */
83 if (!(ld = ldap_open (ld_host, ld_port))) { 132 if (!(ld = ldap_open (ld_host, ld_port))) {
84 /*ldap_perror(ld, "ldap_open"); */ 133 /*ldap_perror(ld, "ldap_open"); */
85 printf ("Could not connect to the server at port %i\n", ld_port); 134 printf (_("Could not connect to the server at port %i\n"), ld_port);
86 return STATE_CRITICAL; 135 return STATE_CRITICAL;
87 } 136 }
88 137
@@ -90,7 +139,7 @@ main (int argc, char *argv[])
90 /* set ldap options */ 139 /* set ldap options */
91 if (ldap_set_option (ld, LDAP_OPT_PROTOCOL_VERSION, &ld_protocol) != 140 if (ldap_set_option (ld, LDAP_OPT_PROTOCOL_VERSION, &ld_protocol) !=
92 LDAP_OPT_SUCCESS ) { 141 LDAP_OPT_SUCCESS ) {
93 printf("Could not set protocol version %d\n", ld_protocol); 142 printf(_("Could not set protocol version %d\n"), ld_protocol);
94 return STATE_CRITICAL; 143 return STATE_CRITICAL;
95 } 144 }
96#endif 145#endif
@@ -98,7 +147,7 @@ main (int argc, char *argv[])
98 if (ldap_bind_s (ld, ld_binddn, ld_passwd, LDAP_AUTH_SIMPLE) != 147 if (ldap_bind_s (ld, ld_binddn, ld_passwd, LDAP_AUTH_SIMPLE) !=
99 LDAP_SUCCESS) { 148 LDAP_SUCCESS) {
100 /*ldap_perror(ld, "ldap_bind"); */ 149 /*ldap_perror(ld, "ldap_bind"); */
101 printf ("Could not bind to the ldap-server\n"); 150 printf (_("Could not bind to the ldap-server\n"));
102 return STATE_CRITICAL; 151 return STATE_CRITICAL;
103 } 152 }
104 153
@@ -106,7 +155,7 @@ main (int argc, char *argv[])
106 if (ldap_search_s (ld, ld_base, LDAP_SCOPE_BASE, ld_attr, NULL, 0, &result) 155 if (ldap_search_s (ld, ld_base, LDAP_SCOPE_BASE, ld_attr, NULL, 0, &result)
107 != LDAP_SUCCESS) { 156 != LDAP_SUCCESS) {
108 /*ldap_perror(ld, "ldap_search"); */ 157 /*ldap_perror(ld, "ldap_search"); */
109 printf ("Could not search/find objectclasses in %s\n", ld_base); 158 printf (_("Could not search/find objectclasses in %s\n"), ld_base);
110 return STATE_CRITICAL; 159 return STATE_CRITICAL;
111 } 160 }
112 161
@@ -123,17 +172,17 @@ main (int argc, char *argv[])
123 t_diff = time1 - time0; 172 t_diff = time1 - time0;
124 173
125 if (crit_time!=UNDEFINED && t_diff>=crit_time) { 174 if (crit_time!=UNDEFINED && t_diff>=crit_time) {
126 printf ("LDAP CRITICAL - %i seconds response time\n", t_diff); 175 printf (_("LDAP CRITICAL - %i seconds response time\n"), t_diff);
127 return STATE_CRITICAL; 176 return STATE_CRITICAL;
128 } 177 }
129 178
130 if (warn_time!=UNDEFINED && t_diff>=warn_time) { 179 if (warn_time!=UNDEFINED && t_diff>=warn_time) {
131 printf ("LDAP WARNING - %i seconds response time\n", t_diff); 180 printf (_("LDAP WARNING - %i seconds response time\n"), t_diff);
132 return STATE_WARNING; 181 return STATE_WARNING;
133 } 182 }
134 183
135 /* print out the result */ 184 /* print out the result */
136 printf ("LDAP OK - %i seconds response time\n", t_diff); 185 printf (_("LDAP OK - %i seconds response time\n"), t_diff);
137 186
138 return STATE_OK; 187 return STATE_OK;
139} 188}
@@ -190,7 +239,7 @@ process_arguments (int argc, char **argv)
190 exit (STATE_OK); 239 exit (STATE_OK);
191 case 't': /* timeout period */ 240 case 't': /* timeout period */
192 if (!is_intnonneg (optarg)) 241 if (!is_intnonneg (optarg))
193 usage2 ("timeout interval must be a positive integer", optarg); 242 usage2 (_("timeout interval must be a positive integer"), optarg);
194 socket_timeout = atoi (optarg); 243 socket_timeout = atoi (optarg);
195 break; 244 break;
196 case 'H': 245 case 'H':
@@ -232,11 +281,11 @@ process_arguments (int argc, char **argv)
232#ifdef USE_IPV6 281#ifdef USE_IPV6
233 address_family = AF_INET6; 282 address_family = AF_INET6;
234#else 283#else
235 usage ("IPv6 support not available\n"); 284 usage (_("IPv6 support not available\n"));
236#endif 285#endif
237 break; 286 break;
238 default: 287 default:
239 usage ("check_ldap: could not parse unknown arguments\n"); 288 usage (_("check_ldap: could not parse unknown arguments\n"));
240 break; 289 break;
241 } 290 }
242 } 291 }
@@ -256,61 +305,11 @@ int
256validate_arguments () 305validate_arguments ()
257{ 306{
258 if (strlen(ld_host) == 0) 307 if (strlen(ld_host) == 0)
259 usage ("please specify the host name\n"); 308 usage (_("please specify the host name\n"));
260 309
261 if (strlen(ld_base) == 0) 310 if (strlen(ld_base) == 0)
262 usage ("please specify the LDAP base\n"); 311 usage (_("please specify the LDAP base\n"));
263
264 else
265 return OK;
266
267}
268
269
270
271/* function print_help */
272void
273print_help ()
274{
275 print_revision (progname, revision);
276 printf
277 ("Copyright (c) 1999 Didi Rieder (adrieder@sbox.tu-graz.ac.at)\n"
278 "License: GPL\n" "\n");
279 print_usage ();
280 printf
281 ("\n"
282 "Options:\n"
283 "\t-H [--host] ... host\n"
284 "\t-a [--attr] ... ldap attribute to search (default: \"(objectclass=*)\"\n"
285 "\t-b [--base] ... ldap base (eg. ou=my unit, o=my org, c=at)\n"
286 "\t-D [--bind] ... ldap bind DN (if required)\n"
287 "\t-P [--pass] ... ldap password (if required)\n"
288 "\t-p [--port] ... ldap port (default: %d)\n"
289#ifdef HAVE_LDAP_SET_OPTION
290 "\t-2 [--ver2] ... use ldap protocol version 2\n"
291 "\t-3 [--ver3] ... use ldap protocol version 3\n"
292 "\t-4 [--use-ipv4] ... use IPv4 protocol\n"
293 "\t-6 [--use-ipv6] ... use IPv6 protocol\n"
294 "\t\t(default protocol version: %d)\n"
295#endif
296 "\t-w [--warn] ... time in secs. - if the exceeds <warn> the STATE_WARNING will be returned\n"
297 "\t-c [--crit] ... time in secs. - if the exceeds <crit> the STATE_CRITICAL will be returned\n"
298 "\n", DEFAULT_PORT
299#ifdef HAVE_LDAP_SET_OPTION
300 , DEFAULT_PROTOCOL
301#endif
302 );
303}
304 312
313 return OK;
305 314
306void
307print_usage ()
308{
309 printf
310 ("Usage: %s -H <host> -b <base_dn> [-p <port>] [-a <attr>] [-D <binddn>]\n"
311 " [-P <password>] [-w <warn_time>] [-c <crit_time>] [-t timeout]\n"
312#ifdef HAVE_LDAP_SET_OPTION
313 " [-2|-3] [-4|-6]\n"
314#endif
315 "(Note: all times are in seconds.)\n", progname);
316} 315}