]> arthur.barton.de Git - netdata.git/blob - charts.d/example.chart.sh
code optimizations; added temperature charts.d plugin
[netdata.git] / charts.d / example.chart.sh
1 #!/bin/sh
2
3 # if this chart is called X.chart.sh, then all functions and global variables
4 # must start with X_
5
6 # _update_every is a special variable - it holds the number of seconds
7 # between the calls of the _update() function
8 example_update_every=
9
10 # _check is called once, to find out if this chart should be enabled or not
11 example_check() {
12         # this should return:
13         #  - 0 to enable the chart
14         #  - 1 to disable the chart
15
16         return 0
17 }
18
19 # _create is called once, to create the charts
20 example_create() {
21         # create the chart with 3 dimensions
22         cat <<EOF
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 EOF
28
29         return 0
30 }
31
32 # _update is called continiously, to collect the values
33 example_update() {
34         # the first argument to this function is the microseconds since last update
35         # pass this parameter to the BEGIN statement (see bellow).
36
37         # do all the work to collect / calculate the values
38         # for each dimension
39         # remember: KEEP IT SIMPLE AND SHORT
40
41         value1=$RANDOM
42         value2=$RANDOM
43         value3=$RANDOM
44
45         # write the result of the work.
46         cat <<VALUESEOF
47 BEGIN example.random $1
48 SET random1 = $value1
49 SET random2 = $value2
50 SET random3 = $value3
51 END
52 VALUESEOF
53
54         return 0
55 }
56