/**
* collectd - src/mysql.c
- * Copyright (C) 2006,2007 Florian octo Forster
+ * Copyright (C) 2006–2008 Florian octo Forster
+ * Copyright (C) 2008 Mirko Buffoni
*
* 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
*
* Authors:
* Florian octo Forster <octo at verplant.org>
+ * Mirko Buffoni <briareos at eswat.org>
**/
#include "collectd.h"
static char *pass;
static char *db = NULL;
static char *socket = NULL;
-static int port = 0;
+static int port = 0;
static MYSQL *getconnection (void)
{
else if (strcasecmp (key, "socket") == 0)
return ((socket = strdup (value)) == NULL ? 1 : 0);
else if (strcasecmp (key, "port") == 0)
- return ((port = atoi (value)) == NULL ? 1 : 0);
+ {
+ char *endptr = NULL;
+ int temp;
+
+ errno = 0;
+ temp = strtol (value, &endptr, 0);
+ if ((errno != 0) || (value == endptr))
+ {
+ ERROR ("mysql plugin: Invalid \"Port\" argument: %s",
+ value);
+ port = 0;
+ return (1);
+ }
+ else if ((temp < 0) || (temp >= 65535))
+ {
+ ERROR ("mysql plugin: Port number out of range: %i",
+ temp);
+ port = 0;
+ return (1);
+ }
+
+ port = temp;
+ return (0);
+ }
else
return (-1);
-}
+} /* int config */
static void counter_submit (const char *type, const char *type_instance,
counter_t value)
vl.values = values;
vl.values_len = 1;
- vl.time = time (NULL);
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "mysql", sizeof (vl.plugin));
sstrncpy (vl.type, type, sizeof (vl.type));
vl.values = values;
vl.values_len = 5;
- vl.time = time (NULL);
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "mysql", sizeof (vl.plugin));
sstrncpy (vl.type, "mysql_qcache", sizeof (vl.type));
vl.values = values;
vl.values_len = 4;
- vl.time = time (NULL);
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "mysql", sizeof (vl.plugin));
sstrncpy (vl.type, "mysql_threads", sizeof (vl.type));
vl.values = values;
vl.values_len = 2;
- vl.time = time (NULL);
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "mysql", sizeof (vl.plugin));
sstrncpy (vl.type, "mysql_octets", sizeof (vl.type));