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