summaryrefslogtreecommitdiffstats
path: root/contrib/check_mysql.c
diff options
context:
space:
mode:
authorEthan Galstad <egalstad@users.sourceforge.net>2002-02-28 06:42:51 +0000
committerEthan Galstad <egalstad@users.sourceforge.net>2002-02-28 06:42:51 +0000
commit44a321cb8a42d6c0ea2d96a1086a17f2134c89cc (patch)
treea1a4d9f7b92412a17ab08f34f04eec45433048b7 /contrib/check_mysql.c
parent54fd5d7022ff2d6a59bc52b8869182f3fc77a058 (diff)
downloadmonitoring-plugins-44a321cb8a42d6c0ea2d96a1086a17f2134c89cc.tar.gz
Initial revision
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@2 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'contrib/check_mysql.c')
-rw-r--r--contrib/check_mysql.c75
1 files changed, 75 insertions, 0 deletions
diff --git a/contrib/check_mysql.c b/contrib/check_mysql.c
new file mode 100644
index 00000000..9abacf87
--- /dev/null
+++ b/contrib/check_mysql.c
@@ -0,0 +1,75 @@
1/*****************************************************************
2 *
3 * Program: check_mysql.c
4 * License: GPL
5 *
6 * Written by Tim Weippert
7 * (based on plugins by Ethan Galstad and MySQL example code)
8 *
9 * Command line: check_mysql <host> [user] [passwd]
10 * <host> can be the FQDN or the IP-Adress
11 * [user] and [passwd] are optional
12 *
13 * Description:
14 *
15 * This plugin attempts to connect to an MySQL Server
16 * with the optional specified parameters user and passwd.
17 * Normaly the host and a user HAVE to assigned.
18 *
19 * The plugin returns
20 * STATE_OK and the Version Number of the Server when all is fine
21 * STATE_CRITICAL if the Connection can't be esablished
22 * STATE_WARNING if the connection was established but the
23 * program can't get the Versoin Number
24 * STATE_UNKNOWN if to many parameters are given
25 *
26 * Copyright (c) 1999 by Tim Weippert
27 *
28 * Changes:
29 * 16.12.1999: Changed the return codes from numbers to statements
30 *
31 *******************************************************************/
32
33#include "../common/config.h"
34#include "../common/common.h"
35#include "mysql.h"
36
37MYSQL mysql;
38
39int main(int argc, char **argv)
40{
41 uint i = 0;
42 char *host;
43 char *user;
44 char *passwd;
45
46 char *status;
47 char *version;
48
49 if ( argc > 4 ) {
50 printf("Too many Arguments supplied - %i .\n", argc);
51 printf("Usage: %s <host> [user] [passwd]\n", argv[0]);
52 return STATE_UNKNOWN;
53 }
54
55 (host = argv[1]) || (host = NULL);
56 (user = argv[2]) || (user = NULL);
57 (passwd = argv[3]) || (passwd = NULL);
58
59 if (!(mysql_connect(&mysql,host,user,passwd))) {
60 printf("Can't connect to Mysql on Host: %s\n", host);
61 return STATE_CRITICAL;
62 }
63
64 if ( !(version = mysql_get_server_info(&mysql)) ) {
65 printf("Connect OK, but can't get Serverinfo ... something wrong !\n");
66 return STATE_WARNING;
67 }
68
69 printf("Mysql ok - Running Version: %s\n", version);
70
71 mysql_close(&mysql);
72 return STATE_OK;
73}
74
75