summaryrefslogtreecommitdiffstats
path: root/charts.d/load_average.chart.sh
diff options
context:
space:
mode:
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>2014-05-03 20:08:06 +0300
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>2014-05-03 20:08:06 +0300
commit648e4ae9540b2b6bed15839b319d456e8ba01674 (patch)
treef75dda86778c307878fda330fb3a13220e268f96 /charts.d/load_average.chart.sh
parentec97cc2a4bfaa7c775a3b39cdada6e4124f1ba43 (diff)
Now there are 2 kinds of plugins:
- plugins.d plugins that are expected to always be in memory and execute continiously - charts.d scripts that are sourced by the charts.d plugin and are all executed together, lowering significantly the resources they require (compared to plugins)
Diffstat (limited to 'charts.d/load_average.chart.sh')
-rwxr-xr-xcharts.d/load_average.chart.sh47
1 files changed, 47 insertions, 0 deletions
diff --git a/charts.d/load_average.chart.sh b/charts.d/load_average.chart.sh
new file mode 100755
index 0000000000..e2c72494a9
--- /dev/null
+++ b/charts.d/load_average.chart.sh
@@ -0,0 +1,47 @@
+#!/bin/sh
+
+load_average_check() {
+ # this should return:
+ # - 0 to enable the chart
+ # - 1 to disable the chart
+
+ return 0
+}
+
+load_average_create() {
+ # create a chart with 3 dimensions
+cat <<EOF
+CHART example.load '' "System Load Average" "load" load load line 500 $update_every
+DIMENSION load1 '1 min' absolute 1 100
+DIMENSION load5 '5 mins' absolute 1 100
+DIMENSION load15 '15 mins' absolute 1 100
+EOF
+
+ return 0
+}
+
+load_average_update() {
+ # do all the work to collect / calculate the values
+ # for each dimension
+ # remember: KEEP IT SIMPLE AND SHORT
+
+ # here we parse the system average load
+ # it is decimal (with 2 decimal digits), so we remove the dot and
+ # at the definition we have divisor = 100, to have the graph show the right value
+ loadavg="`cat /proc/loadavg | sed -e "s/\.//g"`"
+ load1=`echo $loadavg | cut -d ' ' -f 1`
+ load5=`echo $loadavg | cut -d ' ' -f 2`
+ load15=`echo $loadavg | cut -d ' ' -f 3`
+
+ # write the result of the work.
+ cat <<VALUESEOF
+BEGIN example.load
+SET load1 = $load1
+SET load5 = $load5
+SET load15 = $load15
+END
+VALUESEOF
+
+ return 0
+}
+