/**
* collectd - src/mysql.c
* Copyright (C) 2006-2009 Florian octo Forster
- * Copyright (C) 2009 Doug MacEachern
- * Copyright (C) 2009 Sebastian tokkee Harl
+ * Copyright (C) 2008 Mirko Buffoni
+ * Copyright (C) 2009 Doug MacEachern
+ * Copyright (C) 2009 Sebastian tokkee Harl
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
return (status);
}
assert (db->instance != NULL);
- db->database = strdup (db->instance);
}
else
{
db->port);
status = -1;
}
- if (db->database == NULL)
- {
- ERROR ("mysql plugin: No `Database' configured");
- status = -1;
- }
break;
} /* while (status == 0) */
user_data_t ud;
char cb_name[DATA_MAX_NAME_LEN];
- DEBUG ("mysql plugin: Registering new read callback: %s", db->database);
+ DEBUG ("mysql plugin: Registering new read callback: %s",
+ (db->database != NULL) ? db->database : "<default>");
memset (&ud, 0, sizeof (ud));
ud.data = (void *) db;
if (mysql_real_connect (db->con, db->host, db->user, db->pass,
db->database, db->port, db->socket, 0) == NULL)
{
- ERROR ("mysql_real_connect failed: %s", mysql_error (db->con));
+ ERROR ("mysql plugin: Failed to connect to database %s "
+ "at server %s: %s",
+ (db->database != NULL) ? db->database : "<none>",
+ (db->host != NULL) ? db->host : "localhost",
+ mysql_error (db->con));
db->state = 0;
return (NULL);
}
else
{
+ INFO ("mysql plugin: Sucessfully connected to database %s "
+ "at server %s (server version: %s, protocol version: %d)",
+ (db->database != NULL) ? db->database : "<none>",
+ mysql_get_host_info (db->con),
+ mysql_get_server_info (db->con),
+ mysql_get_proto_info (db->con));
db->state = 1;
return (db->con);
}