]> git.pld-linux.org Git - packages/cacti-spine.git/blob - mysql_max_packet_size.patch
- move to cacti webapps dir
[packages/cacti-spine.git] / mysql_max_packet_size.patch
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
4 @@ -121,6 +121,7 @@
5  #define STAT_DESCRIP_ERROR 99
6  #define CACTID_PARENT 1
7  #define CACTID_FORK 0
8 +#define MAX_MYSQL_BUF_SIZE 1400
9  
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
16 @@ -109,13 +109,12 @@
17         int j;
18         int num_oids = 0;
19         int snmp_poller_items = 0;
20 -       int buffer;
21 +       int out_buffer;
22         int php_process;
23  
24         char *poll_result = NULL;
25         char update_sql[BUFSIZE];
26         char temp_result[BUFSIZE];
27 -       char delim = ' ';
28  
29         int last_snmp_version = 0;
30         int last_snmp_port = 0;
31 @@ -681,26 +680,52 @@
32                         }
33                 }
34  
35 -               /* format database insert */
36 -               buffer = 600*rows_processed+100;
37 -
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");
42                 }
43 -               memset(query3, 0, buffer);
44 +               query3[0] = '\0';
45  
46 -               snprintf(query3, buffer-1, "INSERT INTO poller_output (local_data_id,rrd_name,time,output) VALUES");
47 +               int new_buffer = TRUE;
48 +               
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);
51  
52                 i = 0;
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);
56 +                       
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);
61 +
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");
64 +
65 +                               /* reset the output buffer length */
66 +                               out_buffer = strlen(query3);
67 +
68 +                               /* set binary, let the system know we are a new buffer */
69 +                               new_buffer = TRUE;
70 +                       }
71 +                       
72 +                       /* if this is our first pass, or we just outputted to the database, need to change the delimeter */
73 +                       if (new_buffer) {
74 +                               result_string[0] = ' ';
75 +                       }else{
76 +                               result_string[0] = ',';
77 +                       }
78 +                                                       
79 +                       out_buffer = out_buffer + strlen(result_string);
80                         strncat(query3, result_string, strlen(result_string));
81 -                       delim = ',';
82 +
83 +                       new_buffer = FALSE;
84                         i++;
85                 }
86  
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);
93                 }
This page took 0.062518 seconds and 3 git commands to generate.