1 diff -ruBbd cacti-cactid-0.8.6g/cactid.h cacti-cactid-0.8.6g-patched/cactid.h
2 --- cacti-cactid-0.8.6g/cactid.h 2006-01-11 19:25:55.000000000 -0500
3 +++ cacti-cactid-0.8.6g-patched/cactid.h 2006-01-22 18:57:38.000000000 -0500
5 #define STAT_DESCRIP_ERROR 99
6 #define CACTID_PARENT 1
8 +#define MAX_MYSQL_BUF_SIZE 1400
10 /* locations to search for the config file */
11 #define CONFIG_PATHS 2
12 Only in cacti-cactid-0.8.6g-patched: mysql_max_packet_size.patch
13 diff -ruBbd cacti-cactid-0.8.6g/poller.c cacti-cactid-0.8.6g-patched/poller.c
14 --- cacti-cactid-0.8.6g/poller.c 2006-01-11 19:25:55.000000000 -0500
15 +++ cacti-cactid-0.8.6g-patched/poller.c 2006-01-22 18:57:38.000000000 -0500
19 int snmp_poller_items = 0;
24 char *poll_result = NULL;
25 char update_sql[BUFSIZE];
26 char temp_result[BUFSIZE];
29 int last_snmp_version = 0;
30 int last_snmp_port = 0;
35 - /* format database insert */
36 - buffer = 600*rows_processed+100;
38 - if (!(query3 = (char *)malloc(buffer))) {
39 + /* insert the query results into the database */
40 + if (!(query3 = (char *)malloc(MAX_MYSQL_BUF_SIZE))) {
41 die("ERROR: Fatal malloc error: poller.c query3 oids!\n");
43 - memset(query3, 0, buffer);
46 - snprintf(query3, buffer-1, "INSERT INTO poller_output (local_data_id,rrd_name,time,output) VALUES");
47 + int new_buffer = TRUE;
49 + snprintf(query3, MAX_MYSQL_BUF_SIZE-1, "INSERT INTO poller_output (local_data_id,rrd_name,time,output) VALUES");
50 + out_buffer = strlen(query3);
53 while (i < rows_processed) {
54 - 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);
55 + 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);
57 + /* if the next element to the buffer will overflow it, write to the database */
58 + if ((out_buffer + strlen(result_string)) >= MAX_MYSQL_BUF_SIZE) {
59 + /* insert the record */
60 + db_insert(&mysql, query3);
62 + /* re-initialize the query buffer */
63 + snprintf(query3, MAX_MYSQL_BUF_SIZE-1, "INSERT INTO poller_output (local_data_id,rrd_name,time,output) VALUES");
65 + /* reset the output buffer length */
66 + out_buffer = strlen(query3);
68 + /* set binary, let the system know we are a new buffer */
72 + /* if this is our first pass, or we just outputted to the database, need to change the delimeter */
74 + result_string[0] = ' ';
76 + result_string[0] = ',';
79 + out_buffer = out_buffer + strlen(result_string);
80 strncat(query3, result_string, strlen(result_string));
87 - /* only perform and insert if there is something to insert */
88 - if (rows_processed > 0) {
89 + /* perform the last insert if required */
90 + if (out_buffer > 0) {
91 /* insert records into database */
92 db_insert(&mysql, query3);