Imported Upstream version 2.0
This commit is contained in:
parent
c89ccc3c74
commit
0841b5c7c7
165 changed files with 25440 additions and 4442 deletions
|
@ -1,9 +1,9 @@
|
|||
/*****************************************************************************
|
||||
*
|
||||
* Nagios check_mysql_query plugin
|
||||
* Monitoring check_mysql_query plugin
|
||||
*
|
||||
* License: GPL
|
||||
* Copyright (c) 2006-2009 Nagios Plugins Development Team
|
||||
* Copyright (c) 2006-2009 Monitoring Plugins Development Team
|
||||
* Original code from check_mysql, copyright 1999 Didi Rieder
|
||||
*
|
||||
* Description:
|
||||
|
@ -31,7 +31,7 @@
|
|||
|
||||
const char *progname = "check_mysql_query";
|
||||
const char *copyright = "1999-2007";
|
||||
const char *email = "nagiosplug-devel@lists.sourceforge.net";
|
||||
const char *email = "devel@monitoring-plugins.org";
|
||||
|
||||
#include "common.h"
|
||||
#include "utils.h"
|
||||
|
@ -46,6 +46,8 @@ char *db_host = NULL;
|
|||
char *db_socket = NULL;
|
||||
char *db_pass = NULL;
|
||||
char *db = NULL;
|
||||
char *opt_file = NULL;
|
||||
char *opt_group = NULL;
|
||||
unsigned int db_port = MYSQL_PORT;
|
||||
|
||||
int process_arguments (int, char **);
|
||||
|
@ -83,7 +85,13 @@ main (int argc, char **argv)
|
|||
/* initialize mysql */
|
||||
mysql_init (&mysql);
|
||||
|
||||
mysql_options(&mysql,MYSQL_READ_DEFAULT_GROUP,"client");
|
||||
if (opt_file != NULL)
|
||||
mysql_options(&mysql,MYSQL_READ_DEFAULT_FILE,opt_file);
|
||||
|
||||
if (opt_group != NULL)
|
||||
mysql_options(&mysql,MYSQL_READ_DEFAULT_GROUP,opt_group);
|
||||
else
|
||||
mysql_options(&mysql,MYSQL_READ_DEFAULT_GROUP,"client");
|
||||
|
||||
/* establish a connection to the server and error checking */
|
||||
if (!mysql_real_connect(&mysql,db_host,db_user,db_pass,db,db_port,db_socket,0)) {
|
||||
|
@ -152,7 +160,13 @@ main (int argc, char **argv)
|
|||
} else if (status == STATE_CRITICAL) {
|
||||
printf("QUERY %s: ", _("CRITICAL"));
|
||||
}
|
||||
printf(_("'%s' returned %f"), sql_query, value);
|
||||
printf(_("'%s' returned %f | %s"), sql_query, value,
|
||||
fperfdata("result", value, "",
|
||||
my_thresholds->warning?TRUE:FALSE, my_thresholds->warning?my_thresholds->warning->end:0,
|
||||
my_thresholds->critical?TRUE:FALSE, my_thresholds->critical?my_thresholds->critical->end:0,
|
||||
FALSE, 0,
|
||||
FALSE, 0)
|
||||
);
|
||||
printf("\n");
|
||||
|
||||
return status;
|
||||
|
@ -174,6 +188,8 @@ process_arguments (int argc, char **argv)
|
|||
{"database", required_argument, 0, 'd'},
|
||||
{"username", required_argument, 0, 'u'},
|
||||
{"password", required_argument, 0, 'p'},
|
||||
{"file", required_argument, 0, 'f'},
|
||||
{"group", required_argument, 0, 'g'},
|
||||
{"port", required_argument, 0, 'P'},
|
||||
{"verbose", no_argument, 0, 'v'},
|
||||
{"version", no_argument, 0, 'V'},
|
||||
|
@ -188,7 +204,7 @@ process_arguments (int argc, char **argv)
|
|||
return ERROR;
|
||||
|
||||
while (1) {
|
||||
c = getopt_long (argc, argv, "hvVP:p:u:d:H:s:q:w:c:", longopts, &option);
|
||||
c = getopt_long (argc, argv, "hvVP:p:u:d:H:s:q:w:c:f:g:", longopts, &option);
|
||||
|
||||
if (c == -1 || c == EOF)
|
||||
break;
|
||||
|
@ -220,6 +236,12 @@ process_arguments (int argc, char **argv)
|
|||
optarg++;
|
||||
}
|
||||
break;
|
||||
case 'f': /* client options file */
|
||||
opt_file = optarg;
|
||||
break;
|
||||
case 'g': /* client options group */
|
||||
opt_group = optarg;
|
||||
break;
|
||||
case 'P': /* critical time threshold */
|
||||
db_port = atoi (optarg);
|
||||
break;
|
||||
|
@ -299,6 +321,10 @@ print_help (void)
|
|||
printf (" %s\n", _("Use the specified socket (has no effect if -H is used)"));
|
||||
printf (" -d, --database=STRING\n");
|
||||
printf (" %s\n", _("Database to check"));
|
||||
printf (" %s\n", "-f, --file=STRING");
|
||||
printf (" %s\n", _("Read from the specified client options file"));
|
||||
printf (" %s\n", "-g, --group=STRING");
|
||||
printf (" %s\n", _("Use a client options group"));
|
||||
printf (" -u, --username=STRING\n");
|
||||
printf (" %s\n", _("Username to login with"));
|
||||
printf (" -p, --password=STRING\n");
|
||||
|
@ -324,5 +350,5 @@ print_usage (void)
|
|||
{
|
||||
printf ("%s\n", _("Usage:"));
|
||||
printf (" %s -q SQL_query [-w warn] [-c crit] [-H host] [-P port] [-s socket]\n",progname);
|
||||
printf (" [-d database] [-u user] [-p password]\n");
|
||||
printf (" [-d database] [-u user] [-p password] [-f optfile] [-g group]\n");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue