diff options
Diffstat (limited to 'web/attachments/423473-nagiosplug-HEAD-mysql_noauth.patch')
-rw-r--r-- | web/attachments/423473-nagiosplug-HEAD-mysql_noauth.patch | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/web/attachments/423473-nagiosplug-HEAD-mysql_noauth.patch b/web/attachments/423473-nagiosplug-HEAD-mysql_noauth.patch new file mode 100644 index 0000000..e414423 --- /dev/null +++ b/web/attachments/423473-nagiosplug-HEAD-mysql_noauth.patch | |||
@@ -0,0 +1,74 @@ | |||
1 | diff -Naur nagiosplug/plugins/check_mysql.c nagiosplug.new/plugins/check_mysql.c | ||
2 | --- nagiosplug/plugins/check_mysql.c 2011-09-13 15:56:05.667051730 +0300 | ||
3 | +++ nagiosplug.new/plugins/check_mysql.c 2011-09-13 15:57:08.786832084 +0300 | ||
4 | @@ -42,6 +42,7 @@ | ||
5 | #include "netutils.h" | ||
6 | |||
7 | #include <mysql.h> | ||
8 | +#include <mysqld_error.h> | ||
9 | #include <errmsg.h> | ||
10 | |||
11 | char *db_user = NULL; | ||
12 | @@ -51,6 +52,7 @@ | ||
13 | char *db = NULL; | ||
14 | unsigned int db_port = MYSQL_PORT; | ||
15 | int check_slave = 0, warn_sec = 0, crit_sec = 0; | ||
16 | +int ignore_auth = 0; | ||
17 | int verbose = 0; | ||
18 | |||
19 | thresholds *my_threshold = NULL; | ||
20 | @@ -91,7 +93,16 @@ | ||
21 | |||
22 | /* establish a connection to the server and error checking */ | ||
23 | if (!mysql_real_connect(&mysql,db_host,db_user,db_pass,db,db_port,db_socket,0)) { | ||
24 | - if (mysql_errno (&mysql) == CR_UNKNOWN_HOST) | ||
25 | + if (ignore_auth && mysql_errno (&mysql) == ER_ACCESS_DENIED_ERROR) | ||
26 | + { | ||
27 | + printf("MySQL OK - Version: %s (protocol %d)\n", | ||
28 | + mysql_get_server_info(&mysql), | ||
29 | + mysql_get_proto_info(&mysql) | ||
30 | + ); | ||
31 | + mysql_close (&mysql); | ||
32 | + return STATE_OK; | ||
33 | + } | ||
34 | + else if (mysql_errno (&mysql) == CR_UNKNOWN_HOST) | ||
35 | die (STATE_WARNING, "%s\n", mysql_error (&mysql)); | ||
36 | else if (mysql_errno (&mysql) == CR_VERSION_ERROR) | ||
37 | die (STATE_WARNING, "%s\n", mysql_error (&mysql)); | ||
38 | @@ -252,6 +263,7 @@ | ||
39 | {"critical", required_argument, 0, 'c'}, | ||
40 | {"warning", required_argument, 0, 'w'}, | ||
41 | {"check-slave", no_argument, 0, 'S'}, | ||
42 | + {"ignore-auth", no_argument, 0, 'n'}, | ||
43 | {"verbose", no_argument, 0, 'v'}, | ||
44 | {"version", no_argument, 0, 'V'}, | ||
45 | {"help", no_argument, 0, 'h'}, | ||
46 | @@ -262,7 +274,7 @@ | ||
47 | return ERROR; | ||
48 | |||
49 | while (1) { | ||
50 | - c = getopt_long (argc, argv, "hvVSP:p:u:d:H:s:c:w:", longopts, &option); | ||
51 | + c = getopt_long (argc, argv, "hvVSnP:p:u:d:H:s:c:w:", longopts, &option); | ||
52 | |||
53 | if (c == -1 || c == EOF) | ||
54 | break; | ||
55 | @@ -300,6 +312,9 @@ | ||
56 | case 'S': | ||
57 | check_slave = 1; /* check-slave */ | ||
58 | break; | ||
59 | + case 'n': | ||
60 | + ignore_auth = 1; /* ignore-auth */ | ||
61 | + break; | ||
62 | case 'w': | ||
63 | warning = optarg; | ||
64 | break; | ||
65 | @@ -385,6 +400,9 @@ | ||
66 | printf (UT_EXTRA_OPTS); | ||
67 | |||
68 | printf (UT_HOST_PORT, 'P', myport); | ||
69 | + printf (" %s\n", "-n, --ignore-auth"); | ||
70 | + printf (" %s\n", _("Ignore authentication failure and check for mysql connectivity only")); | ||
71 | + | ||
72 | printf (" %s\n", "-s, --socket=STRING"); | ||
73 | printf (" %s\n", _("Use the specified socket (has no effect if -H is used)")); | ||
74 | |||