ex wrote:
It's a hack (I dont know C

, but working (except DEBUG) for me.
I just hacked a solution too, very similar to yours. Your version had fewer modification so I tried it too, but it didn't work for me. So I reverted back to this:
Code:
--- sql.c-dist 2008-05-12 04:59:59.000000000 +1000
+++ sql.c 2008-05-12 05:25:52.000000000 +1000
@@ -48,10 +48,10 @@
int db_insert(MYSQL *mysql, const char *query) {
int error;
int error_count = 0;
- char query_frag[BUFSIZE];
+ char query_frag[BIG_BUFSIZE];
/* save a fragment just in case */
- snprintf(query_frag, BUFSIZE, "%s", query);
+ snprintf(query_frag, BIG_BUFSIZE, "%s", query);
/* show the sql query */
if (set.log_level == 5) {
@@ -102,10 +102,10 @@
int error = 0;
int error_count = 0;
- char query_frag[BUFSIZE];
+ char query_frag[BIG_BUFSIZE];
/* save a fragment just in case */
- snprintf(query_frag, BUFSIZE, "%s", query);
+ snprintf(query_frag, BIG_BUFSIZE, "%s", query);
/* show the sql query */
SPINE_LOG_DEBUG(("DEBUG: SQL:'%s'", query_frag));
Code:
--- poller.c-dist 2008-05-12 05:11:11.000000000 +1000
+++ poller.c 2008-05-12 05:36:16.000000000 +1000
@@ -94,7 +94,7 @@
char query5[BUFSIZE];
char query6[BUFSIZE];
char query7[BUFSIZE];
- char query8[BUFSIZE];
+ char query8[BIG_BUFSIZE];
char query9[BUFSIZE];
char query10[BUFSIZE];
char errstr[BUFSIZE];
@@ -217,7 +217,7 @@
set.poller_interval, host_id);
/* query to add output records to the poller output table */
- snprintf(query8, BUFSIZE,
+ snprintf(query8, BIG_BUFSIZE,
"INSERT INTO poller_output"
" (local_data_id, rrd_name, time, output) VALUES");
@@ -498,7 +498,7 @@
poll_result = strdup("U");
}
- if (!(query3 = (char *)malloc(BUFSIZE))) {
+ if (!(query3 = (char *)malloc(BIG_BUFSIZE))) {
die("ERROR: Fatal malloc error: poller.c reindex insert!");
}
query3[0] = '\0';
@@ -509,21 +509,21 @@
}else if ((!strcmp(reindex->op, "=")) && (strcmp(reindex->assert_value,poll_result))) {
SPINE_LOG_HIGH(("Host[%i] ASSERT: '%s' .eq. '%s' failed. Recaching host '%s', data query #%i\n", host->id, reindex->assert_value, poll_result, host->hostname, reindex->data_query_id));
- snprintf(query3, BUFSIZE, "REPLACE INTO poller_command (poller_id, time, action,command) values (0, NOW(), %i, '%i:%i')", POLLER_COMMAND_REINDEX, host->id, reindex->data_query_id);
+ snprintf(query3, BIG_BUFSIZE, "REPLACE INTO poller_command (poller_id, time, action,command) values (0, NOW(), %i, '%i:%i')", POLLER_COMMAND_REINDEX, host->id, reindex->data_query_id);
db_insert(&mysql, query3);
assert_fail = TRUE;
previous_assert_failure = TRUE;
}else if ((!strcmp(reindex->op, ">")) && (strtoll(reindex->assert_value, (char **)NULL, 10) < strtoll(poll_result, (char **)NULL, 10))) {
SPINE_LOG_HIGH(("Host[%i] ASSERT: '%s' .gt. '%s' failed. Recaching host '%s', data query #%i\n", host->id, reindex->assert_value, poll_result, host->hostname, reindex->data_query_id));
- snprintf(query3, BUFSIZE, "REPLACE INTO poller_command (poller_id, time, action, command) values (0, NOW(), %i, '%i:%i')", POLLER_COMMAND_REINDEX, host->id, reindex->data_query_id);
+ snprintf(query3, BIG_BUFSIZE, "REPLACE INTO poller_command (poller_id, time, action, command) values (0, NOW(), %i, '%i:%i')", POLLER_COMMAND_REINDEX, host->id, reindex->data_query_id);
db_insert(&mysql, query3);
assert_fail = TRUE;
previous_assert_failure = TRUE;
}else if ((!strcmp(reindex->op, "<")) && (strtoll(reindex->assert_value, (char **)NULL, 10) > strtoll(poll_result, (char **)NULL, 10))) {
SPINE_LOG_HIGH(("Host[%i] ASSERT: '%s' .lt. '%s' failed. Recaching host '%s', data query #%i\n", host->id, reindex->assert_value, poll_result, host->hostname, reindex->data_query_id));
- snprintf(query3, BUFSIZE, "REPLACE INTO poller_command (poller_id, time, action, command) values (0, NOW(), %i, '%i:%i')", POLLER_COMMAND_REINDEX, host->id, reindex->data_query_id);
+ snprintf(query3, BIG_BUFSIZE, "REPLACE INTO poller_command (poller_id, time, action, command) values (0, NOW(), %i, '%i:%i')", POLLER_COMMAND_REINDEX, host->id, reindex->data_query_id);
db_insert(&mysql, query3);
assert_fail = TRUE;
previous_assert_failure = TRUE;
@@ -534,7 +534,7 @@
* 2) the OP code is > or < meaning the current value could have changed without causing
* the assert to fail */
if ((assert_fail) || (!strcmp(reindex->op, ">")) || (!strcmp(reindex->op, "<"))) {
- snprintf(query3, BUFSIZE, "UPDATE poller_reindex SET assert_value='%s' WHERE host_id='%i' AND data_query_id='%i' and arg1='%s'", poll_result, host_id, reindex->data_query_id, reindex->arg1);
+ snprintf(query3, BIG_BUFSIZE, "UPDATE poller_reindex SET assert_value='%s' WHERE host_id='%i' AND data_query_id='%i' and arg1='%s'", poll_result, host_id, reindex->data_query_id, reindex->arg1);
db_insert(&mysql, query3);
if ((assert_fail) &&
@@ -933,7 +933,7 @@
}
/* insert the query results into the database */
- if (!(query3 = (char *)malloc(MAX_MYSQL_BUF_SIZE+BUFSIZE))) {
+ if (!(query3 = (char *)malloc(MAX_MYSQL_BUF_SIZE+BIG_BUFSIZE))) {
die("ERROR: Fatal malloc error: poller.c query3 oids!");
}
query3[0] = '\0';
@@ -943,7 +943,7 @@
i = 0;
while (i < rows_processed) {
- snprintf(result_string, BUFSIZE, " (%i,'%s','%s','%s')",
+ snprintf(result_string, BIG_BUFSIZE, " (%i,'%s','%s','%s')",
poller_items[i].local_data_id,
poller_items[i].rrd_name,
host_time,
Would be great if the developer could fix this fro the next release. I'm not sure if posting here will get a patch moved upstream; I didn't see an obvious way to submit patches to developers.