]> arthur.barton.de Git - netdata.git/blobdiff - charts.d/example.chart.sh
fixed phpfpm
[netdata.git] / charts.d / example.chart.sh
index 34a3bc1bfab43b2f8ba1c88de770708174ddc9a8..b20740e862ef67180f1e798d9103e7a95196bfa2 100755 (executable)
@@ -7,14 +7,21 @@
 # between the calls of the _update() function
 example_update_every=
 
+# the priority is used to sort the charts on the dashboard
+# 1 = the first chart
 example_priority=150000
 
+# to enable this chart, you have to set this to 12345
+# (just a demonstration for something that needs to be checked)
+example_magic_number=
+
 # _check is called once, to find out if this chart should be enabled or not
 example_check() {
        # this should return:
        #  - 0 to enable the chart
        #  - 1 to disable the chart
 
+       [ "${example_magic_number}" != "12345" ] && return 1
        return 0
 }
 
@@ -22,11 +29,11 @@ example_check() {
 example_create() {
        # create the chart with 3 dimensions
        cat <<EOF
-CHART example.random '' "Random Numbers Stacked Chart" "% of random numbers" random random stacked $[example_priority] $example_update_every
+CHART example.random '' "Random Numbers Stacked Chart" "% of random numbers" random random stacked $((example_priority)) $example_update_every
 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 $[example_priority + 1] $example_update_every
+CHART example.random2 '' "A random number" "random number" random random area $((example_priority + 1)) $example_update_every
 DIMENSION random '' absolute 1 1
 EOF
 
@@ -49,19 +56,19 @@ example_update() {
        value1=$RANDOM
        value2=$RANDOM
        value3=$RANDOM
-       value4=$[8192 + (RANDOM * 16383 / 32767) ]
+       value4=$((8192 + (RANDOM * 16383 / 32767) ))
 
        if [ $example_count -gt 0 ]
                then
-               example_count=$[example_count - 1]
+               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)]
+               [ $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_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]
+               [ $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