SOURCES: mysql_max_packet_size.patch (NEW) - add to CVS
glen
glen at pld-linux.org
Mon Mar 27 16:05:33 CEST 2006
Author: glen Date: Mon Mar 27 14:05:33 2006 GMT
Module: SOURCES Tag: HEAD
---- Log message:
- add to CVS
---- Files affected:
SOURCES:
mysql_max_packet_size.patch (NONE -> 1.1) (NEW)
---- Diffs:
================================================================
Index: SOURCES/mysql_max_packet_size.patch
diff -u /dev/null SOURCES/mysql_max_packet_size.patch:1.1
--- /dev/null Mon Mar 27 16:05:33 2006
+++ SOURCES/mysql_max_packet_size.patch Mon Mar 27 16:05:28 2006
@@ -0,0 +1,93 @@
+diff -ruBbd cacti-cactid-0.8.6g/cactid.h cacti-cactid-0.8.6g-patched/cactid.h
+--- cacti-cactid-0.8.6g/cactid.h 2006-01-11 19:25:55.000000000 -0500
++++ cacti-cactid-0.8.6g-patched/cactid.h 2006-01-22 18:57:38.000000000 -0500
+@@ -121,6 +121,7 @@
+ #define STAT_DESCRIP_ERROR 99
+ #define CACTID_PARENT 1
+ #define CACTID_FORK 0
++#define MAX_MYSQL_BUF_SIZE 1400
+
+ /* locations to search for the config file */
+ #define CONFIG_PATHS 2
+Only in cacti-cactid-0.8.6g-patched: mysql_max_packet_size.patch
+diff -ruBbd cacti-cactid-0.8.6g/poller.c cacti-cactid-0.8.6g-patched/poller.c
+--- cacti-cactid-0.8.6g/poller.c 2006-01-11 19:25:55.000000000 -0500
++++ cacti-cactid-0.8.6g-patched/poller.c 2006-01-22 18:57:38.000000000 -0500
+@@ -109,13 +109,12 @@
+ int j;
+ int num_oids = 0;
+ int snmp_poller_items = 0;
+- int buffer;
++ int out_buffer;
+ int php_process;
+
+ char *poll_result = NULL;
+ char update_sql[BUFSIZE];
+ char temp_result[BUFSIZE];
+- char delim = ' ';
+
+ int last_snmp_version = 0;
+ int last_snmp_port = 0;
+@@ -681,26 +680,52 @@
+ }
+ }
+
+- /* format database insert */
+- buffer = 600*rows_processed+100;
+-
+- if (!(query3 = (char *)malloc(buffer))) {
++ /* insert the query results into the database */
++ if (!(query3 = (char *)malloc(MAX_MYSQL_BUF_SIZE))) {
+ die("ERROR: Fatal malloc error: poller.c query3 oids!\n");
+ }
+- memset(query3, 0, buffer);
++ query3[0] = '\0';
+
+- snprintf(query3, buffer-1, "INSERT INTO poller_output (local_data_id,rrd_name,time,output) VALUES");
++ int new_buffer = TRUE;
++
++ snprintf(query3, MAX_MYSQL_BUF_SIZE-1, "INSERT INTO poller_output (local_data_id,rrd_name,time,output) VALUES");
++ out_buffer = strlen(query3);
+
+ i = 0;
+ while (i < rows_processed) {
+- snprintf(result_string, sizeof(result_string)-1, "%c(%i,'%s','%s','%s')", delim, poller_items[i].local_data_id, poller_items[i].rrd_name, start_datetime, poller_items[i].result);
++ snprintf(result_string, sizeof(result_string)-1, " (%i,'%s','%s','%s')", poller_items[i].local_data_id, poller_items[i].rrd_name, start_datetime, poller_items[i].result);
++
++ /* if the next element to the buffer will overflow it, write to the database */
++ if ((out_buffer + strlen(result_string)) >= MAX_MYSQL_BUF_SIZE) {
++ /* insert the record */
++ db_insert(&mysql, query3);
++
++ /* re-initialize the query buffer */
++ snprintf(query3, MAX_MYSQL_BUF_SIZE-1, "INSERT INTO poller_output (local_data_id,rrd_name,time,output) VALUES");
++
++ /* reset the output buffer length */
++ out_buffer = strlen(query3);
++
++ /* set binary, let the system know we are a new buffer */
++ new_buffer = TRUE;
++ }
++
++ /* if this is our first pass, or we just outputted to the database, need to change the delimeter */
++ if (new_buffer) {
++ result_string[0] = ' ';
++ }else{
++ result_string[0] = ',';
++ }
++
++ out_buffer = out_buffer + strlen(result_string);
+ strncat(query3, result_string, strlen(result_string));
+- delim = ',';
++
++ new_buffer = FALSE;
+ i++;
+ }
+
+- /* only perform and insert if there is something to insert */
+- if (rows_processed > 0) {
++ /* perform the last insert if required */
++ if (out_buffer > 0) {
+ /* insert records into database */
+ db_insert(&mysql, query3);
+ }
================================================================
More information about the pld-cvs-commit
mailing list