1
/*****************************************************************
3
* Program: check_mysql.c
6
* Written by Tim Weippert
7
* (based on plugins by Ethan Galstad and MySQL example code)
9
* Command line: check_mysql <host> [user] [passwd]
10
* <host> can be the FQDN or the IP-Adress
11
* [user] and [passwd] are optional
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.
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
26
* Copyright (c) 1999 by Tim Weippert
29
* 16.12.1999: Changed the return codes from numbers to statements
31
*******************************************************************/
39
int main(int argc, char **argv)
50
printf("Too many Arguments supplied - %i .\n", argc);
51
printf("Usage: %s <host> [user] [passwd]\n", argv[0]);
55
(host = argv[1]) || (host = NULL);
56
(user = argv[2]) || (user = NULL);
57
(passwd = argv[3]) || (passwd = NULL);
59
if (!(mysql_connect(&mysql,host,user,passwd))) {
60
printf("Can't connect to Mysql on Host: %s\n", host);
61
return STATE_CRITICAL;
64
if ( !(version = mysql_get_server_info(&mysql)) ) {
65
printf("Connect OK, but can't get Serverinfo ... something wrong !\n");
69
printf("Mysql ok - Running Version: %s\n", version);