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