thermferm/server.c

changeset 389
584d40bb4b09
parent 381
b22f8bf63b17
child 390
daa435544ab1
equal deleted inserted replaced
388:05a55609cd9a 389:584d40bb4b09
51 struct hostent *hp; 51 struct hostent *hp;
52 52
53 #define SS_BUFSIZE 1024 53 #define SS_BUFSIZE 1024
54 #define SS_TIMEOUT 300 54 #define SS_TIMEOUT 300
55 55
56 #define MAX_INTERVALS 6 56 #define MAX_INTERVALS 10
57 const int GRAPH_INTERVAL[MAX_INTERVALS] = { 0, 1, 5, 15, 30, 60, }; 57 const int GRAPH_INTERVAL[MAX_INTERVALS] = { 0, 1, 5, 15, 30, 60, 120, 240, 480, 960 };
58 const int GRAPH_DATALINES[MAX_INTERVALS] = { 0, 800, 3200, 12000, 24000, 48000, }; 58 const int GRAPH_DATALINES[MAX_INTERVALS] = { 0, 800, 3200, 12000, 24000, 48000, 96000, 192000, 384000, 768000 };
59 const char MONTH[12][4] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; 59 const char MONTH[12][4] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
60 60
61 61
62 typedef struct _ls_list { 62 typedef struct _ls_list {
63 struct _ls_list *next; /* Next record pointer */ 63 struct _ls_list *next; /* Next record pointer */
496 for (graphstep = 1; graphstep <= MAX_INTERVALS; graphstep++) { 496 for (graphstep = 1; graphstep <= MAX_INTERVALS; graphstep++) {
497 if (lines < GRAPH_DATALINES[graphstep]) { 497 if (lines < GRAPH_DATALINES[graphstep]) {
498 break; 498 break;
499 } 499 }
500 } 500 }
501 if (graphstep > MAX_INTERVALS)
502 graphstep = MAX_INTERVALS;
501 syslog(LOG_NOTICE, "ARCHIVE LOG %s: lines=%d, interval=%d, graphstep=%d", param, lines, GRAPH_INTERVAL[graphstep], graphstep); 503 syslog(LOG_NOTICE, "ARCHIVE LOG %s: lines=%d, interval=%d, graphstep=%d", param, lines, GRAPH_INTERVAL[graphstep], graphstep);
502 504
503 while (fgets(buffer, sizeof(buffer)-1, fp) != NULL) { 505 while (fgets(buffer, sizeof(buffer)-1, fp) != NULL) {
504 /* 506 /*
505 * 2014-11-15 18:39,BEER,20.312,19.750,20.0,0,NA,NA,NA,78105,NA,NA,18.000 507 * 2014-11-15 18:39,BEER,20.312,19.750,20.0,0,NA,NA,NA,78105,NA,NA,18.000

mercurial