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