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