diff --git a/src/mysql.c b/src/mysql.c
index 822c6cce7ece8a0c68d5bf78d49e97b7249279d2..caebdf31f3d0f3e1156398cc9768863f4b4738d5 100644 (file)
--- a/src/mysql.c
+++ b/src/mysql.c
static char *pass;
static char *db = NULL;
static char *pass;
static char *db = NULL;
-#if MYSQL_HAVE_READ
-static char init_suceeded = 0;
-#endif
-
/* TODO
* understand `Select_*' and possibly do that stuff as well..
*/
/* TODO
* understand `Select_*' and possibly do that stuff as well..
*/
static MYSQL *con;
static int state;
static MYSQL *con;
static int state;
+ static int wait_for = 0;
+ static int wait_increase = 60;
+
+ int step;
+
if (state != 0)
{
int err;
if (state != 0)
{
int err;
}
}
}
}
+ step = atoi (COLLECTD_STEP);
+
+ if (wait_for > 0)
+ {
+ wait_for -= step;
+ return (NULL);
+ }
+
+ wait_for = wait_increase;
+ wait_increase *= 2;
+ if (wait_increase > 86400)
+ wait_increase = 86400;
+
if ((con = mysql_init (con)) == NULL)
{
syslog (LOG_ERR, "mysql_init failed: %s", mysql_error (con));
if ((con = mysql_init (con)) == NULL)
{
syslog (LOG_ERR, "mysql_init failed: %s", mysql_error (con));
else
{
state = 1;
else
{
state = 1;
+ wait_for = 0;
+ wait_increase = 60;
return (con);
}
} /* static MYSQL *getconnection (void) */
return (con);
}
} /* static MYSQL *getconnection (void) */
static void init (void)
{
static void init (void)
{
-#if MYSQL_HAVE_READ
- if (getconnection () != NULL)
- init_suceeded = 1;
- else
- {
- syslog (LOG_ERR, "The `mysql' plugin will be disabled because `init' failed to connect to `%s'", host);
- init_suceeded = 0;
- }
-#endif /* MYSQL_HAVE_READ */
-
return;
}
return;
}
unsigned long long traffic_incoming = 0ULL;
unsigned long long traffic_outgoing = 0ULL;
unsigned long long traffic_incoming = 0ULL;
unsigned long long traffic_outgoing = 0ULL;
- if (init_suceeded == 0)
- return;
-
/* An error message will have been printed in this case */
if ((con = getconnection ()) == NULL)
return;
/* An error message will have been printed in this case */
if ((con = getconnection ()) == NULL)
return;