summaryrefslogtreecommitdiffstats
path: root/collectors/charts.d.plugin/example
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2021-02-07 11:45:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2021-02-07 11:45:55 +0000
commita8220ab2d293bb7f4b014b79d16b2fb05090fa93 (patch)
tree77f0a30f016c0925cf7ee9292e644bba183c2774 /collectors/charts.d.plugin/example
parentAdding upstream version 1.19.0. (diff)
downloadnetdata-a8220ab2d293bb7f4b014b79d16b2fb05090fa93.tar.xz
netdata-a8220ab2d293bb7f4b014b79d16b2fb05090fa93.zip
Adding upstream version 1.29.0.upstream/1.29.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'collectors/charts.d.plugin/example')
-rw-r--r--collectors/charts.d.plugin/example/README.md5
-rw-r--r--collectors/charts.d.plugin/example/example.chart.sh106
2 files changed, 58 insertions, 53 deletions
diff --git a/collectors/charts.d.plugin/example/README.md b/collectors/charts.d.plugin/example/README.md
index 98562d624..de21f6ad6 100644
--- a/collectors/charts.d.plugin/example/README.md
+++ b/collectors/charts.d.plugin/example/README.md
@@ -1,3 +1,8 @@
+<!--
+title: "Example"
+custom_edit_url: https://github.com/netdata/netdata/edit/master/collectors/charts.d.plugin/example/README.md
+-->
+
# Example
This is just an example charts.d data collector.
diff --git a/collectors/charts.d.plugin/example/example.chart.sh b/collectors/charts.d.plugin/example/example.chart.sh
index 8bae570a3..5ff51a579 100644
--- a/collectors/charts.d.plugin/example/example.chart.sh
+++ b/collectors/charts.d.plugin/example/example.chart.sh
@@ -32,63 +32,63 @@ example_last=0
example_count=0
example_get() {
- # do all the work to collect / calculate the values
- # for each dimension
- #
- # Remember:
- # 1. KEEP IT SIMPLE AND SHORT
- # 2. AVOID FORKS (avoid piping commands)
- # 3. AVOID CALLING TOO MANY EXTERNAL PROGRAMS
- # 4. USE LOCAL VARIABLES (global variables may overlap with other modules)
-
- example_value1=$RANDOM
- example_value2=$RANDOM
- example_value3=$RANDOM
- example_value4=$((8192 + (RANDOM * 16383 / 32767)))
-
- if [ $example_count -gt 0 ]; then
- example_count=$((example_count - 1))
-
- [ $example_last -gt 16383 ] && example_value4=$((example_last + (RANDOM * ((32767 - example_last) / 2) / 32767)))
- [ $example_last -le 16383 ] && example_value4=$((example_last - (RANDOM * (example_last / 2) / 32767)))
- else
- example_count=$((1 + (RANDOM * 5 / 32767)))
-
- if [ $example_last -gt 16383 ] && [ $example_value4 -gt 16383 ]; then
- example_value4=$((example_value4 - 16383))
- fi
- if [ $example_last -le 16383 ] && [ $example_value4 -lt 16383 ]; then
- example_value4=$((example_value4 + 16383))
- fi
- fi
- example_last=$example_value4
-
- # this should return:
- # - 0 to send the data to netdata
- # - 1 to report a failure to collect the data
-
- return 0
+ # do all the work to collect / calculate the values
+ # for each dimension
+ #
+ # Remember:
+ # 1. KEEP IT SIMPLE AND SHORT
+ # 2. AVOID FORKS (avoid piping commands)
+ # 3. AVOID CALLING TOO MANY EXTERNAL PROGRAMS
+ # 4. USE LOCAL VARIABLES (global variables may overlap with other modules)
+
+ example_value1=$RANDOM
+ example_value2=$RANDOM
+ example_value3=$RANDOM
+ example_value4=$((8192 + (RANDOM * 16383 / 32767)))
+
+ if [ $example_count -gt 0 ]; then
+ example_count=$((example_count - 1))
+
+ [ $example_last -gt 16383 ] && example_value4=$((example_last + (RANDOM * ((32767 - example_last) / 2) / 32767)))
+ [ $example_last -le 16383 ] && example_value4=$((example_last - (RANDOM * (example_last / 2) / 32767)))
+ else
+ example_count=$((1 + (RANDOM * 5 / 32767)))
+
+ if [ $example_last -gt 16383 ] && [ $example_value4 -gt 16383 ]; then
+ example_value4=$((example_value4 - 16383))
+ fi
+ if [ $example_last -le 16383 ] && [ $example_value4 -lt 16383 ]; then
+ example_value4=$((example_value4 + 16383))
+ fi
+ fi
+ example_last=$example_value4
+
+ # this should return:
+ # - 0 to send the data to netdata
+ # - 1 to report a failure to collect the data
+
+ return 0
}
# _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
+ # this should return:
+ # - 0 to enable the chart
+ # - 1 to disable the chart
- # check something
- [ "${example_magic_number}" != "12345" ] && error "manual configuration required: you have to set example_magic_number=$example_magic_number in example.conf to start example chart." && return 1
+ # check something
+ [ "${example_magic_number}" != "12345" ] && error "manual configuration required: you have to set example_magic_number=$example_magic_number in example.conf to start example chart." && return 1
- # check that we can collect data
- example_get || return 1
+ # check that we can collect data
+ example_get || return 1
- return 0
+ return 0
}
# _create is called once, to create the charts
example_create() {
- # create the chart with 3 dimensions
- cat <<EOF
+ # 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
DIMENSION random1 '' percentage-of-absolute-row 1 1
DIMENSION random2 '' percentage-of-absolute-row 1 1
@@ -97,18 +97,18 @@ CHART example.random2 '' "A random number" "random number" random random area $(
DIMENSION random '' absolute 1 1
EOF
- return 0
+ return 0
}
# _update is called continuously, to collect the values
example_update() {
- # the first argument to this function is the microseconds since last update
- # pass this parameter to the BEGIN statement (see bellow).
+ # the first argument to this function is the microseconds since last update
+ # pass this parameter to the BEGIN statement (see bellow).
- example_get || return 1
+ example_get || return 1
- # write the result of the work.
- cat <<VALUESEOF
+ # write the result of the work.
+ cat << VALUESEOF
BEGIN example.random $1
SET random1 = $example_value1
SET random2 = $example_value2
@@ -119,5 +119,5 @@ SET random = $example_value4
END
VALUESEOF
- return 0
+ return 0
}