@cryptotaxi247 / netdata-1 / commits / 82fb4a921

added support for rendering overflows and resets

Costa Tsaousis (ktsaou) committed Apr 9, 2014 at 15:17 UTC 82fb4a921ff3e63a963831dd6cc6120aef9a9236
1 file changed +270 -144
netdata.c
+270 -144
@@ -351,7 +351,10 @@ struct rrd_dimension {
351 long divisor;
352
353 void *values;
354 -
354 +
355 +// char **annotations;
356 +// char *(*annotator)(long double previous, long double current);
357 +
358 time_t last_updated;
359
360 struct rrd_dimension *next;
@@ -469,7 +472,7 @@ RRD_STATS *rrd_stats_create(const char *id, const char *name, unsigned long entr
472 return(st);
473 }
474
472 -RRD_DIMENSION *rrd_stats_dimension_add(RRD_STATS *st, const char *id, const char *name, size_t bytes, long multiplier, long divisor, int type)
475 +RRD_DIMENSION *rrd_stats_dimension_add(RRD_STATS *st, const char *id, const char *name, size_t bytes, long multiplier, long divisor, int type, void *obsolete)
476 {
477 RRD_DIMENSION *rd = NULL;
478
@@ -483,13 +486,22 @@ RRD_DIMENSION *rrd_stats_dimension_add(RRD_STATS *st, const char *id, const char
486 rd->multiplier = multiplier;
487 rd->divisor = divisor;
488 rd->type = type;
489 +
490 rd->values = calloc(rd->entries, rd->bytes);
491 if(!rd->values) {
488 - error("Cannot allocate %lu entries of %lu bytes each for RRD_DIMENSION.", rd->entries, rd->bytes);
492 + error("Cannot allocate %lu entries of %lu bytes each for RRD_DIMENSION values.", rd->entries, rd->bytes);
493 free(rd);
494 return NULL;
495 }
496
497 +/* rd->annotations = calloc(rd->entries, sizeof(char *));
498 + if(!rd->annotations) {
499 + error("Cannot allocate %lu entries of %lu bytes each for RRD_DIMENSION annotations.", rd->entries, sizeof(char *));
500 + free(rd->values);
501 + free(rd);
502 + return NULL;
503 + }
504 +*/
505 strncpy(rd->id, id, RRD_STATS_NAME_MAX);
506 rd->id[RRD_STATS_NAME_MAX] = '\0';
507
@@ -499,6 +511,8 @@ RRD_DIMENSION *rrd_stats_dimension_add(RRD_STATS *st, const char *id, const char
511 rd->next = st->dimensions;
512 st->dimensions = rd;
513
514 + //rd->annotator = annotator;
515 +
516 return(rd);
517 }
518
@@ -506,6 +520,7 @@ void rrd_stats_dimension_free(RRD_DIMENSION *rd)
520 {
521 if(rd->next) rrd_stats_dimension_free(rd->next);
522 debug(D_RRD_STATS, "Removing dimension '%s'.", rd->name);
523 + // free(rd->annotations);
524 free(rd->values);
525 free(rd);
526 }
@@ -549,6 +564,68 @@ RRD_DIMENSION *rrd_stats_dimension_find(RRD_STATS *st, const char *id)
564 return(rd);
565 }
566
567 +int rrd_stats_dimension_hide(RRD_STATS *st, const char *id)
568 +{
569 + RRD_DIMENSION *rd = rrd_stats_dimension_find(st, id);
570 + if(!rd) {
571 + error("Cannot find dimension with id '%s' on stats '%s' (%s).", id, st->name, st->id);
572 + return 1;
573 + }
574 +
575 + rd->hidden = 1;
576 + return 0;
577 +}
578 +
579 +void rrd_stats_dimension_set_by_pointer(RRD_STATS *st, RRD_DIMENSION *rd, void *data, void *obsolete)
580 +{
581 + rd->last_updated = st->last_updated;
582 +
583 + if(rd->bytes == sizeof(long long)) {
584 + long long *dimension = rd->values, *value = data;
585 +
586 + dimension[st->current_entry] = (*value);
587 + }
588 + else if(rd->bytes == sizeof(long)) {
589 + long *dimension = rd->values, *value = data;
590 +
591 + dimension[st->current_entry] = (*value);
592 + }
593 + else if(rd->bytes == sizeof(int)) {
594 + int *dimension = rd->values, *value = data;
595 +
596 + dimension[st->current_entry] = (*value);
597 + }
598 + else if(rd->bytes == sizeof(char)) {
599 + char *dimension = rd->values, *value = data;
600 +
601 + dimension[st->current_entry] = (*value);
602 + }
603 + else fatal("I don't know how to handle data of length %d bytes.", rd->bytes);
604 +
605 + // clear any previous annotations
606 +/* if(rd->annotations[st->current_entry]) {
607 + free(rd->annotations[st->current_entry]);
608 + rd->annotations[st->current_entry] = NULL;
609 + }
610 +
611 + // set the new annotation
612 + if(annotation)
613 + rd->annotations[st->current_entry] = strdup(annotation);
614 +*/
615 +}
616 +
617 +int rrd_stats_dimension_set(RRD_STATS *st, char *id, void *data, void *obsolete)
618 +{
619 + RRD_DIMENSION *rd = rrd_stats_dimension_find(st, id);
620 + if(!rd) {
621 + error("Cannot find dimension with id '%s' on stats '%s' (%s).", id, st->name, st->id);
622 + return 1;
623 + }
624 +
625 + rrd_stats_dimension_set_by_pointer(st, rd, data, obsolete);
626 + return 0;
627 +}
628 +
629 void rrd_stats_next(RRD_STATS *st)
630 {
631 struct timeval *now;
@@ -592,6 +669,15 @@ void rrd_stats_done(RRD_STATS *st)
669 continue;
670 }
671 }
672 + else if((rd->last_updated + update_every) < st->last_updated) {
673 + debug(D_RRD_STATS, "Clearing obsolete dimension '%s' (%s) of '%s' (%s).", rd->name, rd->id, st->name, st->id);
674 +
675 + unsigned char zero[rd->bytes];
676 + int i;
677 + for(i = 0; i < rd->bytes ; i++) zero[i] = 0;
678 +
679 + rrd_stats_dimension_set_by_pointer(st, rd, &zero, NULL);
680 + }
681
682 last = rd;
683 rd = rd->next;
@@ -600,53 +686,6 @@ void rrd_stats_done(RRD_STATS *st)
686 pthread_mutex_unlock(&st->mutex);
687 }
688
603 -int rrd_stats_dimension_hide(RRD_STATS *st, const char *id)
604 -{
605 - RRD_DIMENSION *rd = rrd_stats_dimension_find(st, id);
606 - if(!rd) {
607 - error("Cannot find dimension with id '%s' on stats '%s' (%s).", id, st->name, st->id);
608 - return 1;
609 - }
610 -
611 - rd->hidden = 1;
612 - return 0;
613 -}
614 -
615 -
616 -int rrd_stats_dimension_set(RRD_STATS *st, const char *id, void *data)
617 -{
618 - RRD_DIMENSION *rd = rrd_stats_dimension_find(st, id);
619 - if(!rd) {
620 - error("Cannot find dimension with id '%s' on stats '%s' (%s).", id, st->name, st->id);
621 - return 1;
622 - }
623 -
624 - rd->last_updated = st->last_updated;
625 -
626 - if(rd->bytes == sizeof(long long)) {
627 - long long *dimension = rd->values, *value = data;
628 -
629 - dimension[st->current_entry] = (*value);
630 - }
631 - else if(rd->bytes == sizeof(long)) {
632 - long *dimension = rd->values, *value = data;
633 -
634 - dimension[st->current_entry] = (*value);
635 - }
636 - else if(rd->bytes == sizeof(int)) {
637 - int *dimension = rd->values, *value = data;
638 -
639 - dimension[st->current_entry] = (*value);
640 - }
641 - else if(rd->bytes == sizeof(char)) {
642 - char *dimension = rd->values, *value = data;
643 -
644 - dimension[st->current_entry] = (*value);
645 - }
646 - else fatal("I don't know how to handle data of length %d bytes.", rd->bytes);
647 -
648 - return 0;
649 -}
689
690
691 // ----------------------------------------------------------------------------
@@ -897,6 +936,58 @@ long long rrd_stats_dimension_get(RRD_DIMENSION *rd, size_t position)
936 return(0);
937 }
938
939 +
940 +struct web_line {
941 + char *buffer;
942 + int len;
943 + int size;
944 +};
945 +
946 +struct web_line *web_line_create(size_t size)
947 +{
948 + struct web_line *l;
949 + l = calloc(1, sizeof(struct web_line));
950 + if(!l) fatal("Cannot allocate %d bytes.", sizeof(struct web_line));
951 +
952 + l->buffer = calloc(size + 1, sizeof(char));
953 + if(!l->buffer) fatal("Cannot allocate %d bytes.", (size + 1) * sizeof(char));
954 +
955 + l->len = 0;
956 + l->size = size;
957 +
958 + return (l);
959 +}
960 +
961 +int web_line_printf(struct web_line *wl, const char *fmt, ... )
962 +{
963 + if(wl->len < wl->size) {
964 + va_list args;
965 + va_start( args, fmt );
966 + wl->len += vsnprintf(&wl->buffer[wl->len], wl->size - wl->len, fmt, args);
967 + va_end( args );
968 + wl->buffer[wl->len] = '\0';
969 + }
970 +
971 + return (wl->len);
972 +}
973 +
974 +char *web_line(struct web_line *wl)
975 +{
976 + return wl->buffer;
977 +}
978 +
979 +void web_line_reset(struct web_line *wl)
980 +{
981 + wl->len = 0;
982 + wl->buffer[wl->len] = 0;
983 +}
984 +
985 +void web_line_free(struct web_line *wl)
986 +{
987 + free(wl->buffer);
988 + free(wl);
989 +}
990 +
991 void rrd_stats_json(RRD_STATS *st, struct web_buffer *wb, size_t entries_to_show, size_t group_count, int group_method)
992 {
993 pthread_mutex_lock(&st->mutex);
@@ -934,6 +1025,10 @@ void rrd_stats_json(RRD_STATS *st, struct web_buffer *wb, size_t entries_to_show
1025 return;
1026 }
1027
1028 + int line_size = 4096 + (dimensions * 200);
1029 + struct web_line *wl = web_line_create(line_size);
1030 + int annotation_count = 0;
1031 +
1032 // temporary storage to keep track of group values and counts
1033 long double group_values[dimensions];
1034 int group_counts[dimensions];
@@ -941,13 +1036,15 @@ void rrd_stats_json(RRD_STATS *st, struct web_buffer *wb, size_t entries_to_show
1036 group_values[c] = group_counts[c] = 0;
1037
1038 wb->bytes += sprintf(&wb->buffer[wb->bytes], "{\n \"cols\":\n [\n");
944 - wb->bytes += sprintf(&wb->buffer[wb->bytes], " {\"id\":\"\",\"label\":\"time\",\"pattern\":\"\",\"type\":\"datetime\"}");
1039 + wb->bytes += sprintf(&wb->buffer[wb->bytes], " {\"id\":\"\",\"label\":\"time\",\"pattern\":\"\",\"type\":\"datetime\"},\n");
1040 + wb->bytes += sprintf(&wb->buffer[wb->bytes], " {\"id\":\"\",\"label\":\"\",\"pattern\":\"\",\"type\":\"string\",\"p\":{\"role\":\"annotation\"}},\n");
1041 + wb->bytes += sprintf(&wb->buffer[wb->bytes], " {\"id\":\"\",\"label\":\"\",\"pattern\":\"\",\"type\":\"string\",\"p\":{\"role\":\"annotationText\"}}");
1042
1043 for( rd = st->dimensions, c = 0 ; rd && c < dimensions ; rd = rd->next, c++)
1044 if(!rd->hidden)
1045 wb->bytes += sprintf(&wb->buffer[wb->bytes], ",\n {\"id\":\"\",\"label\":\"%s\",\"pattern\":\"\",\"type\":\"number\"}", rd->name);
1046
950 - wb->bytes += sprintf(&wb->buffer[wb->bytes], " ],\n \"rows\":\n [\n");
1047 + wb->bytes += sprintf(&wb->buffer[wb->bytes], "\n ],\n \"rows\":\n [\n");
1048
1049 // to allow grouping on the same values, we need a pad
1050 pad = current_entry % group_count;
@@ -966,14 +1063,17 @@ void rrd_stats_json(RRD_STATS *st, struct web_buffer *wb, size_t entries_to_show
1063
1064 // the loop in dimension data
1065 count -= 2;
1066 + int annotate_reset = 0;
1067 for ( ; t != current_entry && count >= 0 ; lt = t++, count--) {
1068 + int print_this = 0;
1069 +
1070 if(t >= st->entries) t = 0;
1071
1072 // if the last is empty, loop again
1073 if(!st->times[lt].tv_sec) continue;
1074
1075 // check if we may exceed the buffer provided
976 - web_buffer_increase(wb, 1024 + (50 * dimensions));
1076 + web_buffer_increase(wb, line_size);
1077
1078 // prefer the most recent last entries
1079 if(((count-pad) / group_count) > entries_to_show) continue;
@@ -992,11 +1092,10 @@ void rrd_stats_json(RRD_STATS *st, struct web_buffer *wb, size_t entries_to_show
1092 if(!tm) { error("localtime() failed."); continue; }
1093
1094 sprintf(dtm, "\"Date(%d, %d, %d, %d, %d, %d, %d)\"", tm->tm_year + 1900, tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, (int)(st->times[t].tv_usec / 1000)); // datetime
995 - // strftime(dtm, 200, "\"Date(%Y, %m, %d, %H, %M, %S)\"", tm); // datetime
996 - // strftime(dtm, 200, "[%H, %M, %S, 0]", tm); // timeofday
1095 wb->bytes += sprintf(&wb->buffer[wb->bytes], "%s {\"c\":[{\"v\":%s}", printed?"]},\n":"", dtm);
1096
999 - printed++;
1097 + print_this = 1;
1098 + web_line_reset(wl);
1099 }
1100
1101 // if we need a PCENT_OVER_TOTAL, calculate the totals for the current and the last
@@ -1009,20 +1108,24 @@ void rrd_stats_json(RRD_STATS *st, struct web_buffer *wb, size_t entries_to_show
1108 }
1109
1110 for( rd = st->dimensions, c = 0 ; rd && c < dimensions ; rd = rd->next, c++) {
1012 - //long long oldvalue, value; // temp variable for storing data values
1111 long double oldvalue, value; // temp variable for storing data values
1112
1113 value = (long double)rrd_stats_dimension_get(rd, t);
1114 oldvalue = (long double)rrd_stats_dimension_get(rd, lt);
1017 -
1115 +
1116 switch(rd->type) {
1117 case RRD_DIMENSION_PCENT_OVER_TOTAL:
1118 value = (long double)100 * (value - oldvalue) / (total - oldtotal);
1119 break;
1120
1121 case RRD_DIMENSION_INCREMENTAL:
1024 - if(oldvalue > value) value = 0; // detect overflows and resets
1122 + if(oldvalue > value) {
1123 + // reset
1124 + annotate_reset = 1;
1125 + value = 0;
1126 + }
1127 else value -= oldvalue;
1128 +
1129 value = value * (long double)1000000L / (long double)usec;
1130 break;
1131
@@ -1032,6 +1135,10 @@ void rrd_stats_json(RRD_STATS *st, struct web_buffer *wb, size_t entries_to_show
1135
1136 value = value * (long double)rd->multiplier / (long double)rd->divisor;
1137
1138 +// if(rd->options & RRD_OPTION_ANNOTATE_NOT_ZERO) {
1139 +// annotation_add(my_annotations, rd->name, "%s = %0.1lf", value);
1140 +// }
1141 +
1142 group_counts[c]++;
1143 switch(group_method) {
1144 case GROUP_MAX:
@@ -1045,18 +1152,36 @@ void rrd_stats_json(RRD_STATS *st, struct web_buffer *wb, size_t entries_to_show
1152 break;
1153 }
1154
1048 - if(((count-pad) % group_count) == 0) {
1155 + if(print_this) {
1156 if(!rd->hidden)
1050 - wb->bytes += sprintf(&wb->buffer[wb->bytes], ",{\"v\":%0.1Lf}", group_values[c]);
1051 - //wb->bytes += sprintf(&wb->buffer[wb->bytes], ",{\"v\":%lld}", group_values[c]);
1157 + web_line_printf(wl, ",{\"v\":%0.1Lf}", group_values[c]);
1158 + //wb->bytes += sprintf(&wb->buffer[wb->bytes], ",{\"v\":%0.1Lf}", group_values[c]);
1159
1160 group_values[c] = group_counts[c] = 0;
1161 }
1162 }
1163 +
1164 + if(print_this) {
1165 + if(annotate_reset) {
1166 + annotation_count++;
1167 + wb->bytes += sprintf(&wb->buffer[wb->bytes], ",{\"v\":\"RESET OR OVERFLOW\"},{\"v\":\"The counters have been wrapped.\"}");
1168 + annotate_reset = 0;
1169 + }
1170 + else {
1171 + wb->bytes += sprintf(&wb->buffer[wb->bytes], ",{\"v\":null},{\"v\":null}");
1172 + }
1173 +
1174 + strcpy(&wb->buffer[wb->bytes], wl->buffer);
1175 + wb->bytes += wl->len;
1176 + printed++;
1177 + }
1178 }
1179 +
1180 if(printed) wb->bytes += sprintf(&wb->buffer[wb->bytes], "]}");
1181 wb->bytes += sprintf(&wb->buffer[wb->bytes], "\n ]\n}\n");
1182
1183 + web_line_free(wl);
1184 +
1185 pthread_mutex_unlock(&st->mutex);
1186 }
1187
@@ -2081,17 +2206,17 @@ int do_proc_net_dev() {
2206 continue;
2207 }
2208
2084 - if(!rrd_stats_dimension_add(st, "sent", "sent", sizeof(unsigned long long), -8, 1024, RRD_DIMENSION_INCREMENTAL))
2209 + if(!rrd_stats_dimension_add(st, "sent", "sent", sizeof(unsigned long long), -8, 1024, RRD_DIMENSION_INCREMENTAL, NULL))
2210 error("Cannot add RRD_STATS dimension %s.", "sent");
2211
2087 - if(!rrd_stats_dimension_add(st, "received", "received", sizeof(unsigned long long), 8, 1024, RRD_DIMENSION_INCREMENTAL))
2212 + if(!rrd_stats_dimension_add(st, "received", "received", sizeof(unsigned long long), 8, 1024, RRD_DIMENSION_INCREMENTAL, NULL))
2213 error("Cannot add RRD_STATS dimension %s.", "received");
2214
2215 }
2216 else rrd_stats_next(st);
2217
2093 - rrd_stats_dimension_set(st, "received", &rbytes);
2094 - rrd_stats_dimension_set(st, "sent", &tbytes);
2218 + rrd_stats_dimension_set(st, "received", &rbytes, NULL);
2219 + rrd_stats_dimension_set(st, "sent", &tbytes, NULL);
2220 rrd_stats_done(st);
2221 }
2222 }
@@ -2208,6 +2333,7 @@ int do_proc_diskstats() {
2333 case 146: // nfs
2334 case 199: // veritas
2335 case 201: // veritas
2336 + case 251: // dm
2337 break;
2338
2339 case 48: // RAID
@@ -2267,17 +2393,17 @@ int do_proc_diskstats() {
2393 continue;
2394 }
2395
2270 - if(!rrd_stats_dimension_add(st, "writes", "writes", sizeof(unsigned long long), sector_size * -1, 1024, RRD_DIMENSION_INCREMENTAL))
2396 + if(!rrd_stats_dimension_add(st, "writes", "writes", sizeof(unsigned long long), sector_size * -1, 1024, RRD_DIMENSION_INCREMENTAL, NULL))
2397 error("Cannot add RRD_STATS dimension %s.", "writes");
2398
2273 - if(!rrd_stats_dimension_add(st, "reads", "reads", sizeof(unsigned long long), sector_size, 1024, RRD_DIMENSION_INCREMENTAL))
2399 + if(!rrd_stats_dimension_add(st, "reads", "reads", sizeof(unsigned long long), sector_size, 1024, RRD_DIMENSION_INCREMENTAL, NULL))
2400 error("Cannot add RRD_STATS dimension %s.", "reads");
2401
2402 }
2403 else rrd_stats_next(st);
2404
2279 - rrd_stats_dimension_set(st, "reads", &readsectors);
2280 - rrd_stats_dimension_set(st, "writes", &writesectors);
2405 + rrd_stats_dimension_set(st, "reads", &readsectors, NULL);
2406 + rrd_stats_dimension_set(st, "writes", &writesectors, NULL);
2407 rrd_stats_done(st);
2408 }
2409 }
@@ -2331,21 +2457,21 @@ int do_proc_net_snmp() {
2457 continue;
2458 }
2459
2334 - if(!rrd_stats_dimension_add(st, "forwarded", "forwarded", sizeof(unsigned long long), 1, 1, RRD_DIMENSION_INCREMENTAL))
2460 + if(!rrd_stats_dimension_add(st, "forwarded", "forwarded", sizeof(unsigned long long), 1, 1, RRD_DIMENSION_INCREMENTAL, NULL))
2461 error("Cannot add RRD_STATS dimension %s.", "forwarded");
2462
2337 - if(!rrd_stats_dimension_add(st, "sent", "sent", sizeof(unsigned long long), -1, 1, RRD_DIMENSION_INCREMENTAL))
2463 + if(!rrd_stats_dimension_add(st, "sent", "sent", sizeof(unsigned long long), -1, 1, RRD_DIMENSION_INCREMENTAL, NULL))
2464 error("Cannot add RRD_STATS dimension %s.", "sent");
2465
2340 - if(!rrd_stats_dimension_add(st, "received", "received", sizeof(unsigned long long), 1, 1, RRD_DIMENSION_INCREMENTAL))
2466 + if(!rrd_stats_dimension_add(st, "received", "received", sizeof(unsigned long long), 1, 1, RRD_DIMENSION_INCREMENTAL, NULL))
2467 error("Cannot add RRD_STATS dimension %s.", "received");
2468
2469 }
2470 else rrd_stats_next(st);
2471
2346 - rrd_stats_dimension_set(st, "sent", &OutRequests);
2347 - rrd_stats_dimension_set(st, "received", &InReceives);
2348 - rrd_stats_dimension_set(st, "forwarded", &ForwDatagrams);
2472 + rrd_stats_dimension_set(st, "sent", &OutRequests, NULL);
2473 + rrd_stats_dimension_set(st, "received", &InReceives, NULL);
2474 + rrd_stats_dimension_set(st, "forwarded", &ForwDatagrams, NULL);
2475 rrd_stats_done(st);
2476 }
2477 else if(strncmp(p, "Tcp: ", 5) == 0) {
@@ -2375,12 +2501,12 @@ int do_proc_net_snmp() {
2501 continue;
2502 }
2503
2378 - if(!rrd_stats_dimension_add(st, "connections", "connections", sizeof(unsigned long long), 1, 1, RRD_DIMENSION_ABSOLUTE))
2504 + if(!rrd_stats_dimension_add(st, "connections", "connections", sizeof(unsigned long long), 1, 1, RRD_DIMENSION_ABSOLUTE, NULL))
2505 error("Cannot add RRD_STATS dimension %s.", "connections");
2506 }
2507 else rrd_stats_next(st);
2508
2383 - rrd_stats_dimension_set(st, "connections", &CurrEstab);
2509 + rrd_stats_dimension_set(st, "connections", &CurrEstab, NULL);
2510 rrd_stats_done(st);
2511
2512 st = rrd_stats_find(RRD_TYPE_NET_SNMP ".tcppackets");
@@ -2391,16 +2517,16 @@ int do_proc_net_snmp() {
2517 continue;
2518 }
2519
2394 - if(!rrd_stats_dimension_add(st, "sent", "sent", sizeof(unsigned long long), -1, 1, RRD_DIMENSION_INCREMENTAL))
2520 + if(!rrd_stats_dimension_add(st, "sent", "sent", sizeof(unsigned long long), -1, 1, RRD_DIMENSION_INCREMENTAL, NULL))
2521 error("Cannot add RRD_STATS dimension %s.", "sent");
2522
2397 - if(!rrd_stats_dimension_add(st, "received", "received", sizeof(unsigned long long), 1, 1, RRD_DIMENSION_INCREMENTAL))
2523 + if(!rrd_stats_dimension_add(st, "received", "received", sizeof(unsigned long long), 1, 1, RRD_DIMENSION_INCREMENTAL, NULL))
2524 error("Cannot add RRD_STATS dimension %s.", "received");
2525 }
2526 else rrd_stats_next(st);
2527
2402 - rrd_stats_dimension_set(st, "received", &InSegs);
2403 - rrd_stats_dimension_set(st, "sent", &OutSegs);
2528 + rrd_stats_dimension_set(st, "received", &InSegs, NULL);
2529 + rrd_stats_dimension_set(st, "sent", &OutSegs, NULL);
2530 rrd_stats_done(st);
2531 }
2532 else if(strncmp(p, "Udp: ", 5) == 0) {
@@ -2430,16 +2556,16 @@ int do_proc_net_snmp() {
2556 continue;
2557 }
2558
2433 - if(!rrd_stats_dimension_add(st, "sent", "sent", sizeof(unsigned long long), -1, 1, RRD_DIMENSION_INCREMENTAL))
2559 + if(!rrd_stats_dimension_add(st, "sent", "sent", sizeof(unsigned long long), -1, 1, RRD_DIMENSION_INCREMENTAL, NULL))
2560 error("Cannot add RRD_STATS dimension %s.", "sent");
2561
2436 - if(!rrd_stats_dimension_add(st, "received", "received", sizeof(unsigned long long), 1, 1, RRD_DIMENSION_INCREMENTAL))
2562 + if(!rrd_stats_dimension_add(st, "received", "received", sizeof(unsigned long long), 1, 1, RRD_DIMENSION_INCREMENTAL, NULL))
2563 error("Cannot add RRD_STATS dimension %s.", "received");
2564 }
2565 else rrd_stats_next(st);
2566
2441 - rrd_stats_dimension_set(st, "received", &InDatagrams);
2442 - rrd_stats_dimension_set(st, "sent", &OutDatagrams);
2567 + rrd_stats_dimension_set(st, "received", &InDatagrams, NULL);
2568 + rrd_stats_dimension_set(st, "sent", &OutDatagrams, NULL);
2569 rrd_stats_done(st);
2570 }
2571 }
@@ -2490,17 +2616,17 @@ int do_proc_net_netstat() {
2616 continue;
2617 }
2618
2493 - if(!rrd_stats_dimension_add(st, "sent", "sent", sizeof(unsigned long long), -8, 1024, RRD_DIMENSION_INCREMENTAL))
2619 + if(!rrd_stats_dimension_add(st, "sent", "sent", sizeof(unsigned long long), -8, 1024, RRD_DIMENSION_INCREMENTAL, NULL))
2620 error("Cannot add RRD_STATS dimension %s.", "sent");
2621
2496 - if(!rrd_stats_dimension_add(st, "received", "received", sizeof(unsigned long long), 8, 1024, RRD_DIMENSION_INCREMENTAL))
2622 + if(!rrd_stats_dimension_add(st, "received", "received", sizeof(unsigned long long), 8, 1024, RRD_DIMENSION_INCREMENTAL, NULL))
2623 error("Cannot add RRD_STATS dimension %s.", "received");
2624
2625 }
2626 else rrd_stats_next(st);
2627
2502 - rrd_stats_dimension_set(st, "sent", &OutOctets);
2503 - rrd_stats_dimension_set(st, "received", &InOctets);
2628 + rrd_stats_dimension_set(st, "sent", &OutOctets, NULL);
2629 + rrd_stats_dimension_set(st, "received", &InOctets, NULL);
2630 rrd_stats_done(st);
2631 }
2632 }
@@ -2569,12 +2695,12 @@ int do_proc_net_stat_conntrack() {
2695 return 1;
2696 }
2697
2572 - if(!rrd_stats_dimension_add(st, "connections", "connections", sizeof(unsigned long long), 1, 1, RRD_DIMENSION_ABSOLUTE))
2698 + if(!rrd_stats_dimension_add(st, "connections", "connections", sizeof(unsigned long long), 1, 1, RRD_DIMENSION_ABSOLUTE, NULL))
2699 error("Cannot add RRD_STATS dimension %s.", "connections");
2700 }
2701 else rrd_stats_next(st);
2702
2577 - rrd_stats_dimension_set(st, "connections", &aentries);
2703 + rrd_stats_dimension_set(st, "connections", &aentries, NULL);
2704 rrd_stats_done(st);
2705
2706 st = rrd_stats_find(RRD_TYPE_NET_STAT_CONNTRACK ".new");
@@ -2585,16 +2711,16 @@ int do_proc_net_stat_conntrack() {
2711 return 1;
2712 }
2713
2588 - if(!rrd_stats_dimension_add(st, "dropped", "dropped", sizeof(unsigned long long), -1, 1, RRD_DIMENSION_INCREMENTAL))
2714 + if(!rrd_stats_dimension_add(st, "dropped", "dropped", sizeof(unsigned long long), -1, 1, RRD_DIMENSION_INCREMENTAL, NULL))
2715 error("Cannot add RRD_STATS dimension %s.", "dropped");
2716
2591 - if(!rrd_stats_dimension_add(st, "new", "new", sizeof(unsigned long long), 1, 1, RRD_DIMENSION_INCREMENTAL))
2717 + if(!rrd_stats_dimension_add(st, "new", "new", sizeof(unsigned long long), 1, 1, RRD_DIMENSION_INCREMENTAL, NULL))
2718 error("Cannot add RRD_STATS dimension %s.", "new");
2719 }
2720 else rrd_stats_next(st);
2721
2596 - rrd_stats_dimension_set(st, "new", &anew);
2597 - rrd_stats_dimension_set(st, "dropped", &adrop);
2722 + rrd_stats_dimension_set(st, "new", &anew, NULL);
2723 + rrd_stats_dimension_set(st, "dropped", &adrop, NULL);
2724 rrd_stats_done(st);
2725
2726 st = rrd_stats_find(RRD_TYPE_NET_STAT_CONNTRACK ".changes");
@@ -2605,16 +2731,16 @@ int do_proc_net_stat_conntrack() {
2731 return 1;
2732 }
2733
2608 - if(!rrd_stats_dimension_add(st, "deleted", "deleted", sizeof(unsigned long long), -1, 1, RRD_DIMENSION_INCREMENTAL))
2734 + if(!rrd_stats_dimension_add(st, "deleted", "deleted", sizeof(unsigned long long), -1, 1, RRD_DIMENSION_INCREMENTAL, NULL))
2735 error("Cannot add RRD_STATS dimension %s.", "deleted");
2736
2611 - if(!rrd_stats_dimension_add(st, "inserted", "inserted", sizeof(unsigned long long), 1, 1, RRD_DIMENSION_INCREMENTAL))
2737 + if(!rrd_stats_dimension_add(st, "inserted", "inserted", sizeof(unsigned long long), 1, 1, RRD_DIMENSION_INCREMENTAL, NULL))
2738 error("Cannot add RRD_STATS dimension %s.", "inserted");
2739 }
2740 else rrd_stats_next(st);
2741
2616 - rrd_stats_dimension_set(st, "inserted", &ainsert);
2617 - rrd_stats_dimension_set(st, "deleted", &adelete);
2742 + rrd_stats_dimension_set(st, "inserted", &ainsert, NULL);
2743 + rrd_stats_dimension_set(st, "deleted", &adelete, NULL);
2744 rrd_stats_done(st);
2745
2746 return 0;
@@ -2671,12 +2797,12 @@ int do_proc_net_ip_vs_stats() {
2797 return 1;
2798 }
2799
2674 - if(!rrd_stats_dimension_add(st, "connections", "connections", sizeof(unsigned long long), 1, 1, RRD_DIMENSION_INCREMENTAL))
2800 + if(!rrd_stats_dimension_add(st, "connections", "connections", sizeof(unsigned long long), 1, 1, RRD_DIMENSION_INCREMENTAL, NULL))
2801 error("Cannot add RRD_STATS dimension %s.", "connections");
2802 }
2803 else rrd_stats_next(st);
2804
2679 - rrd_stats_dimension_set(st, "connections", &entries);
2805 + rrd_stats_dimension_set(st, "connections", &entries, NULL);
2806 rrd_stats_done(st);
2807
2808 st = rrd_stats_find(RRD_TYPE_NET_IPVS ".packets");
@@ -2687,16 +2813,16 @@ int do_proc_net_ip_vs_stats() {
2813 return 1;
2814 }
2815
2690 - if(!rrd_stats_dimension_add(st, "sent", "sent", sizeof(unsigned long long), -1, 1, RRD_DIMENSION_INCREMENTAL))
2816 + if(!rrd_stats_dimension_add(st, "sent", "sent", sizeof(unsigned long long), -1, 1, RRD_DIMENSION_INCREMENTAL, NULL))
2817 error("Cannot add RRD_STATS dimension %s.", "sent");
2818
2693 - if(!rrd_stats_dimension_add(st, "received", "received", sizeof(unsigned long long), 1, 1, RRD_DIMENSION_INCREMENTAL))
2819 + if(!rrd_stats_dimension_add(st, "received", "received", sizeof(unsigned long long), 1, 1, RRD_DIMENSION_INCREMENTAL, NULL))
2820 error("Cannot add RRD_STATS dimension %s.", "received");
2821 }
2822 else rrd_stats_next(st);
2823
2698 - rrd_stats_dimension_set(st, "received", &InPackets);
2699 - rrd_stats_dimension_set(st, "sent", &OutPackets);
2824 + rrd_stats_dimension_set(st, "received", &InPackets, NULL);
2825 + rrd_stats_dimension_set(st, "sent", &OutPackets, NULL);
2826 rrd_stats_done(st);
2827
2828 st = rrd_stats_find(RRD_TYPE_NET_IPVS ".net");
@@ -2707,16 +2833,16 @@ int do_proc_net_ip_vs_stats() {
2833 return 1;
2834 }
2835
2710 - if(!rrd_stats_dimension_add(st, "sent", "sent", sizeof(unsigned long long), -8, 1024, RRD_DIMENSION_INCREMENTAL))
2836 + if(!rrd_stats_dimension_add(st, "sent", "sent", sizeof(unsigned long long), -8, 1024, RRD_DIMENSION_INCREMENTAL, NULL))
2837 error("Cannot add RRD_STATS dimension %s.", "sent");
2838
2713 - if(!rrd_stats_dimension_add(st, "received", "received", sizeof(unsigned long long), 8, 1024, RRD_DIMENSION_INCREMENTAL))
2839 + if(!rrd_stats_dimension_add(st, "received", "received", sizeof(unsigned long long), 8, 1024, RRD_DIMENSION_INCREMENTAL, NULL))
2840 error("Cannot add RRD_STATS dimension %s.", "received");
2841 }
2842 else rrd_stats_next(st);
2843
2718 - rrd_stats_dimension_set(st, "received", &InBytes);
2719 - rrd_stats_dimension_set(st, "sent", &OutBytes);
2844 + rrd_stats_dimension_set(st, "received", &InBytes, NULL);
2845 + rrd_stats_dimension_set(st, "sent", &OutBytes, NULL);
2846 rrd_stats_done(st);
2847
2848 return 0;
@@ -2760,50 +2886,50 @@ int do_proc_stat() {
2886 long multiplier = 1;
2887 long divisor = 1; // sysconf(_SC_CLK_TCK);
2888
2763 - if(!rrd_stats_dimension_add(st, "iowait", "iowait", sizeof(unsigned long long), multiplier, divisor, RRD_DIMENSION_PCENT_OVER_TOTAL))
2889 + if(!rrd_stats_dimension_add(st, "iowait", "iowait", sizeof(unsigned long long), multiplier, divisor, RRD_DIMENSION_PCENT_OVER_TOTAL, NULL))
2890 error("Cannot add RRD_STATS dimension %s.", "iowait");
2891
2766 - if(!rrd_stats_dimension_add(st, "nice", "nice", sizeof(unsigned long long), multiplier, divisor, RRD_DIMENSION_PCENT_OVER_TOTAL))
2892 + if(!rrd_stats_dimension_add(st, "nice", "nice", sizeof(unsigned long long), multiplier, divisor, RRD_DIMENSION_PCENT_OVER_TOTAL, NULL))
2893 error("Cannot add RRD_STATS dimension %s.", "nice");
2894
2769 - if(!rrd_stats_dimension_add(st, "system", "system", sizeof(unsigned long long), multiplier, divisor, RRD_DIMENSION_PCENT_OVER_TOTAL))
2895 + if(!rrd_stats_dimension_add(st, "system", "system", sizeof(unsigned long long), multiplier, divisor, RRD_DIMENSION_PCENT_OVER_TOTAL, NULL))
2896 error("Cannot add RRD_STATS dimension %s.", "system");
2897
2772 - if(!rrd_stats_dimension_add(st, "user", "user", sizeof(unsigned long long), multiplier, divisor, RRD_DIMENSION_PCENT_OVER_TOTAL))
2898 + if(!rrd_stats_dimension_add(st, "user", "user", sizeof(unsigned long long), multiplier, divisor, RRD_DIMENSION_PCENT_OVER_TOTAL, NULL))
2899 error("Cannot add RRD_STATS dimension %s.", "user");
2900
2775 - if(!rrd_stats_dimension_add(st, "idle", "idle", sizeof(unsigned long long), multiplier, divisor, RRD_DIMENSION_PCENT_OVER_TOTAL))
2901 + if(!rrd_stats_dimension_add(st, "idle", "idle", sizeof(unsigned long long), multiplier, divisor, RRD_DIMENSION_PCENT_OVER_TOTAL, NULL))
2902 error("Cannot add RRD_STATS dimension %s.", "idle");
2903 else rrd_stats_dimension_hide(st, "idle");
2904
2779 - if(!rrd_stats_dimension_add(st, "irq", "irq", sizeof(unsigned long long), multiplier, divisor, RRD_DIMENSION_PCENT_OVER_TOTAL))
2905 + if(!rrd_stats_dimension_add(st, "irq", "irq", sizeof(unsigned long long), multiplier, divisor, RRD_DIMENSION_PCENT_OVER_TOTAL, NULL))
2906 error("Cannot add RRD_STATS dimension %s.", "irq");
2907
2782 - if(!rrd_stats_dimension_add(st, "softirq", "softirq", sizeof(unsigned long long), multiplier, divisor, RRD_DIMENSION_PCENT_OVER_TOTAL))
2908 + if(!rrd_stats_dimension_add(st, "softirq", "softirq", sizeof(unsigned long long), multiplier, divisor, RRD_DIMENSION_PCENT_OVER_TOTAL, NULL))
2909 error("Cannot add RRD_STATS dimension %s.", "softirq");
2910
2785 - if(!rrd_stats_dimension_add(st, "steal", "steal", sizeof(unsigned long long), multiplier, divisor, RRD_DIMENSION_PCENT_OVER_TOTAL))
2911 + if(!rrd_stats_dimension_add(st, "steal", "steal", sizeof(unsigned long long), multiplier, divisor, RRD_DIMENSION_PCENT_OVER_TOTAL, NULL))
2912 error("Cannot add RRD_STATS dimension %s.", "steal");
2913
2788 - if(!rrd_stats_dimension_add(st, "guest", "guest", sizeof(unsigned long long), multiplier, divisor, RRD_DIMENSION_PCENT_OVER_TOTAL))
2914 + if(!rrd_stats_dimension_add(st, "guest", "guest", sizeof(unsigned long long), multiplier, divisor, RRD_DIMENSION_PCENT_OVER_TOTAL, NULL))
2915 error("Cannot add RRD_STATS dimension %s.", "guest");
2916
2791 - if(!rrd_stats_dimension_add(st, "guest_nice", "guest_nice", sizeof(unsigned long long), multiplier, divisor, RRD_DIMENSION_PCENT_OVER_TOTAL))
2917 + if(!rrd_stats_dimension_add(st, "guest_nice", "guest_nice", sizeof(unsigned long long), multiplier, divisor, RRD_DIMENSION_PCENT_OVER_TOTAL, NULL))
2918 error("Cannot add RRD_STATS dimension %s.", "guest_nice");
2919
2920 }
2921 else rrd_stats_next(st);
2922
2797 - rrd_stats_dimension_set(st, "user", &user);
2798 - rrd_stats_dimension_set(st, "nice", &nice);
2799 - rrd_stats_dimension_set(st, "system", &system);
2800 - rrd_stats_dimension_set(st, "idle", &idle);
2801 - rrd_stats_dimension_set(st, "iowait", &iowait);
2802 - rrd_stats_dimension_set(st, "irq", &irq);
2803 - rrd_stats_dimension_set(st, "softirq", &softirq);
2804 - rrd_stats_dimension_set(st, "steal", &steal);
2805 - rrd_stats_dimension_set(st, "guest", &guest);
2806 - rrd_stats_dimension_set(st, "guest_nice", &guest_nice);
2923 + rrd_stats_dimension_set(st, "user", &user, NULL);
2924 + rrd_stats_dimension_set(st, "nice", &nice, NULL);
2925 + rrd_stats_dimension_set(st, "system", &system, NULL);
2926 + rrd_stats_dimension_set(st, "idle", &idle, NULL);
2927 + rrd_stats_dimension_set(st, "iowait", &iowait, NULL);
2928 + rrd_stats_dimension_set(st, "irq", &irq, NULL);
2929 + rrd_stats_dimension_set(st, "softirq", &softirq, NULL);
2930 + rrd_stats_dimension_set(st, "steal", &steal, NULL);
2931 + rrd_stats_dimension_set(st, "guest", &guest, NULL);
2932 + rrd_stats_dimension_set(st, "guest_nice", &guest_nice, NULL);
2933 rrd_stats_done(st);
2934 }
2935 else if(strncmp(p, "intr ", 5) == 0) {
@@ -2824,13 +2950,13 @@ int do_proc_stat() {
2950 continue;
2951 }
2952
2827 - if(!rrd_stats_dimension_add(st, "interrupts", "interrupts", sizeof(unsigned long long), 1, 1, RRD_DIMENSION_INCREMENTAL))
2953 + if(!rrd_stats_dimension_add(st, "interrupts", "interrupts", sizeof(unsigned long long), 1, 1, RRD_DIMENSION_INCREMENTAL, NULL))
2954 error("Cannot add RRD_STATS dimension %s.", "interrupts");
2955
2956 }
2957 else rrd_stats_next(st);
2958
2833 - rrd_stats_dimension_set(st, "interrupts", &value);
2959 + rrd_stats_dimension_set(st, "interrupts", &value, NULL);
2960 rrd_stats_done(st);
2961 }
2962 else if(strncmp(p, "ctxt ", 5) == 0) {
@@ -2851,13 +2977,13 @@ int do_proc_stat() {
2977 continue;
2978 }
2979
2854 - if(!rrd_stats_dimension_add(st, "switches", "switches", sizeof(unsigned long long), 1, 1, RRD_DIMENSION_INCREMENTAL))
2980 + if(!rrd_stats_dimension_add(st, "switches", "switches", sizeof(unsigned long long), 1, 1, RRD_DIMENSION_INCREMENTAL, NULL))
2981 error("Cannot add RRD_STATS dimension %s.", "switches");
2982
2983 }
2984 else rrd_stats_next(st);
2985
2860 - rrd_stats_dimension_set(st, "switches", &value);
2986 + rrd_stats_dimension_set(st, "switches", &value, NULL);
2987 rrd_stats_done(st);
2988 }
2989 else if(strncmp(p, "processes ", 10) == 0) {
@@ -2878,13 +3004,13 @@ int do_proc_stat() {
3004 continue;
3005 }
3006
2881 - if(!rrd_stats_dimension_add(st, "started", "started", sizeof(unsigned long long), 1, 1, RRD_DIMENSION_INCREMENTAL))
3007 + if(!rrd_stats_dimension_add(st, "started", "started", sizeof(unsigned long long), 1, 1, RRD_DIMENSION_INCREMENTAL, NULL))
3008 error("Cannot add RRD_STATS dimension %s.", "started");
3009
3010 }
3011 else rrd_stats_next(st);
3012
2887 - rrd_stats_dimension_set(st, "started", &value);
3013 + rrd_stats_dimension_set(st, "started", &value, NULL);
3014 rrd_stats_done(st);
3015 }
3016 else if(strncmp(p, "procs_running ", 14) == 0) {
@@ -2905,13 +3031,13 @@ int do_proc_stat() {
3031 continue;
3032 }
3033
2908 - if(!rrd_stats_dimension_add(st, "running", "running", sizeof(unsigned long long), 1, 1, RRD_DIMENSION_ABSOLUTE))
3034 + if(!rrd_stats_dimension_add(st, "running", "running", sizeof(unsigned long long), 1, 1, RRD_DIMENSION_ABSOLUTE, NULL))
3035 error("Cannot add RRD_STATS dimension %s.", "running");
3036
3037 }
3038 else rrd_stats_next(st);
3039
2914 - rrd_stats_dimension_set(st, "running", &value);
3040 + rrd_stats_dimension_set(st, "running", &value, NULL);
3041 rrd_stats_done(st);
3042 }
3043 }
@@ -3049,7 +3175,7 @@ void tc_device_commit(struct tc_device *d)
3175
3176 for ( c = d->classes ; c ; c = c->next) {
3177 if(c->isleaf && c->hasparent) {
3052 - if(!rrd_stats_dimension_add(st, c->id, c->name, sizeof(unsigned long long), 8, 1024, RRD_DIMENSION_INCREMENTAL))
3178 + if(!rrd_stats_dimension_add(st, c->id, c->name, sizeof(unsigned long long), 8, 1024, RRD_DIMENSION_INCREMENTAL, NULL))
3179 error("Cannot add RRD_STATS dimension %s.", c->name);
3180 }
3181 }
@@ -3058,12 +3184,12 @@ void tc_device_commit(struct tc_device *d)
3184
3185 for ( c = d->classes ; c ; c = c->next) {
3186 if(c->isleaf && c->hasparent)
3061 - if(rrd_stats_dimension_set(st, c->id, &c->bytes) != 0) {
3187 + if(rrd_stats_dimension_set(st, c->id, &c->bytes, NULL) != 0) {
3188
3189 // new class, we have to add it
3064 - if(!rrd_stats_dimension_add(st, c->id, c->name, sizeof(unsigned long long), 8, 1024, RRD_DIMENSION_INCREMENTAL))
3190 + if(!rrd_stats_dimension_add(st, c->id, c->name, sizeof(unsigned long long), 8, 1024, RRD_DIMENSION_INCREMENTAL, NULL))
3191 error("Cannot add RRD_STATS dimension %s.", c->name);
3066 - else rrd_stats_dimension_set(st, c->id, &c->bytes);
3192 + else rrd_stats_dimension_set(st, c->id, &c->bytes, NULL);
3193 }
3194
3195 // check if the class changed name
@@ -3259,13 +3385,13 @@ void *cpujitter_main(void *ptr)
3385 continue;
3386 }
3387
3262 - if(!rrd_stats_dimension_add(st, "jitter", "jitter", sizeof(unsigned long long), 1, 1, RRD_DIMENSION_ABSOLUTE))
3388 + if(!rrd_stats_dimension_add(st, "jitter", "jitter", sizeof(unsigned long long), 1, 1, RRD_DIMENSION_ABSOLUTE, NULL))
3389 error("Cannot add RRD_STATS dimension %s.", "jitter");
3390
3391 }
3392 else rrd_stats_next(st);
3393
3268 - rrd_stats_dimension_set(st, "jitter", &usec);
3394 + rrd_stats_dimension_set(st, "jitter", &usec, NULL);
3395 rrd_stats_done(st);
3396 }
3397