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