]> arthur.barton.de Git - netdata.git/commitdiff
documentation and fixed a rounding bug
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Tue, 29 Apr 2014 23:04:48 +0000 (02:04 +0300)
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Tue, 29 Apr 2014 23:04:48 +0000 (02:04 +0300)
charts.d/skeleton-chart.sh
netdata.c

index bdc37b636a777184771c059fd038c3034492ec0d..508fe3bb4ecdb61ed24096cc0151e7b35d576de1 100755 (executable)
@@ -19,8 +19,8 @@ echo "MYPID $$"
 
 # -----------------------------------------------------------------------------
 # create a new chart
-# > CHART type.chartname family[=chartname] homegroup[=type] charttype priority[=1000]
-# charttype = line or area or stacked
+# > CHART type.chartname family[=chartname] homegroup[=type] charttype[=line] priority[=1000] update_every[=user default]
+# charttype = line, area or stacked
 # homegroup = any name or the word 'none' which hides the chart from the home web page
 # 
 # set the chart title
@@ -29,11 +29,8 @@ echo "MYPID $$"
 # set the units of measurement
 # > UNITS my wonderfull unit
 #
-# you can overwrite the update frequency as you need
-# > UPDATE EVERY $update_every
-#
 # create all the dimensions you need
-# > DIMENSION CREATE dimensionname1 algorithm signed|unsigned byte|char|int|long|long long multiplier divisor [hidden]"
+# > DIMENSION CREATE dimensionname algorithm multiplier divisor [hidden]"
 #
 # algorithms:
 #   absolute
@@ -50,17 +47,38 @@ echo "MYPID $$"
 #     the % is drawn of this value compared to the differential total of
 #     each dimension
 #
-# number sizes:
-#   unsigned byte      = 1 byte  = 0 ...                        255
-#   unsigned int       = 2 bytes = 0 ...                     65.535
-#   unsigned long      = 4 bytes = 0 ...              4.294.967.295
-#   unsigned long long = 8 bytes = 0 ... 18.446.744.073.709.551.615
-#   
-#   signed values are from - to + the half of the above
+# A NOTE ABOUT VALUES
+# NetData will collect any signed value in the 64bit range:
+#
+#    -9.223.372.036.854.775.807   to   +9.223.372.036.854.775.807
+#
+# However, to lower its memory requirements, it stores all values in the
+# signed 32bit range, divided by 10, that is:
+#
+#                  -214.748.364   to    214.748.364
+#
+# This division by 10, is used to give you a decimal point in the charts.
+# In memory, every number is 4 bytes (32bits).
+#
+# To work with this without loosing detail, you should set the proper
+# algorithm of calculation, together with a multiplier and a divider.
+#
+# The algorithm is applied in the wider 64bit numbers. Once the calculation
+# is complete the value is multiplied by the multiplier, by 10, and then
+# divided by the divider (all of these at the 64bit level).
+# The 64bit result is then stored in a 32 bit signed int.
+#
+# So, at the chart level:
+#
+#  - the finest number is 0.1
+#  - the smallest -214.748.364,7
+#  - the highest   214.748.364,7
+#
+# You should choose a multiplier and divider to stay within these limits.
 #
 
 cat <<EOF
-CHART example.random ExampleGroup ExampleCategory stacked 1
+CHART example.random ExampleGroup ExampleCategory stacked 1 1
 TITLE Random Numbers Example Chart
 UNITS random numbers
 UPDATE EVERY $update_every
index 5b6785a5469a58f55e393e8a2a3753eefa4a1fc9..30d1a6f6c1f34a522b2ec0dddb22119fe9e418c6 100755 (executable)
--- a/netdata.c
+++ b/netdata.c
@@ -1044,10 +1044,10 @@ void rrd_stats_done(RRD_STATS *st)
                                        break;
                        }
 
-                       rd->calculated_value = rd->calculated_value * rd->multiplier / rd->divisor;
+                       rd->calculated_value = rd->calculated_value * 10 * rd->multiplier / rd->divisor;
 
                        // store the calculated value
-                       rd->values[st->current_entry] = rd->calculated_value * 10;
+                       rd->values[st->current_entry] = rd->calculated_value;
                }
 
                // store the time difference to the last entry