summaryrefslogtreecommitdiffstats
path: root/charts.d/example.chart.sh
diff options
context:
space:
mode:
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>2016-01-16 21:09:16 +0200
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>2016-01-16 21:09:16 +0200
commitf60e440d0a44a465aad35cf8546dbda52491b94f (patch)
tree3b97980769dc08f2707a5bb5d4c69fbead5a1b19 /charts.d/example.chart.sh
parentd7f9fbc761cc2385e0f6e865e510e87da0c8f197 (diff)
a new random number needed for demo2.html
Diffstat (limited to 'charts.d/example.chart.sh')
-rwxr-xr-xcharts.d/example.chart.sh26
1 files changed, 25 insertions, 1 deletions
diff --git a/charts.d/example.chart.sh b/charts.d/example.chart.sh
index aa1005d11a..7e07ccf47f 100755
--- a/charts.d/example.chart.sh
+++ b/charts.d/example.chart.sh
@@ -24,13 +24,19 @@ CHART example.random '' "Random Numbers Stacked Chart" "% of random numbers" ran
DIMENSION random1 '' percentage-of-absolute-row 1 1
DIMENSION random2 '' percentage-of-absolute-row 1 1
DIMENSION random3 '' percentage-of-absolute-row 1 1
+CHART example.random2 '' "A random number" "random number" random random area 5001 $example_update_every
+DIMENSION random '' absolute 1 1
EOF
return 0
}
# _update is called continiously, to collect the values
+example_last=0
+example_count=0
example_update() {
+ local value1 value2 value3 value4 mode
+
# the first argument to this function is the microseconds since last update
# pass this parameter to the BEGIN statement (see bellow).
@@ -41,6 +47,21 @@ example_update() {
value1=$RANDOM
value2=$RANDOM
value3=$RANDOM
+ value4=$[8192 + (RANDOM * 16383 / 32767) ]
+
+ if [ $example_count -gt 0 ]
+ then
+ example_count=$[example_count - 1]
+
+ [ $example_last -gt 16383 ] && value4=$[example_last + (RANDOM * ( (32767 - example_last) / 2) / 32767)]
+ [ $example_last -le 16383 ] && value4=$[example_last - (RANDOM * (example_last / 2) / 32767)]
+ else
+ example_count=$[1 + (RANDOM * 5 / 32767) ]
+
+ [ $example_last -gt 16383 -a $value4 -gt 16383 ] && value4=$[value4 - 16383]
+ [ $example_last -le 16383 -a $value4 -lt 16383 ] && value4=$[value4 + 16383]
+ fi
+ example_last=$value4
# write the result of the work.
cat <<VALUESEOF
@@ -49,8 +70,11 @@ SET random1 = $value1
SET random2 = $value2
SET random3 = $value3
END
+BEGIN example.random2 $1
+SET random = $value4
+END
VALUESEOF
+ # echo >&2 "example_count = $example_count value = $value4"
return 0
}
-