not complete yet
Costa Tsaousis (ktsaou) committed
May 19, 2014 at 11:21 UTC
00e7da4bb2a99baae57a7d4328ff5bab1bd7228b
2 files changed
+115
-48
apps_plugin.c
+3
-3
@@ -1048,14 +1048,14 @@ void show_charts(void)
1048
for (w = target_root; w ; w = w->next) {
1049
if(w->target || (!w->processes && !w->exposed)) continue;
1050
1051
- fprintf(stdout, "DIMENSION %s '' absolute 1 1\n", w->name);
1051
+ fprintf(stdout, "DIMENSION %s '' absolute-last-value 1 1\n", w->name);
1052
}
1053
1054
fprintf(stdout, "CHART apps.processes '' 'Apps Processes' 'processes' apps apps stacked 20004 %d\n", update_every);
1055
for (w = target_root; w ; w = w->next) {
1056
if(w->target || (!w->processes && !w->exposed)) continue;
1057
1058
- fprintf(stdout, "DIMENSION %s '' absolute 1 1\n", w->name);
1058
+ fprintf(stdout, "DIMENSION %s '' absolute-last-value 1 1\n", w->name);
1059
}
1060
1061
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);
@@ -1119,7 +1119,7 @@ void show_charts(void)
1119
fprintf(stdout, "DIMENSION system '' incremental 1 1000\n");
1120
1121
fprintf(stdout, "CHART netdata.apps_files '' 'Apps Plugin Files' 'files/s' netdata netdata line 10001 %d\n", update_every);
1122
- fprintf(stdout, "DIMENSION files '' incremental 1 1\n");
1122
+ fprintf(stdout, "DIMENSION files '' incremental-last-value 1 1\n");
1123
1124
fflush(stdout);
1125
}
netdata.c
+112
-45
@@ -875,15 +875,19 @@ const char *chart_type_name(int chart_type)
875
// ----------------------------------------------------------------------------
876
// algorithms types
877
878
-#define RRD_DIMENSION_ABSOLUTE 0
879
-#define RRD_DIMENSION_INCREMENTAL 1
880
-#define RRD_DIMENSION_PCENT_OVER_DIFF_TOTAL 2
881
-#define RRD_DIMENSION_PCENT_OVER_ROW_TOTAL 3
878
+#define RRD_DIMENSION_ABSOLUTE 0
879
+#define RRD_DIMENSION_INCREMENTAL 1
880
+#define RRD_DIMENSION_PCENT_OVER_DIFF_TOTAL 2
881
+#define RRD_DIMENSION_PCENT_OVER_ROW_TOTAL 3
882
+#define RRD_DIMENSION_INCREMENTAL_NO_INTERPOLATION 4
883
+#define RRD_DIMENSION_ABSOLUTE_NO_INTERPOLATION 5
884
885
int algorithm_id(const char *name)
886
{
887
if(strcmp(name, "absolute") == 0) return RRD_DIMENSION_ABSOLUTE;
888
+ if(strcmp(name, "absolute-last-value") == 0) return RRD_DIMENSION_ABSOLUTE_NO_INTERPOLATION;
889
if(strcmp(name, "incremental") == 0) return RRD_DIMENSION_INCREMENTAL;
890
+ if(strcmp(name, "incremental-last-value") == 0) return RRD_DIMENSION_INCREMENTAL_NO_INTERPOLATION;
891
if(strcmp(name, "percentage-of-absolute-row") == 0) return RRD_DIMENSION_PCENT_OVER_ROW_TOTAL;
892
if(strcmp(name, "percentage-of-incremental-row") == 0) return RRD_DIMENSION_PCENT_OVER_DIFF_TOTAL;
893
return RRD_DIMENSION_ABSOLUTE;
@@ -895,14 +899,22 @@ const char *algorithm_name(int chart_type)
899
static char *incremental = "incremental";
900
static char *percentage_of_absolute_row = "percentage-of-absolute-row";
901
static char *percentage_of_incremental_row = "percentage-of-incremental-row";
902
+ static char *incremental_last_value = "incremental-last-value";
903
+ static char *absolute_last_value = "absolute-last-value";
904
905
switch(chart_type) {
906
case RRD_DIMENSION_ABSOLUTE:
907
return absolute;
908
909
+ case RRD_DIMENSION_ABSOLUTE_NO_INTERPOLATION:
910
+ return absolute_last_value;
911
+
912
case RRD_DIMENSION_INCREMENTAL:
913
return incremental;
914
915
+ case RRD_DIMENSION_INCREMENTAL_NO_INTERPOLATION:
916
+ return incremental_last_value;
917
+
918
case RRD_DIMENSION_PCENT_OVER_ROW_TOTAL:
919
return percentage_of_absolute_row;
920
@@ -1741,7 +1753,29 @@ unsigned long long rrd_stats_done(RRD_STATS *st)
1753
);
1754
break;
1755
1756
+ case RRD_DIMENSION_INCREMENTAL_NO_INTERPOLATION:
1757
+ // we need the incremental calculation to produce per second results
1758
+ // so, we multiply with 1.000.000 and divide by the microseconds passed since
1759
+ // the last entry
1760
+
1761
+ // if the new is smaller than the old (an overflow, or reset), set the old equal to the new
1762
+ // to reset the calculation (it will give zero as the calculation for this second)
1763
+ if(rd->last_collected_value > rd->collected_value) rd->last_collected_value = rd->collected_value;
1764
+
1765
+ rd->calculated_value = (calculated_number)(rd->collected_value - rd->last_collected_value);
1766
+
1767
+ if(st->debug)
1768
+ debug(D_RRD_STATS, "%s/%s: CALC "
1769
+ CALCULATED_NUMBER_FORMAT " = "
1770
+ COLLECTED_NUMBER_FORMAT " - " COLLECTED_NUMBER_FORMAT
1771
+ , st->id, rd->name
1772
+ , rd->calculated_value
1773
+ , rd->collected_value, rd->last_collected_value
1774
+ );
1775
+ break;
1776
+
1777
case RRD_DIMENSION_ABSOLUTE:
1778
+ case RRD_DIMENSION_ABSOLUTE_NO_INTERPOLATION:
1779
rd->calculated_value = (calculated_number)rd->collected_value;
1780
1781
if(st->debug)
@@ -1776,13 +1810,44 @@ unsigned long long rrd_stats_done(RRD_STATS *st)
1810
st->last_updated.tv_usec = 0;
1811
1812
for( rd = st->dimensions ; rd ; rd = rd->next ) {
1779
- rd->calculated_value = (calculated_number)
1780
- ( ( (rd->calculated_value - rd->last_calculated_value)
1781
- * (calculated_number)np
1782
- / (calculated_number)(now_ut - last_ut)
1783
- )
1784
- + rd->last_calculated_value
1785
- );
1813
+ calculated_number old_calculated_value = rd->calculated_value;
1814
+
1815
+ switch(rd->algorithm) {
1816
+ case RRD_DIMENSION_ABSOLUTE_NO_INTERPOLATION:
1817
+ case RRD_DIMENSION_INCREMENTAL_NO_INTERPOLATION:
1818
+ rd->calculated_value = rd->last_calculated_value;
1819
+ if(st->debug)
1820
+ debug(D_RRD_STATS, "%s/%s: CALC2 "
1821
+ CALCULATED_NUMBER_FORMAT " = " CALCULATED_NUMBER_FORMAT
1822
+ , st->id, rd->name
1823
+ , rd->calculated_value
1824
+ , rd->last_calculated_value
1825
+ );
1826
+ ;;
1827
+
1828
+ default:
1829
+ rd->calculated_value = (calculated_number)
1830
+ ( ( (rd->calculated_value - rd->last_calculated_value)
1831
+ * (calculated_number)np
1832
+ / (calculated_number)(now_ut - last_ut)
1833
+ )
1834
+ + rd->last_calculated_value
1835
+ );
1836
+
1837
+ if(st->debug)
1838
+ debug(D_RRD_STATS, "%s/%s: CALC2 "
1839
+ CALCULATED_NUMBER_FORMAT " = ((("
1840
+ "(" CALCULATED_NUMBER_FORMAT " - " CALCULATED_NUMBER_FORMAT ")"
1841
+ " * %llu"
1842
+ " / %llu) + " CALCULATED_NUMBER_FORMAT
1843
+ , st->id, rd->name
1844
+ , rd->calculated_value
1845
+ , old_calculated_value, rd->last_calculated_value
1846
+ , np
1847
+ , (now_ut - last_ut), rd->last_calculated_value
1848
+ );
1849
+ ;;
1850
+ }
1851
1852
rd->values[st->current_entry] = (storage_number)
1853
( rd->calculated_value
@@ -1793,24 +1858,26 @@ unsigned long long rrd_stats_done(RRD_STATS *st)
1858
1859
if(st->debug)
1860
debug(D_RRD_STATS, "%s/%s: STORE[%ld] "
1796
- STORAGE_NUMBER_FORMAT " = ((("
1797
- "(" CALCULATED_NUMBER_FORMAT " - " CALCULATED_NUMBER_FORMAT ")"
1798
- " * %llu"
1799
- " / %llu) + " CALCULATED_NUMBER_FORMAT
1861
+ STORAGE_NUMBER_FORMAT " = " CALCULATED_NUMBER_FORMAT
1862
" * 10 "
1863
" * %ld"
1864
" / %ld"
1865
, st->id, rd->name
1866
, st->current_entry
1867
, rd->values[st->current_entry]
1806
- , rd->calculated_value, rd->last_calculated_value
1807
- , np
1808
- , (now_ut - last_ut), rd->last_calculated_value
1868
+ , rd->last_calculated_value
1869
, rd->multiplier
1870
, rd->divisor
1871
);
1872
1873
rd->last_calculated_value = rd->calculated_value;
1874
+
1875
+ if(rd->algorithm == RRD_DIMENSION_ABSOLUTE_NO_INTERPOLATION || rd->algorithm == RRD_DIMENSION_ABSOLUTE_NO_INTERPOLATION) {
1876
+ if(next_ut + st->update_every * 1000000ULL >= now_ut) {
1877
+ //FIXME
1878
+ ;
1879
+ }
1880
+ }
1881
}
1882
1883
if(st->first_entry_t && st->counter >= (unsigned long long)st->entries) {
@@ -4846,7 +4913,7 @@ int do_proc_net_stat_conntrack() {
4913
if(!st) {
4914
st = rrd_stats_create(RRD_TYPE_NET_STAT_CONNTRACK, "sockets", NULL, RRD_TYPE_NET_STAT_CONNTRACK, "Netfilter Connections", "active connections", 1000, update_every, CHART_TYPE_LINE);
4915
4849
- rrd_stats_dimension_add(st, "connections", NULL, 1, 1, RRD_DIMENSION_ABSOLUTE);
4916
+ rrd_stats_dimension_add(st, "connections", NULL, 1, 1, RRD_DIMENSION_ABSOLUTE_NO_INTERPOLATION);
4917
}
4918
else rrd_stats_next(st);
4919
@@ -4861,9 +4928,9 @@ int do_proc_net_stat_conntrack() {
4928
if(!st) {
4929
st = rrd_stats_create(RRD_TYPE_NET_STAT_CONNTRACK, "new", NULL, RRD_TYPE_NET_STAT_CONNTRACK, "Netfilter New Connections", "connections/s", 1001, update_every, CHART_TYPE_LINE);
4930
4864
- rrd_stats_dimension_add(st, "new", NULL, 1, 1, RRD_DIMENSION_INCREMENTAL);
4865
- rrd_stats_dimension_add(st, "ignore", NULL, -1, 1, RRD_DIMENSION_INCREMENTAL);
4866
- rrd_stats_dimension_add(st, "invalid", NULL, -1, 1, RRD_DIMENSION_INCREMENTAL);
4931
+ rrd_stats_dimension_add(st, "new", NULL, 1, 1, RRD_DIMENSION_INCREMENTAL_NO_INTERPOLATION);
4932
+ rrd_stats_dimension_add(st, "ignore", NULL, -1, 1, RRD_DIMENSION_INCREMENTAL_NO_INTERPOLATION);
4933
+ rrd_stats_dimension_add(st, "invalid", NULL, -1, 1, RRD_DIMENSION_INCREMENTAL_NO_INTERPOLATION);
4934
}
4935
else rrd_stats_next(st);
4936
@@ -4881,9 +4948,9 @@ int do_proc_net_stat_conntrack() {
4948
st = rrd_stats_create(RRD_TYPE_NET_STAT_CONNTRACK, "changes", NULL, RRD_TYPE_NET_STAT_CONNTRACK, "Netfilter Connection Changes", "changes/s", 1002, update_every, CHART_TYPE_LINE);
4949
st->isdetail = 1;
4950
4884
- rrd_stats_dimension_add(st, "inserted", NULL, 1, 1, RRD_DIMENSION_INCREMENTAL);
4885
- rrd_stats_dimension_add(st, "deleted", NULL, -1, 1, RRD_DIMENSION_INCREMENTAL);
4886
- rrd_stats_dimension_add(st, "delete_list", NULL, -1, 1, RRD_DIMENSION_INCREMENTAL);
4951
+ rrd_stats_dimension_add(st, "inserted", NULL, 1, 1, RRD_DIMENSION_INCREMENTAL_NO_INTERPOLATION);
4952
+ rrd_stats_dimension_add(st, "deleted", NULL, -1, 1, RRD_DIMENSION_INCREMENTAL_NO_INTERPOLATION);
4953
+ rrd_stats_dimension_add(st, "delete_list", NULL, -1, 1, RRD_DIMENSION_INCREMENTAL_NO_INTERPOLATION);
4954
}
4955
else rrd_stats_next(st);
4956
@@ -4901,9 +4968,9 @@ int do_proc_net_stat_conntrack() {
4968
st = rrd_stats_create(RRD_TYPE_NET_STAT_CONNTRACK, "expect", NULL, RRD_TYPE_NET_STAT_CONNTRACK, "Netfilter Connection Expectations", "expectations/s", 1003, update_every, CHART_TYPE_LINE);
4969
st->isdetail = 1;
4970
4904
- rrd_stats_dimension_add(st, "created", NULL, 1, 1, RRD_DIMENSION_INCREMENTAL);
4905
- rrd_stats_dimension_add(st, "deleted", NULL, -1, 1, RRD_DIMENSION_INCREMENTAL);
4906
- rrd_stats_dimension_add(st, "new", NULL, 1, 1, RRD_DIMENSION_INCREMENTAL);
4971
+ rrd_stats_dimension_add(st, "created", NULL, 1, 1, RRD_DIMENSION_INCREMENTAL_NO_INTERPOLATION);
4972
+ rrd_stats_dimension_add(st, "deleted", NULL, -1, 1, RRD_DIMENSION_INCREMENTAL_NO_INTERPOLATION);
4973
+ rrd_stats_dimension_add(st, "new", NULL, 1, 1, RRD_DIMENSION_INCREMENTAL_NO_INTERPOLATION);
4974
}
4975
else rrd_stats_next(st);
4976
@@ -4921,9 +4988,9 @@ int do_proc_net_stat_conntrack() {
4988
st = rrd_stats_create(RRD_TYPE_NET_STAT_CONNTRACK, "search", NULL, RRD_TYPE_NET_STAT_CONNTRACK, "Netfilter Connection Searches", "searches/s", 1010, update_every, CHART_TYPE_LINE);
4989
st->isdetail = 1;
4990
4924
- rrd_stats_dimension_add(st, "searched", NULL, 1, 1, RRD_DIMENSION_INCREMENTAL);
4925
- rrd_stats_dimension_add(st, "restarted", NULL, -1, 1, RRD_DIMENSION_INCREMENTAL);
4926
- rrd_stats_dimension_add(st, "found", NULL, 1, 1, RRD_DIMENSION_INCREMENTAL);
4991
+ rrd_stats_dimension_add(st, "searched", NULL, 1, 1, RRD_DIMENSION_INCREMENTAL_NO_INTERPOLATION);
4992
+ rrd_stats_dimension_add(st, "restarted", NULL, -1, 1, RRD_DIMENSION_INCREMENTAL_NO_INTERPOLATION);
4993
+ rrd_stats_dimension_add(st, "found", NULL, 1, 1, RRD_DIMENSION_INCREMENTAL_NO_INTERPOLATION);
4994
}
4995
else rrd_stats_next(st);
4996
@@ -4941,10 +5008,10 @@ int do_proc_net_stat_conntrack() {
5008
st = rrd_stats_create(RRD_TYPE_NET_STAT_CONNTRACK, "errors", NULL, RRD_TYPE_NET_STAT_CONNTRACK, "Netfilter Errors", "events/s", 1005, update_every, CHART_TYPE_LINE);
5009
st->isdetail = 1;
5010
4944
- rrd_stats_dimension_add(st, "icmp_error", NULL, 1, 1, RRD_DIMENSION_INCREMENTAL);
4945
- rrd_stats_dimension_add(st, "insert_failed", NULL, -1, 1, RRD_DIMENSION_INCREMENTAL);
4946
- rrd_stats_dimension_add(st, "drop", NULL, -1, 1, RRD_DIMENSION_INCREMENTAL);
4947
- rrd_stats_dimension_add(st, "early_drop", NULL, -1, 1, RRD_DIMENSION_INCREMENTAL);
5011
+ rrd_stats_dimension_add(st, "icmp_error", NULL, 1, 1, RRD_DIMENSION_INCREMENTAL_NO_INTERPOLATION);
5012
+ rrd_stats_dimension_add(st, "insert_failed", NULL, -1, 1, RRD_DIMENSION_INCREMENTAL_NO_INTERPOLATION);
5013
+ rrd_stats_dimension_add(st, "drop", NULL, -1, 1, RRD_DIMENSION_INCREMENTAL_NO_INTERPOLATION);
5014
+ rrd_stats_dimension_add(st, "early_drop", NULL, -1, 1, RRD_DIMENSION_INCREMENTAL_NO_INTERPOLATION);
5015
}
5016
else rrd_stats_next(st);
5017
@@ -5016,7 +5083,7 @@ int do_proc_net_ip_vs_stats() {
5083
if(!st) {
5084
st = rrd_stats_create(RRD_TYPE_NET_IPVS, "sockets", NULL, RRD_TYPE_NET_IPVS, "IPVS New Connections", "connections/s", 1001, update_every, CHART_TYPE_LINE);
5085
5019
- rrd_stats_dimension_add(st, "connections", NULL, 1, 1, RRD_DIMENSION_INCREMENTAL);
5086
+ rrd_stats_dimension_add(st, "connections", NULL, 1, 1, RRD_DIMENSION_INCREMENTAL_NO_INTERPOLATION);
5087
}
5088
else rrd_stats_next(st);
5089
@@ -5031,8 +5098,8 @@ int do_proc_net_ip_vs_stats() {
5098
if(!st) {
5099
st = rrd_stats_create(RRD_TYPE_NET_IPVS, "packets", NULL, RRD_TYPE_NET_IPVS, "IPVS Packets", "packets/s", 1002, update_every, CHART_TYPE_LINE);
5100
5034
- rrd_stats_dimension_add(st, "received", NULL, 1, 1, RRD_DIMENSION_INCREMENTAL);
5035
- rrd_stats_dimension_add(st, "sent", NULL, -1, 1, RRD_DIMENSION_INCREMENTAL);
5101
+ rrd_stats_dimension_add(st, "received", NULL, 1, 1, RRD_DIMENSION_INCREMENTAL_NO_INTERPOLATION);
5102
+ rrd_stats_dimension_add(st, "sent", NULL, -1, 1, RRD_DIMENSION_INCREMENTAL_NO_INTERPOLATION);
5103
}
5104
else rrd_stats_next(st);
5105
@@ -5160,7 +5227,7 @@ int do_proc_stat() {
5227
st = rrd_stats_create("system", id, NULL, "cpu", "CPU Interrupts", "interrupts/s", 900, update_every, CHART_TYPE_LINE);
5228
st->isdetail = 1;
5229
5163
- rrd_stats_dimension_add(st, "interrupts", NULL, 1, 1, RRD_DIMENSION_INCREMENTAL);
5230
+ rrd_stats_dimension_add(st, "interrupts", NULL, 1, 1, RRD_DIMENSION_INCREMENTAL_NO_INTERPOLATION);
5231
}
5232
else rrd_stats_next(st);
5233
@@ -5184,7 +5251,7 @@ int do_proc_stat() {
5251
if(!st) {
5252
st = rrd_stats_create("system", id, NULL, "cpu", "CPU Context Switches", "context switches/s", 800, update_every, CHART_TYPE_LINE);
5253
5187
- rrd_stats_dimension_add(st, "switches", NULL, 1, 1, RRD_DIMENSION_INCREMENTAL);
5254
+ rrd_stats_dimension_add(st, "switches", NULL, 1, 1, RRD_DIMENSION_INCREMENTAL_NO_INTERPOLATION);
5255
}
5256
else rrd_stats_next(st);
5257
@@ -5236,7 +5303,7 @@ int do_proc_stat() {
5303
st = rrd_stats_create("system", "forks", NULL, "cpu", "New Processes", "processes/s", 700, update_every, CHART_TYPE_LINE);
5304
st->isdetail = 1;
5305
5239
- rrd_stats_dimension_add(st, "started", NULL, 1, 1, RRD_DIMENSION_INCREMENTAL);
5306
+ rrd_stats_dimension_add(st, "started", NULL, 1, 1, RRD_DIMENSION_INCREMENTAL_NO_INTERPOLATION);
5307
}
5308
else rrd_stats_next(st);
5309
@@ -5251,8 +5318,8 @@ int do_proc_stat() {
5318
if(!st) {
5319
st = rrd_stats_create("system", "processes", NULL, "cpu", "Processes", "processes", 600, update_every, CHART_TYPE_LINE);
5320
5254
- rrd_stats_dimension_add(st, "running", NULL, 1, 1, RRD_DIMENSION_ABSOLUTE);
5255
- rrd_stats_dimension_add(st, "blocked", NULL, -1, 1, RRD_DIMENSION_ABSOLUTE);
5321
+ rrd_stats_dimension_add(st, "running", NULL, 1, 1, RRD_DIMENSION_ABSOLUTE_NO_INTERPOLATION);
5322
+ rrd_stats_dimension_add(st, "blocked", NULL, -1, 1, RRD_DIMENSION_ABSOLUTE_NO_INTERPOLATION);
5323
}
5324
else rrd_stats_next(st);
5325
@@ -5791,7 +5858,7 @@ void *proc_main(void *ptr)
5858
if(!stclients) {
5859
stclients = rrd_stats_create("netdata", "clients", NULL, "netdata", "NetData Web Clients", "connected clients", 11000, update_every, CHART_TYPE_LINE);
5860
5794
- rrd_stats_dimension_add(stclients, "clients", NULL, 1, 1, RRD_DIMENSION_ABSOLUTE);
5861
+ rrd_stats_dimension_add(stclients, "clients", NULL, 1, 1, RRD_DIMENSION_ABSOLUTE_NO_INTERPOLATION);
5862
}
5863
else rrd_stats_next(stclients);
5864
@@ -5804,7 +5871,7 @@ void *proc_main(void *ptr)
5871
if(!streqs) {
5872
streqs = rrd_stats_create("netdata", "requests", NULL, "netdata", "NetData Web Requests", "requests/s", 12000, update_every, CHART_TYPE_LINE);
5873
5807
- rrd_stats_dimension_add(streqs, "requests", NULL, 1, 1, RRD_DIMENSION_INCREMENTAL);
5874
+ rrd_stats_dimension_add(streqs, "requests", NULL, 1, 1, RRD_DIMENSION_INCREMENTAL_NO_INTERPOLATION);
5875
}
5876
else rrd_stats_next(streqs);
5877