]> arthur.barton.de Git - netdata.git/blob - charts.d/mem_apps.chart.sh
Merge pull request #2021 from ktsaou/master
[netdata.git] / charts.d / mem_apps.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 mem_apps_apps=
10
11 # these are required for computing memory in bytes and cpu in seconds
12 #mem_apps_pagesize="`getconf PAGESIZE`"
13 #mem_apps_clockticks="`getconf CLK_TCK`"
14
15 mem_apps_update_every=
16
17 mem_apps_check() {
18         # this should return:
19         #  - 0 to enable the chart
20         #  - 1 to disable the chart
21
22         if [ -z "$mem_apps_apps" ]
23         then
24                 error "manual configuration required: please set mem_apps_apps='command1 command2 ...' in $confd/mem_apps_apps.conf"
25                 return 1
26         fi
27         return 0
28 }
29
30 mem_apps_bc_finalze=
31
32 mem_apps_create() {
33
34         echo "CHART chartsd_apps.mem '' 'Apps Memory' MB apps apps.mem stacked 20000 $mem_apps_update_every"
35
36         local x=
37         for x in $mem_apps_apps
38         do
39                 echo "DIMENSION $x $x absolute 1 1024"
40
41                 # this string is needed later in the update() function
42                 # to finalize the instructions for the bc command
43                 mem_apps_bc_finalze="$mem_apps_bc_finalze \"SET $x = \"; $x;"
44         done
45         return 0
46 }
47
48 mem_apps_update() {
49         # do all the work to collect / calculate the values
50         # for each dimension
51         # remember: KEEP IT SIMPLE AND SHORT
52
53         echo "BEGIN chartsd_apps.mem"
54         ps -o comm,rss -C "$mem_apps_apps" |\
55                 grep -v "^COMMAND" |\
56                 (       sed -e "s/ \+/ /g" -e "s/ /+=/g";
57                         echo "$mem_apps_bc_finalze"
58                 ) | bc
59         echo "END"
60
61         return 0
62 }