added noreset flag to prevent apps.plugin charts from showing "reset or overflow"; prevented a spike on incremental charts when starting them
Costa Tsaousis (ktsaou) committed
Nov 19, 2015 at 02:54 UTC
7b3be13a1a3ecdc1730c5e4ed2e460ec30c574a1
5 files changed
+49
-30
src/apps_plugin.c
+15
-15
@@ -1743,105 +1743,105 @@ void show_charts(void)
1743
for (w = target_root; w ; w = w->next) {
1744
if(w->target || (!w->processes && !w->exposed)) continue;
1745
1746
- fprintf(stdout, "DIMENSION %s '' incremental 100 %llu %s\n", w->name, (unsigned long long)(Hertz * update_every), w->hidden?"hidden":"");
1746
+ fprintf(stdout, "DIMENSION %s '' incremental 100 %llu %s\n", w->name, (unsigned long long)(Hertz * update_every), w->hidden?"hidden,noreset":"noreset");
1747
}
1748
1749
fprintf(stdout, "CHART apps.mem '' 'Apps Dedicated Memory (w/o shared)' 'MB' apps apps stacked 20003 %d\n", update_every);
1750
for (w = target_root; w ; w = w->next) {
1751
if(w->target || (!w->processes && !w->exposed)) continue;
1752
1753
- fprintf(stdout, "DIMENSION %s '' absolute %ld %ld\n", w->name, sysconf(_SC_PAGESIZE), 1024L*1024L);
1753
+ fprintf(stdout, "DIMENSION %s '' absolute %ld %ld noreset\n", w->name, sysconf(_SC_PAGESIZE), 1024L*1024L);
1754
}
1755
1756
fprintf(stdout, "CHART apps.threads '' 'Apps Threads' 'threads' apps apps stacked 20005 %d\n", update_every);
1757
for (w = target_root; w ; w = w->next) {
1758
if(w->target || (!w->processes && !w->exposed)) continue;
1759
1760
- fprintf(stdout, "DIMENSION %s '' absolute 1 1\n", w->name);
1760
+ fprintf(stdout, "DIMENSION %s '' absolute 1 1 noreset\n", w->name);
1761
}
1762
1763
fprintf(stdout, "CHART apps.processes '' 'Apps Processes' 'processes' apps apps stacked 20004 %d\n", update_every);
1764
for (w = target_root; w ; w = w->next) {
1765
if(w->target || (!w->processes && !w->exposed)) continue;
1766
1767
- fprintf(stdout, "DIMENSION %s '' absolute 1 1\n", w->name);
1767
+ fprintf(stdout, "DIMENSION %s '' absolute 1 1 noreset\n", w->name);
1768
}
1769
1770
fprintf(stdout, "CHART apps.cpu_user '' 'Apps CPU User Time (%ld%% = %ld core%s)' 'cpu time %%' apps none stacked 20020 %d\n", (processors * 100), processors, (processors>1)?"s":"", update_every);
1771
for (w = target_root; w ; w = w->next) {
1772
if(w->target || (!w->processes && !w->exposed)) continue;
1773
1774
- fprintf(stdout, "DIMENSION %s '' incremental 100 %llu\n", w->name, Hertz * processors * update_every);
1774
+ fprintf(stdout, "DIMENSION %s '' incremental 100 %llu noreset\n", w->name, Hertz * processors * update_every);
1775
}
1776
1777
fprintf(stdout, "CHART apps.cpu_system '' 'Apps CPU System Time (%ld%% = %ld core%s)' 'cpu time %%' apps none stacked 20021 %d\n", (processors * 100), processors, (processors>1)?"s":"", update_every);
1778
for (w = target_root; w ; w = w->next) {
1779
if(w->target || (!w->processes && !w->exposed)) continue;
1780
1781
- fprintf(stdout, "DIMENSION %s '' incremental 100 %llu\n", w->name, Hertz * processors * update_every);
1781
+ fprintf(stdout, "DIMENSION %s '' incremental 100 %llu noreset\n", w->name, Hertz * processors * update_every);
1782
}
1783
1784
fprintf(stdout, "CHART apps.major_faults '' 'Apps Major Page Faults (swaps in)' 'page faults/s' apps apps stacked 20010 %d\n", update_every);
1785
for (w = target_root; w ; w = w->next) {
1786
if(w->target || (!w->processes && !w->exposed)) continue;
1787
1788
- fprintf(stdout, "DIMENSION %s '' incremental 1 %d\n", w->name, update_every);
1788
+ fprintf(stdout, "DIMENSION %s '' incremental 1 %d noreset\n", w->name, update_every);
1789
}
1790
1791
fprintf(stdout, "CHART apps.minor_faults '' 'Apps Minor Page Faults' 'page faults/s' apps none stacked 20011 %d\n", update_every);
1792
for (w = target_root; w ; w = w->next) {
1793
if(w->target || (!w->processes && !w->exposed)) continue;
1794
1795
- fprintf(stdout, "DIMENSION %s '' incremental 1 %d\n", w->name, update_every);
1795
+ fprintf(stdout, "DIMENSION %s '' incremental 1 %d noreset\n", w->name, update_every);
1796
}
1797
1798
fprintf(stdout, "CHART apps.lreads '' 'Apps Disk Logical Reads' 'kilobytes/s' apps none stacked 20042 %d\n", update_every);
1799
for (w = target_root; w ; w = w->next) {
1800
if(w->target || (!w->processes && !w->exposed)) continue;
1801
1802
- fprintf(stdout, "DIMENSION %s '' incremental 1 %d\n", w->name, 1024 * update_every);
1802
+ fprintf(stdout, "DIMENSION %s '' incremental 1 %d noreset\n", w->name, 1024 * update_every);
1803
}
1804
1805
fprintf(stdout, "CHART apps.lwrites '' 'Apps I/O Logical Writes' 'kilobytes/s' apps none stacked 20042 %d\n", update_every);
1806
for (w = target_root; w ; w = w->next) {
1807
if(w->target || (!w->processes && !w->exposed)) continue;
1808
1809
- fprintf(stdout, "DIMENSION %s '' incremental 1 %d\n", w->name, 1024 * update_every);
1809
+ fprintf(stdout, "DIMENSION %s '' incremental 1 %d noreset\n", w->name, 1024 * update_every);
1810
}
1811
1812
fprintf(stdout, "CHART apps.preads '' 'Apps Disk Reads' 'kilobytes/s' apps apps stacked 20002 %d\n", update_every);
1813
for (w = target_root; w ; w = w->next) {
1814
if(w->target || (!w->processes && !w->exposed)) continue;
1815
1816
- fprintf(stdout, "DIMENSION %s '' incremental 1 %d\n", w->name, 1024 * update_every);
1816
+ fprintf(stdout, "DIMENSION %s '' incremental 1 %d noreset\n", w->name, 1024 * update_every);
1817
}
1818
1819
fprintf(stdout, "CHART apps.pwrites '' 'Apps Disk Writes' 'kilobytes/s' apps apps stacked 20002 %d\n", update_every);
1820
for (w = target_root; w ; w = w->next) {
1821
if(w->target || (!w->processes && !w->exposed)) continue;
1822
1823
- fprintf(stdout, "DIMENSION %s '' incremental 1 %d\n", w->name, 1024 * update_every);
1823
+ fprintf(stdout, "DIMENSION %s '' incremental 1 %d noreset\n", w->name, 1024 * update_every);
1824
}
1825
1826
fprintf(stdout, "CHART apps.files '' 'Apps Open Files' 'open files' apps apps stacked 20050 %d\n", update_every);
1827
for (w = target_root; w ; w = w->next) {
1828
if(w->target || (!w->processes && !w->exposed)) continue;
1829
1830
- fprintf(stdout, "DIMENSION %s '' absolute 1 1\n", w->name);
1830
+ fprintf(stdout, "DIMENSION %s '' absolute 1 1 noreset\n", w->name);
1831
}
1832
1833
fprintf(stdout, "CHART apps.sockets '' 'Apps Open Sockets' 'open sockets' apps apps stacked 20051 %d\n", update_every);
1834
for (w = target_root; w ; w = w->next) {
1835
if(w->target || (!w->processes && !w->exposed)) continue;
1836
1837
- fprintf(stdout, "DIMENSION %s '' absolute 1 1\n", w->name);
1837
+ fprintf(stdout, "DIMENSION %s '' absolute 1 1 noreset\n", w->name);
1838
}
1839
1840
fprintf(stdout, "CHART apps.pipes '' 'Apps Pipes' 'open pipes' apps none stacked 20053 %d\n", update_every);
1841
for (w = target_root; w ; w = w->next) {
1842
if(w->target || (!w->processes && !w->exposed)) continue;
1843
1844
- fprintf(stdout, "DIMENSION %s '' absolute 1 1\n", w->name);
1844
+ fprintf(stdout, "DIMENSION %s '' absolute 1 1 noreset\n", w->name);
1845
}
1846
1847
fprintf(stdout, "CHART netdata.apps_cpu '' 'Apps Plugin CPU' 'milliseconds/s' netdata netdata stacked 10000 %d\n", update_every);
src/plugins_d.c
+8
-3
@@ -287,7 +287,7 @@ void *pluginsd_worker_thread(void *arg)
287
char *algorithm = words[3];
288
char *multiplier_s = words[4];
289
char *divisor_s = words[5];
290
- char *hidden = words[6];
290
+ char *options = words[6];
291
292
if(unlikely(!id || !*id)) {
293
error("PLUGINSD: '%s' is requesting a DIMENSION, without an id. Disabling it.", cd->fullfilename);
@@ -320,13 +320,18 @@ void *pluginsd_worker_thread(void *arg)
320
, rrddim_algorithm_name(rrddim_algorithm_id(algorithm))
321
, multiplier
322
, divisor
323
- , hidden?hidden:""
323
+ , options?options:""
324
);
325
326
RRDDIM *rd = rrddim_find(st, id);
327
if(unlikely(!rd)) {
328
rd = rrddim_add(st, id, name, multiplier, divisor, rrddim_algorithm_id(algorithm));
329
- if(unlikely(hidden && strcmp(hidden, "hidden") == 0)) rd->hidden = 1;
329
+ rd->flags = 0x00000000;
330
+ if(options && *options) {
331
+ if(strstr(options, "hidden") != NULL) rd->flags |= RRDDIM_FLAG_HIDDEN;
332
+ if(strstr(options, "noreset") != NULL) rd->flags |= RRDDIM_FLAG_DONT_DETECT_RESETS_OR_OVERFLOWS;
333
+ if(strstr(options, "nooverflow") != NULL) rd->flags |= RRDDIM_FLAG_DONT_DETECT_RESETS_OR_OVERFLOWS;
334
+ }
335
}
336
else if(unlikely(st->debug)) debug(D_PLUGINSD, "PLUGINSD: dimension %s/%s already exists. Not adding it again.", st->id, id);
337
}
src/rrd.c
+13
-7
@@ -516,7 +516,7 @@ RRDDIM *rrddim_add(RRDSET *st, const char *id, const char *name, long multiplier
516
if(rd) {
517
// we have a file mapped for rd
518
rd->mapped = rrd_memory_mode;
519
- rd->hidden = 0;
519
+ rd->flags = 0x00000000;
520
rd->next = NULL;
521
rd->name = NULL;
522
}
@@ -730,7 +730,7 @@ int rrddim_hide(RRDSET *st, const char *id)
730
return 1;
731
}
732
733
- rd->hidden = 1;
733
+ rd->flags |= RRDDIM_FLAG_HIDDEN;
734
return 0;
735
}
736
@@ -744,7 +744,7 @@ int rrddim_unhide(RRDSET *st, const char *id)
744
return 1;
745
}
746
747
- rd->hidden = 0;
747
+ if(rd->flags & RRDDIM_FLAG_HIDDEN) rd->flags ^= RRDDIM_FLAG_HIDDEN;
748
return 0;
749
}
750
@@ -755,6 +755,7 @@ collected_number rrddim_set_by_pointer(RRDSET *st, RRDDIM *rd, collected_number
755
gettimeofday(&rd->last_collected_time, NULL);
756
rd->collected_value = value;
757
rd->updated = 1;
758
+ rd->counter++;
759
760
return rd->last_collected_value;
761
}
@@ -904,6 +905,11 @@ unsigned long long rrdset_done(RRDSET *st)
905
// at this stage we do not interpolate anything
906
for( rd = st->dimensions ; likely(rd) ; rd = rd->next ) {
907
908
+ if(unlikely(!rd->updated || rd->counter <= 1)) {
909
+ rd->calculated_value = 0;
910
+ continue;
911
+ }
912
+
913
if(unlikely(st->debug)) debug(D_RRD_STATS, "%s/%s: "
914
" last_collected_value = " COLLECTED_NUMBER_FORMAT
915
" collected_value = " COLLECTED_NUMBER_FORMAT
@@ -964,15 +970,15 @@ unsigned long long rrdset_done(RRDSET *st)
970
// if the new is smaller than the old (an overflow, or reset), set the old equal to the new
971
// to reset the calculation (it will give zero as the calculation for this second)
972
if(unlikely(rd->last_collected_value > rd->collected_value)) {
967
- debug(D_RRD_STATS, "%s.%s: Detect RESET or OVERFLOW. Last collected value = " COLLECTED_NUMBER_FORMAT ", current = " COLLECTED_NUMBER_FORMAT
973
+ debug(D_RRD_STATS, "%s.%s: RESET or OVERFLOW. Last collected value = " COLLECTED_NUMBER_FORMAT ", current = " COLLECTED_NUMBER_FORMAT
974
, st->name, rd->name
975
, rd->last_collected_value
976
, rd->collected_value);
971
- storage_flags = SN_EXISTS_RESET;
977
+ if(!(rd->flags & RRDDIM_FLAG_DONT_DETECT_RESETS_OR_OVERFLOWS)) storage_flags = SN_EXISTS_RESET;
978
rd->last_collected_value = rd->collected_value;
979
}
980
975
- rd->calculated_value += (calculated_number)(rd->collected_value - rd->last_collected_value);
981
+ rd->calculated_value = (calculated_number)(rd->collected_value - rd->last_collected_value);
982
983
if(unlikely(st->debug))
984
debug(D_RRD_STATS, "%s/%s: CALC INC "
@@ -1090,7 +1096,7 @@ unsigned long long rrdset_done(RRDSET *st)
1096
continue;
1097
}
1098
1093
- if(likely(rd->updated && iterations < st->gap_when_lost_iterations_above)) {
1099
+ if(likely(rd->updated && rd->counter > 1 && iterations < st->gap_when_lost_iterations_above)) {
1100
rd->values[st->current_entry] = pack_storage_number(
1101
new_value
1102
* (calculated_number)rd->multiplier
src/rrd.h
+10
-2
@@ -22,7 +22,7 @@ extern int rrd_delete_unupdated_dimensions;
22
#define RRD_ID_LENGTH_MAX 1024
23
24
#define RRDSET_MAGIC "NETDATA RRD SET FILE V013"
25
-#define RRDDIMENSION_MAGIC "NETDATA RRD DIMENSION FILE V013"
25
+#define RRDDIMENSION_MAGIC "NETDATA RRD DIMENSION FILE V015"
26
27
typedef long long total_number;
28
#define TOTAL_NUMBER_FORMAT "%lld"
@@ -75,6 +75,11 @@ extern int rrd_memory_mode_id(const char *name);
75
extern int rrddim_algorithm_id(const char *name);
76
extern const char *rrddim_algorithm_name(int chart_type);
77
78
+// ----------------------------------------------------------------------------
79
+// flags
80
+
81
+#define RRDDIM_FLAG_HIDDEN 0x00000001 // this dimension will not be offered to callers
82
+#define RRDDIM_FLAG_DONT_DETECT_RESETS_OR_OVERFLOWS 0x00000002 // do not offer RESET or OVERFLOW info to callers
83
84
// ----------------------------------------------------------------------------
85
// RRD DIMENSION
@@ -99,7 +104,6 @@ struct rrddim {
104
long multiplier; // the multiplier of the collected values
105
long divisor; // the divider of the collected values
106
102
- int hidden; // if set to non zero, this dimension will not be offered to callers
107
int mapped; // if set to non zero, this dimension is mapped to a file
108
109
// ------------------------------------------------------------------------
@@ -109,8 +113,12 @@ struct rrddim {
113
// instead of strcmp() every item in the binary index
114
// we first compare the hashes
115
116
+ uint32_t flags;
117
+
118
char cache_filename[FILENAME_MAX+1]; // the filename we load/save from/to this set
119
120
+ unsigned long counter; // the number of times we added values to this rrdim
121
+
122
int updated; // set to 0 after each calculation, to 1 after each collected value
123
// we use this to detect that a dimension is not updated
124
src/rrd2json.c
+3
-3
@@ -93,7 +93,7 @@ unsigned long rrd_stats_one_json(RRDSET *st, char *options, struct web_buffer *w
93
, rd->id
94
, rd->name
95
, rd->entries
96
- , rd->hidden
96
+ , (rd->flags & RRDDIM_FLAG_HIDDEN)?1:0
97
, rrddim_algorithm_name(rd->algorithm)
98
, rd->multiplier
99
, rd->divisor
@@ -540,7 +540,7 @@ RRDR *rrd2rrdr(RRDSET *st, long points, time_t after, time_t before, int group_m
540
541
// update the dimension options
542
if(found_non_zero[c]) r->od[c] |= RRDR_NONZERO;
543
- if(rd->hidden) r->od[c] |= RRDR_HIDDEN;
543
+ if(rd->flags & RRDDIM_FLAG_HIDDEN) r->od[c] |= RRDR_HIDDEN;
544
545
// store the specific point options
546
co[c] = group_options[c];
@@ -673,7 +673,7 @@ unsigned long rrd_stats_json(int type, RRDSET *st, struct web_buffer *wb, int po
673
// initialize them
674
for( rd = st->dimensions, c = 0 ; rd && c < dimensions ; rd = rd->next, c++) {
675
group_values[c] = 0;
676
- print_hidden[c] = rd->hidden;
676
+ print_hidden[c] = (rd->flags & RRDDIM_FLAG_HIDDEN)?1:0;
677
found_non_zero[c] = 0;
678
found_non_existing[c] = 0;
679
}