3 # if this chart is called X.chart.sh, then all functions and global variables
6 # _update_every is a special variable - it holds the number of seconds
7 # between the calls of the _update() function
10 # _check is called once, to find out if this chart should be enabled or not
13 # - 0 to enable the chart
14 # - 1 to disable the chart
19 # _create is called once, to create the charts
21 # create the chart with 3 dimensions
23 CHART example.random '' "Random Numbers Stacked Chart" "% of random numbers" random random stacked 5000 $example_update_every
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
34 # _update is called continiously, to collect the values
38 local value1 value2 value3 value4 mode
40 # the first argument to this function is the microseconds since last update
41 # pass this parameter to the BEGIN statement (see bellow).
43 # do all the work to collect / calculate the values
45 # remember: KEEP IT SIMPLE AND SHORT
50 value4=$[8192 + (RANDOM * 16383 / 32767) ]
52 if [ $example_count -gt 0 ]
54 example_count=$[example_count - 1]
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)]
59 example_count=$[1 + (RANDOM * 5 / 32767) ]
61 [ $example_last -gt 16383 -a $value4 -gt 16383 ] && value4=$[value4 - 16383]
62 [ $example_last -le 16383 -a $value4 -lt 16383 ] && value4=$[value4 + 16383]
66 # write the result of the work.
68 BEGIN example.random $1
73 BEGIN example.random2 $1
77 # echo >&2 "example_count = $example_count value = $value4"