]> arthur.barton.de Git - netdata.git/blob - charts.d/load_average.chart.sh
6e5d5e05728aceabe6c68125645354d60dc8d78f
[netdata.git] / charts.d / load_average.chart.sh
1 #!/bin/sh
2
3 load_average_update_every=
4
5 load_average_check() {
6         # this should return:
7         #  - 0 to enable the chart
8         #  - 1 to disable the chart
9
10         return 0
11 }
12
13 load_average_create() {
14         # create a chart with 3 dimensions
15 cat <<EOF
16 CHART example.load '' "System Load Average" "load" load load line 500 $load_average_update_every
17 DIMENSION load1 '1 min' absolute 1 100
18 DIMENSION load5 '5 mins' absolute 1 100
19 DIMENSION load15 '15 mins' absolute 1 100
20 EOF
21
22         return 0
23 }
24
25 load_average_update() {
26         # do all the work to collect / calculate the values
27         # for each dimension
28         # remember: KEEP IT SIMPLE AND SHORT
29
30         # here we parse the system average load
31         # it is decimal (with 2 decimal digits), so we remove the dot and
32         # at the definition we have divisor = 100, to have the graph show the right value
33         loadavg="`cat /proc/loadavg | sed -e "s/\.//g"`"
34         load1=`echo $loadavg | cut -d ' ' -f 1`
35         load5=`echo $loadavg | cut -d ' ' -f 2`
36         load15=`echo $loadavg | cut -d ' ' -f 3`
37
38         # write the result of the work.
39         cat <<VALUESEOF
40 BEGIN example.load
41 SET load1 = $load1
42 SET load5 = $load5
43 SET load15 = $load15
44 END
45 VALUESEOF
46
47         return 0
48 }
49