summaryrefslogtreecommitdiffstats
path: root/plugins/check_mysql.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/check_mysql.c')
-rw-r--r--plugins/check_mysql.c108
1 files changed, 51 insertions, 57 deletions
diff --git a/plugins/check_mysql.c b/plugins/check_mysql.c
index 3074814..a18397d 100644
--- a/plugins/check_mysql.c
+++ b/plugins/check_mysql.c
@@ -15,25 +15,66 @@
15******************************************************************************/ 15******************************************************************************/
16 16
17const char *progname = "check_mysql"; 17const char *progname = "check_mysql";
18#define REVISION "$Revision$" 18const char *revision = "$Revision$";
19#define COPYRIGHT "1999-2002" 19const char *copyright = "1999-2002";
20const char *email = "nagiosplug-devel@lists.sourceforge.net";
20 21
21#include "common.h" 22#include "common.h"
22#include "utils.h" 23#include "utils.h"
23 24#include "netutils.h"
24#include <mysql/mysql.h> 25#include <mysql/mysql.h>
25#include <mysql/errmsg.h> 26#include <mysql/errmsg.h>
26 27
28unsigned int db_port = MYSQL_PORT;
29
30void
31print_usage (void)
32{
33 printf (_("\
34Usage: %s [-d database] [-H host] [-P port] [-u user] [-p password]\n"),
35 progname);
36 printf (_(UT_HLP_VRS), progname, progname);
37}
38
39void
40print_help (void)
41{
42 print_revision (progname, revision);
43
44 printf (_(COPYRIGHT), copyright, email);
45
46 printf (_("This program tests connections to a mysql server\n"));
47
48 print_usage ();
49
50 printf (_(UT_HELP_VRSN));
51
52 printf (_(UT_HOST_PORT), 'P', atoi(MYSQL_PORT));
53
54 printf (_("\
55 -d, --database=STRING\n\
56 Check database with indicated name\n\
57 -u, --username=STRING\n\
58 Connect using the indicated username\n\
59 -p, --password=STRING\n\
60 Use the indicated password to authenticate the connection\n\
61 ==> IMPORTANT: THIS FORM OF AUTHENTICATION IS NOT SECURE!!! <==\n\
62 Your clear-text password will be visible as a process table entry\n"));
63
64 printf (_("\n\
65There are no required arguments. By default, the local database with\n\
66a server listening on MySQL standard port %d will be checked\n"), MYSQL_PORT);
67
68 printf (_(UT_SUPPORT));
69}
70
27char *db_user = ""; 71char *db_user = "";
28char *db_host = ""; 72char *db_host = "";
29char *db_pass = ""; 73char *db_pass = "";
30char *db = ""; 74char *db = "";
31unsigned int db_port = MYSQL_PORT;
32 75
33int process_arguments (int, char **); 76int process_arguments (int, char **);
34int validate_arguments (void); 77int validate_arguments (void);
35void print_help (void);
36void print_usage (void);
37 78
38int 79int
39main (int argc, char **argv) 80main (int argc, char **argv)
@@ -43,7 +84,7 @@ main (int argc, char **argv)
43 char result[1024]; 84 char result[1024];
44 85
45 if (process_arguments (argc, argv) != OK) 86 if (process_arguments (argc, argv) != OK)
46 usage ("Invalid command arguments supplied\n"); 87 usage (_("Invalid command arguments supplied\n"));
47 88
48 /* initialize mysql */ 89 /* initialize mysql */
49 mysql_init (&mysql); 90 mysql_init (&mysql);
@@ -154,7 +195,7 @@ process_arguments (int argc, char **argv)
154 db_host = optarg; 195 db_host = optarg;
155 } 196 }
156 else { 197 else {
157 usage ("Invalid host name\n"); 198 usage (_("Invalid host name\n"));
158 } 199 }
159 break; 200 break;
160 case 'd': /* hostname */ 201 case 'd': /* hostname */
@@ -170,13 +211,13 @@ process_arguments (int argc, char **argv)
170 db_port = atoi (optarg); 211 db_port = atoi (optarg);
171 break; 212 break;
172 case 'V': /* version */ 213 case 'V': /* version */
173 print_revision (progname, REVISION); 214 print_revision (progname, revision);
174 exit (STATE_OK); 215 exit (STATE_OK);
175 case 'h': /* help */ 216 case 'h': /* help */
176 print_help (); 217 print_help ();
177 exit (STATE_OK); 218 exit (STATE_OK);
178 case '?': /* help */ 219 case '?': /* help */
179 usage ("Invalid argument\n"); 220 usage (_("Invalid argument\n"));
180 } 221 }
181 } 222 }
182 223
@@ -215,50 +256,3 @@ validate_arguments (void)
215{ 256{
216 return OK; 257 return OK;
217} 258}
218
219
220
221
222
223void
224print_help (void)
225{
226 print_revision (progname, REVISION);
227 printf
228 ("Copyright (c) 2000 Didi Rieder/Karl DeBisschop\n\n"
229 "This plugin is for testing a mysql server.\n");
230 print_usage ();
231 printf
232 ("\nThere are no required arguments. By default, the local database with\n"
233 "a server listening on MySQL standard port %d will be checked\n\n"
234 "Options:\n"
235 " -d, --database=STRING\n"
236 " Check database with indicated name\n"
237 " -H, --hostname=STRING or IPADDRESS\n"
238 " Check server on the indicated host\n"
239 " -P, --port=INTEGER\n"
240 " Make connection on the indicated port\n"
241 " -u, --username=STRING\n"
242 " Connect using the indicated username\n"
243 " -p, --password=STRING\n"
244 " Use the indicated password to authenticate the connection\n"
245 " ==> IMPORTANT: THIS FORM OF AUTHENTICATION IS NOT SECURE!!! <==\n"
246 " Your clear-text password will be visible as a process table entry\n"
247 " -h, --help\n"
248 " Print detailed help screen\n"
249 " -V, --version\n" " Print version information\n\n", MYSQL_PORT);
250 support ();
251}
252
253
254
255
256
257void
258print_usage (void)
259{
260 printf
261 ("Usage: %s [-d database] [-H host] [-P port] [-u user] [-p password]\n"
262 " %s --help\n"
263 " %s --version\n", progname, progname, progname);
264}