a new random number needed for demo2.html
Costa Tsaousis (ktsaou) committed
Jan 16, 2016 at 21:09 UTC
f60e440d0a44a465aad35cf8546dbda52491b94f
1 file changed
+25
-1
charts.d/example.chart.sh
+25
-1
@@ -24,13 +24,19 @@ CHART example.random '' "Random Numbers Stacked Chart" "% of random numbers" ran
24
DIMENSION random1 '' percentage-of-absolute-row 1 1
25
DIMENSION random2 '' percentage-of-absolute-row 1 1
26
DIMENSION random3 '' percentage-of-absolute-row 1 1
27
+CHART example.random2 '' "A random number" "random number" random random area 5001 $example_update_every
28
+DIMENSION random '' absolute 1 1
29
EOF
30
31
return 0
32
}
33
34
# _update is called continiously, to collect the values
35
+example_last=0
36
+example_count=0
37
example_update() {
38
+ local value1 value2 value3 value4 mode
39
+
40
# the first argument to this function is the microseconds since last update
41
# pass this parameter to the BEGIN statement (see bellow).
42
@@ -41,6 +47,21 @@ example_update() {
47
value1=$RANDOM
48
value2=$RANDOM
49
value3=$RANDOM
50
+ value4=$[8192 + (RANDOM * 16383 / 32767) ]
51
+
52
+ if [ $example_count -gt 0 ]
53
+ then
54
+ example_count=$[example_count - 1]
55
+
56
+ [ $example_last -gt 16383 ] && value4=$[example_last + (RANDOM * ( (32767 - example_last) / 2) / 32767)]
57
+ [ $example_last -le 16383 ] && value4=$[example_last - (RANDOM * (example_last / 2) / 32767)]
58
+ else
59
+ example_count=$[1 + (RANDOM * 5 / 32767) ]
60
+
61
+ [ $example_last -gt 16383 -a $value4 -gt 16383 ] && value4=$[value4 - 16383]
62
+ [ $example_last -le 16383 -a $value4 -lt 16383 ] && value4=$[value4 + 16383]
63
+ fi
64
+ example_last=$value4
65
66
# write the result of the work.
67
cat <<VALUESEOF
@@ -49,8 +70,11 @@ SET random1 = $value1
70
SET random2 = $value2
71
SET random3 = $value3
72
END
73
+BEGIN example.random2 $1
74
+SET random = $value4
75
+END
76
VALUESEOF
77
+ # echo >&2 "example_count = $example_count value = $value4"
78
79
return 0
80
}
56
-