@cryptotaxi247 / netdata-1 / commits / 0f80f8b9f

cleanup propriatery charts.d charts; proc_stat optimization; minor fixes for not updated dimensions in rrd.c

Costa Tsaousis (ktsaou) committed Jul 4, 2016 at 22:41 UTC 0f80f8b9f850cc5bbb6669aa7d71f8b43e4614d4
4 files changed +102 -320
charts.d/airsearches.chart.sh deleted
-91
@@ -1,91 +0,0 @@
1 -#!/bin/sh
2 -
3 -airsearches_url=
4 -airsearches_cmds=
5 -airsearches_update_every=15
6 -
7 -airsearches_get() {
8 - wget 2>/dev/null -O - "$airsearches_url" |\
9 - sed -e "s|<br />|\n|g" -e "s|: |=|g" -e "s| \+|_|g" -e "s/^/airsearches_/g" |\
10 - tr "[A-Z]\.\!@#\$%^&*()_+\-" "[a-z]_____________" |\
11 - egrep "^airsearches_[a-z0-9_]+=[0-9]+$"
12 -}
13 -
14 -airsearches_check() {
15 - # make sure we have all the commands we need
16 - require_cmd wget || return 1
17 -
18 - # make sure we are configured
19 - if [ -z "$airsearches_url" ]
20 - then
21 - echo >&2 "$PROGRAM_NAME: airsearches: not configured. Please set airsearches_url='url' in $confd/airsearches.conf"
22 - return 1
23 - fi
24 -
25 - # check once if the url works
26 - wget 2>/dev/null -O /dev/null "$airsearches_url"
27 - if [ ! $? -eq 0 ]
28 - then
29 - echo >&2 "$PROGRAM_NAME: airsearches: cannot fetch the url: $airsearches_url. Please set airsearches_url='url' in $confd/airsearches.conf"
30 - return 1
31 - fi
32 -
33 - # if the admin did not give any commands
34 - # find the available ones
35 - if [ -z "$airsearches_cmds" ]
36 - then
37 - airsearches_cmds="$(airsearches_get | cut -d '=' -f 1 | sed "s/^airsearches_//g" | sort -u)"
38 - echo
39 - fi
40 -
41 - # did we find any commands?
42 - if [ -z "$airsearches_cmds" ]
43 - then
44 - echo >&2 "$PROGRAM_NAME: airsearches: cannot find command list automatically. Please set airsearches_cmds='...' in $confd/airsearches.conf"
45 - return 1
46 - fi
47 -
48 - # ok we can do it
49 - return 0
50 -}
51 -
52 -airsearches_create() {
53 - [ -z "$airsearches_cmds" ] && return 1
54 -
55 - # create the charts
56 - local x=
57 - echo "CHART airsearches.affiliates '' 'Air Searches per affiliate' 'requests / min' airsearches '' stacked 20000 $airsearches_update_every"
58 - for x in $airsearches_cmds
59 - do
60 - echo "DIMENSION $x '' incremental 60 1"
61 - done
62 -
63 - return 0
64 -}
65 -
66 -airsearches_update() {
67 - # the first argument to this function is the microseconds since last update
68 - # pass this parameter to the BEGIN statement (see bellow).
69 -
70 - # do all the work to collect / calculate the values
71 - # for each dimension
72 - # remember: KEEP IT SIMPLE AND SHORT
73 -
74 - # get the values from airsearches
75 - eval "$(airsearches_get)"
76 -
77 - # write the result of the work.
78 - local x=
79 -
80 - echo "BEGIN airsearches.affiliates $1"
81 - for x in $airsearches_cmds
82 - do
83 - eval "v=\$airsearches_$x"
84 - echo "SET $x = $v"
85 - done
86 - echo "END"
87 -
88 - airsearches_dt=0
89 -
90 - return 0
91 -}
charts.d/crsproxy.chart.sh deleted
-151
@@ -1,151 +0,0 @@
1 -#!/bin/sh
2 -
3 -crsproxy_url=
4 -crsproxy_cmds=
5 -crsproxy_update_every=15
6 -
7 -crsproxy_get() {
8 - wget 2>/dev/null -O - "$crsproxy_url" |\
9 - sed \
10 - -e "s/ \+/ /g" \
11 - -e "s/\./_/g" \
12 - -e "s/ =/=/g" \
13 - -e "s/= /=/g" \
14 - -e "s/^/crsproxy_/g" |\
15 - egrep "^crsproxy_[a-zA-Z][a-zA-Z0-9_]*=[0-9]+$"
16 -}
17 -
18 -crsproxy_check() {
19 - # make sure we have all the commands we need
20 - require_cmd wget || return 1
21 -
22 - if [ -z "$crsproxy_url" ]
23 - then
24 - echo >&2 "$PROGRAM_NAME: crsproxy: not configured. Please set crsproxy_url='url' in $confd/crsproxy.conf"
25 - return 1
26 - fi
27 -
28 - # check once if the url works
29 - wget 2>/dev/null -O /dev/null "$crsproxy_url"
30 - if [ ! $? -eq 0 ]
31 - then
32 - echo >&2 "$PROGRAM_NAME: crsproxy: cannot fetch the url: $crsproxy_url. Please set crsproxy_url='url' in $confd/crsproxy.conf"
33 - return 1
34 - fi
35 -
36 - # if the user did not request specific commands
37 - # find the commands available
38 - if [ -z "$crsproxy_cmds" ]
39 - then
40 - crsproxy_cmds="$(crsproxy_get | cut -d '=' -f 1 | sed "s/^crsproxy_cmd_//g" | sort -u)"
41 - fi
42 -
43 - # if no commands are available
44 - if [ -z "$crsproxy_cmds" ]
45 - then
46 - echo >&2 "$PROGRAM_NAME: crsproxy: cannot find command list automatically. Please set crsproxy_cmds='...' in $confd/crsproxy.conf"
47 - return 1
48 - fi
49 - return 0
50 -}
51 -
52 -crsproxy_create() {
53 - # create the charts
54 - cat <<EOF
55 -CHART crsproxy.connected '' "CRS Proxy Connected Clients" "clients" crsproxy '' line 20000 $crsproxy_update_every
56 -DIMENSION web '' absolute 1 1
57 -DIMENSION native '' absolute 1 1
58 -DIMENSION virtual '' absolute 1 1
59 -CHART crsproxy.requests '' "CRS Proxy Requests Rate" "requests / min" crsproxy '' area 20001 $crsproxy_update_every
60 -DIMENSION web '' incremental 60 1
61 -DIMENSION native '' incremental -60 1
62 -CHART crsproxy.clients '' "CRS Proxy Clients Rate" "clients / min" crsproxy '' area 20010 $crsproxy_update_every
63 -DIMENSION web '' incremental 60 1
64 -DIMENSION native '' incremental -60 1
65 -DIMENSION virtual '' incremental 60 1
66 -CHART crsproxy.replies '' "CRS Replies Rate" "replies / min" crsproxy '' area 20020 $crsproxy_update_every
67 -DIMENSION ok '' incremental 60 1
68 -DIMENSION failed '' incremental -60 1
69 -CHART crsproxy.bconnections '' "Back-End Connections Rate" "connections / min" crsproxy '' area 20030 $crsproxy_update_every
70 -DIMENSION ok '' incremental 60 1
71 -DIMENSION failed '' incremental -60 1
72 -EOF
73 -
74 - local x=
75 - echo "CHART crsproxy.commands '' 'CRS Commands Requests' 'requests / min' crsproxy '' stacked 20100 $crsproxy_update_every"
76 - for x in $crsproxy_cmds
77 - do
78 - echo "DIMENSION $x '' incremental 60 $crsproxy_update_every"
79 - done
80 -
81 - echo "CHART crsproxy.commands_failed '' 'CRS Failed Commands' 'replies / min' crsproxy '' stacked 20110 $crsproxy_update_every"
82 - for x in $crsproxy_cmds
83 - do
84 - echo "DIMENSION $x '' incremental 60 $crsproxy_update_every"
85 - done
86 -
87 - return 0
88 -}
89 -
90 -
91 -crsproxy_update() {
92 - # the first argument to this function is the microseconds since last update
93 - # pass this parameter to the BEGIN statement (see bellow).
94 -
95 - # do all the work to collect / calculate the values
96 - # for each dimension
97 - # remember: KEEP IT SIMPLE AND SHORT
98 -
99 - # get the values from crsproxy
100 - eval "$(crsproxy_get)"
101 -
102 -
103 - # write the result of the work.
104 - cat <<VALUESEOF
105 -BEGIN crsproxy.connected $1
106 -SET web = $((crsproxy_web_clients_opened - crsproxy_web_clients_closed))
107 -SET native = $((crsproxy_crs_clients_opened - crsproxy_crs_clients_closed))
108 -SET virtual = $((crsproxy_virtual_clients_opened - crsproxy_virtual_clients_closed))
109 -END
110 -BEGIN crsproxy.requests $1
111 -SET web = $crsproxy_web_requests
112 -SET native = $crsproxy_native_requests
113 -END
114 -BEGIN crsproxy.clients $1
115 -SET web = $crsproxy_web_clients_opened
116 -SET native = $crsproxy_crs_clients_opened
117 -SET virtual = $crsproxy_virtual_clients_opened
118 -END
119 -BEGIN crsproxy.replies $1
120 -SET ok = $crsproxy_replies_success
121 -SET failed = $crsproxy_replies_error
122 -END
123 -BEGIN crsproxy.bconnections $1
124 -SET ok = $crsproxy_connections_nonblocking_established
125 -SET failed = $crsproxy_connections_nonblocking_failed
126 -END
127 -VALUESEOF
128 -
129 - local native_requests="_native_requests"
130 - local web_requests="_web_requests"
131 - local replies_error="_replies_error"
132 - local x=
133 -
134 - echo "BEGIN crsproxy.commands $1"
135 - for x in $crsproxy_cmds
136 - do
137 - eval "v=\$(( crsproxy_cmd_$x$native_requests + crsproxy_cmd_$x$web_requests ))"
138 - echo "SET $x = $v"
139 - done
140 - echo "END"
141 -
142 - echo "BEGIN crsproxy.commands_failed $1"
143 - for x in $crsproxy_cmds
144 - do
145 - eval "v=\$crsproxy_cmd_$x$replies_error"
146 - echo "SET $x = $v"
147 - done
148 - echo "END"
149 -
150 - return 0
151 -}
src/proc_stat.c
+57 -42
@@ -12,31 +12,37 @@
12 #include "rrd.h"
13 #include "plugin_proc.h"
14
15 -#define RRD_TYPE_STAT "cpu"
16 -#define RRD_TYPE_STAT_LEN strlen(RRD_TYPE_STAT)
17 -
15 int do_proc_stat(int update_every, unsigned long long dt) {
16 + (void)dt;
17 +
18 static procfile *ff = NULL;
19 static int do_cpu = -1, do_cpu_cores = -1, do_interrupts = -1, do_context = -1, do_forks = -1, do_processes = -1;
20 + static uint32_t hash_intr, hash_ctxt, hash_processes, hash_procs_running, hash_procs_blocked;
21 +
22 + if(unlikely(do_cpu == -1)) {
23 + do_cpu = config_get_boolean("plugin:proc:/proc/stat", "cpu utilization", 1);
24 + do_cpu_cores = config_get_boolean("plugin:proc:/proc/stat", "per cpu core utilization", 1);
25 + do_interrupts = config_get_boolean("plugin:proc:/proc/stat", "cpu interrupts", 1);
26 + do_context = config_get_boolean("plugin:proc:/proc/stat", "context switches", 1);
27 + do_forks = config_get_boolean("plugin:proc:/proc/stat", "processes started", 1);
28 + do_processes = config_get_boolean("plugin:proc:/proc/stat", "processes running", 1);
29 +
30 + hash_intr = simple_hash("intr");
31 + hash_ctxt = simple_hash("ctxt");
32 + hash_processes = simple_hash("processes");
33 + hash_procs_running = simple_hash("procs_running");
34 + hash_procs_blocked = simple_hash("procs_blocked");
35 + }
36
22 - if(do_cpu == -1) do_cpu = config_get_boolean("plugin:proc:/proc/stat", "cpu utilization", 1);
23 - if(do_cpu_cores == -1) do_cpu_cores = config_get_boolean("plugin:proc:/proc/stat", "per cpu core utilization", 1);
24 - if(do_interrupts == -1) do_interrupts = config_get_boolean("plugin:proc:/proc/stat", "cpu interrupts", 1);
25 - if(do_context == -1) do_context = config_get_boolean("plugin:proc:/proc/stat", "context switches", 1);
26 - if(do_forks == -1) do_forks = config_get_boolean("plugin:proc:/proc/stat", "processes started", 1);
27 - if(do_processes == -1) do_processes = config_get_boolean("plugin:proc:/proc/stat", "processes running", 1);
28 -
29 - if(dt) {};
30 -
31 - if(!ff) {
37 + if(unlikely(!ff)) {
38 char filename[FILENAME_MAX + 1];
39 snprintfz(filename, FILENAME_MAX, "%s%s", global_host_prefix, "/proc/stat");
40 ff = procfile_open(config_get("plugin:proc:/proc/stat", "filename to monitor", filename), " \t:", PROCFILE_FLAG_DEFAULT);
41 + if(unlikely(!ff)) return 1;
42 }
36 - if(!ff) return 1;
43
44 ff = procfile_readall(ff);
39 - if(!ff) return 0; // we return 0, so that we will retry to open it next time
45 + if(unlikely(!ff)) return 0; // we return 0, so that we will retry to open it next time
46
47 uint32_t lines = procfile_lines(ff), l;
48 uint32_t words;
@@ -45,9 +51,13 @@ int do_proc_stat(int update_every, unsigned long long dt) {
51 RRDSET *st;
52
53 for(l = 0; l < lines ;l++) {
48 - if(strncmp(procfile_lineword(ff, l, 0), "cpu", 3) == 0) {
54 + char *row_key = procfile_lineword(ff, l, 0);
55 + uint32_t hash = simple_hash(row_key);
56 +
57 + // faster strncmp(row_key, "cpu", 3) == 0
58 + if(likely(row_key[0] == 'c' && row_key[1] == 'p' && row_key[2] == 'u')) {
59 words = procfile_linewords(ff, l);
50 - if(words < 9) {
60 + if(unlikely(words < 9)) {
61 error("Cannot read /proc/stat cpu line. Expected 9 params, read %u.", words);
62 continue;
63 }
@@ -55,7 +65,7 @@ int do_proc_stat(int update_every, unsigned long long dt) {
65 char *id;
66 unsigned long long user = 0, nice = 0, system = 0, idle = 0, iowait = 0, irq = 0, softirq = 0, steal = 0, guest = 0, guest_nice = 0;
67
58 - id = procfile_lineword(ff, l, 0);
68 + id = row_key;
69 user = strtoull(procfile_lineword(ff, l, 1), NULL, 10);
70 nice = strtoull(procfile_lineword(ff, l, 2), NULL, 10);
71 system = strtoull(procfile_lineword(ff, l, 3), NULL, 10);
@@ -67,25 +77,30 @@ int do_proc_stat(int update_every, unsigned long long dt) {
77 if(words >= 10) guest = strtoull(procfile_lineword(ff, l, 9), NULL, 10);
78 if(words >= 11) guest_nice = strtoull(procfile_lineword(ff, l, 10), NULL, 10);
79
70 - char *title = "Core utilization";
71 - char *type = RRD_TYPE_STAT;
72 - char *context = "cpu.cpu";
73 - char *family = "utilization";
74 - long priority = 1000;
75 - int isthistotal = 0;
80 + char *title, *type, *context, *family;
81 + long priority;
82 + int isthistotal;
83
77 - if(strcmp(id, "cpu") == 0) {
78 - isthistotal = 1;
79 - type = "system";
84 + if(unlikely(strcmp(id, "cpu")) == 0) {
85 title = "Total CPU utilization";
86 + type = "system";
87 context = "system.cpu";
88 family = id;
89 priority = 100;
90 + isthistotal = 1;
91 + }
92 + else {
93 + title = "Core utilization";
94 + type = "cpu";
95 + context = "cpu.cpu";
96 + family = "utilization";
97 + priority = 1000;
98 + isthistotal = 0;
99 }
100
86 - if((isthistotal && do_cpu) || (!isthistotal && do_cpu_cores)) {
101 + if(likely((isthistotal && do_cpu) || (!isthistotal && do_cpu_cores))) {
102 st = rrdset_find_bytype(type, id);
88 - if(!st) {
103 + if(unlikely(!st)) {
104 st = rrdset_create(type, id, NULL, family, context, title, "percentage", priority, update_every, RRDSET_TYPE_STACKED);
105
106 long multiplier = 1;
@@ -119,14 +134,14 @@ int do_proc_stat(int update_every, unsigned long long dt) {
134 rrdset_done(st);
135 }
136 }
122 - else if(strcmp(procfile_lineword(ff, l, 0), "intr") == 0) {
137 + else if(hash == hash_intr && strcmp(row_key, "intr") == 0) {
138 unsigned long long value = strtoull(procfile_lineword(ff, l, 1), NULL, 10);
139
140 // --------------------------------------------------------------------
141
127 - if(do_interrupts) {
142 + if(likely(do_interrupts)) {
143 st = rrdset_find_bytype("system", "intr");
129 - if(!st) {
144 + if(unlikely(!st)) {
145 st = rrdset_create("system", "intr", NULL, "interrupts", NULL, "CPU Interrupts", "interrupts/s", 900, update_every, RRDSET_TYPE_LINE);
146 st->isdetail = 1;
147
@@ -138,14 +153,14 @@ int do_proc_stat(int update_every, unsigned long long dt) {
153 rrdset_done(st);
154 }
155 }
141 - else if(strcmp(procfile_lineword(ff, l, 0), "ctxt") == 0) {
156 + else if(hash == hash_ctxt && strcmp(row_key, "ctxt") == 0) {
157 unsigned long long value = strtoull(procfile_lineword(ff, l, 1), NULL, 10);
158
159 // --------------------------------------------------------------------
160
146 - if(do_context) {
161 + if(likely(do_context)) {
162 st = rrdset_find_bytype("system", "ctxt");
148 - if(!st) {
163 + if(unlikely(!st)) {
164 st = rrdset_create("system", "ctxt", NULL, "processes", NULL, "CPU Context Switches", "context switches/s", 800, update_every, RRDSET_TYPE_LINE);
165
166 rrddim_add(st, "switches", NULL, 1, 1, RRDDIM_INCREMENTAL);
@@ -156,22 +171,22 @@ int do_proc_stat(int update_every, unsigned long long dt) {
171 rrdset_done(st);
172 }
173 }
159 - else if(!processes && strcmp(procfile_lineword(ff, l, 0), "processes") == 0) {
174 + else if(hash == hash_processes && !processes && strcmp(row_key, "processes") == 0) {
175 processes = strtoull(procfile_lineword(ff, l, 1), NULL, 10);
176 }
162 - else if(!running && strcmp(procfile_lineword(ff, l, 0), "procs_running") == 0) {
177 + else if(hash == hash_procs_running && !running && strcmp(row_key, "procs_running") == 0) {
178 running = strtoull(procfile_lineword(ff, l, 1), NULL, 10);
179 }
165 - else if(!blocked && strcmp(procfile_lineword(ff, l, 0), "procs_blocked") == 0) {
180 + else if(hash == hash_procs_blocked && !blocked && strcmp(row_key, "procs_blocked") == 0) {
181 blocked = strtoull(procfile_lineword(ff, l, 1), NULL, 10);
182 }
183 }
184
185 // --------------------------------------------------------------------
186
172 - if(do_forks) {
187 + if(likely(do_forks)) {
188 st = rrdset_find_bytype("system", "forks");
174 - if(!st) {
189 + if(unlikely(!st)) {
190 st = rrdset_create("system", "forks", NULL, "processes", NULL, "Started Processes", "processes/s", 700, update_every, RRDSET_TYPE_LINE);
191 st->isdetail = 1;
192
@@ -185,9 +200,9 @@ int do_proc_stat(int update_every, unsigned long long dt) {
200
201 // --------------------------------------------------------------------
202
188 - if(do_processes) {
203 + if(likely(do_processes)) {
204 st = rrdset_find_bytype("system", "processes");
190 - if(!st) {
205 + if(unlikely(!st)) {
206 st = rrdset_create("system", "processes", NULL, "processes", NULL, "System Processes", "processes", 600, update_every, RRDSET_TYPE_LINE);
207
208 rrddim_add(st, "running", NULL, 1, 1, RRDDIM_ABSOLUTE);
src/rrd.c
+45 -36
@@ -920,7 +920,7 @@ unsigned long long rrdset_done(RRDSET *st)
920 int dimensions;
921 st->collected_total = 0;
922 for( rd = st->dimensions, dimensions = 0 ; likely(rd) ; rd = rd->next, dimensions++ )
923 - st->collected_total += rd->collected_value;
923 + if(likely(rd->updated)) st->collected_total += rd->collected_value;
924
925 uint32_t storage_flags = SN_EXISTS;
926
@@ -929,6 +929,11 @@ unsigned long long rrdset_done(RRDSET *st)
929 // at this stage we do not interpolate anything
930 for( rd = st->dimensions ; likely(rd) ; rd = rd->next ) {
931
932 + if(unlikely(!rd->updated)) {
933 + rd->calculated_value = 0;
934 + continue;
935 + }
936 +
937 if(unlikely(st->debug)) debug(D_RRD_STATS, "%s/%s: START "
938 " last_collected_value = " COLLECTED_NUMBER_FORMAT
939 " collected_value = " COLLECTED_NUMBER_FORMAT
@@ -942,34 +947,35 @@ unsigned long long rrdset_done(RRDSET *st)
947 );
948
949 switch(rd->algorithm) {
945 - case RRDDIM_ABSOLUTE:
946 - rd->calculated_value = (calculated_number)rd->collected_value
947 - * (calculated_number)rd->multiplier
948 - / (calculated_number)rd->divisor;
949 -
950 - if(unlikely(st->debug))
951 - debug(D_RRD_STATS, "%s/%s: CALC ABS/ABS-NO-IN "
952 - CALCULATED_NUMBER_FORMAT " = "
953 - COLLECTED_NUMBER_FORMAT
954 - " * " CALCULATED_NUMBER_FORMAT
955 - " / " CALCULATED_NUMBER_FORMAT
956 - , st->id, rd->name
957 - , rd->calculated_value
958 - , rd->collected_value
959 - , (calculated_number)rd->multiplier
960 - , (calculated_number)rd->divisor
961 - );
962 - break;
950 + case RRDDIM_ABSOLUTE:
951 + rd->calculated_value = (calculated_number)rd->collected_value
952 + * (calculated_number)rd->multiplier
953 + / (calculated_number)rd->divisor;
954 +
955 + if(unlikely(st->debug))
956 + debug(D_RRD_STATS, "%s/%s: CALC ABS/ABS-NO-IN "
957 + CALCULATED_NUMBER_FORMAT " = "
958 + COLLECTED_NUMBER_FORMAT
959 + " * " CALCULATED_NUMBER_FORMAT
960 + " / " CALCULATED_NUMBER_FORMAT
961 + , st->id, rd->name
962 + , rd->calculated_value
963 + , rd->collected_value
964 + , (calculated_number)rd->multiplier
965 + , (calculated_number)rd->divisor
966 + );
967 + break;
968
969 case RRDDIM_PCENT_OVER_ROW_TOTAL:
965 - if(unlikely(!st->collected_total)) rd->calculated_value = 0;
970 + if(unlikely(!st->collected_total))
971 + rd->calculated_value = 0;
972 else
967 - // the percentage of the current value
968 - // over the total of all dimensions
969 - rd->calculated_value =
970 - (calculated_number)100
971 - * (calculated_number)rd->collected_value
972 - / (calculated_number)st->collected_total;
973 + // the percentage of the current value
974 + // over the total of all dimensions
975 + rd->calculated_value =
976 + (calculated_number)100
977 + * (calculated_number)rd->collected_value
978 + / (calculated_number)st->collected_total;
979
980 if(unlikely(st->debug))
981 debug(D_RRD_STATS, "%s/%s: CALC PCENT-ROW "
@@ -984,7 +990,7 @@ unsigned long long rrdset_done(RRDSET *st)
990 break;
991
992 case RRDDIM_INCREMENTAL:
987 - if(unlikely(!rd->updated || rd->counter <= 1)) {
993 + if(unlikely(rd->counter <= 1)) {
994 rd->calculated_value = 0;
995 continue;
996 }
@@ -1000,9 +1006,10 @@ unsigned long long rrdset_done(RRDSET *st)
1006 rd->last_collected_value = rd->collected_value;
1007 }
1008
1003 - rd->calculated_value = (calculated_number)(rd->collected_value - rd->last_collected_value)
1004 - * (calculated_number)rd->multiplier
1005 - / (calculated_number)rd->divisor;
1009 + rd->calculated_value =
1010 + (calculated_number)(rd->collected_value - rd->last_collected_value)
1011 + * (calculated_number)rd->multiplier
1012 + / (calculated_number)rd->divisor;
1013
1014 if(unlikely(st->debug))
1015 debug(D_RRD_STATS, "%s/%s: CALC INC PRE "
@@ -1020,18 +1027,20 @@ unsigned long long rrdset_done(RRDSET *st)
1027 break;
1028
1029 case RRDDIM_PCENT_OVER_DIFF_TOTAL:
1023 - if(unlikely(!rd->updated || rd->counter <= 1)) {
1030 + if(unlikely(rd->counter <= 1)) {
1031 rd->calculated_value = 0;
1032 continue;
1033 }
1034
1035 // the percentage of the current increment
1036 // over the increment of all dimensions together
1030 - if(unlikely(st->collected_total == st->last_collected_total)) rd->calculated_value = rd->last_calculated_value;
1031 - else rd->calculated_value =
1032 - (calculated_number)100
1033 - * (calculated_number)(rd->collected_value - rd->last_collected_value)
1034 - / (calculated_number)(st->collected_total - st->last_collected_total);
1037 + if(unlikely(st->collected_total == st->last_collected_total))
1038 + rd->calculated_value = 0;
1039 + else
1040 + rd->calculated_value =
1041 + (calculated_number)100
1042 + * (calculated_number)(rd->collected_value - rd->last_collected_value)
1043 + / (calculated_number)(st->collected_total - st->last_collected_total);
1044
1045 if(unlikely(st->debug))
1046 debug(D_RRD_STATS, "%s/%s: CALC PCENT-DIFF "