Merge pull request #1735 from sumpfralle/olsr-jsoninfo-parser-handle-empty-result
[oweals/luci.git] / applications / luci-app-statistics / luasrc / statistics / rrdtool / definitions / memory.lua
1 -- Copyright  2011 Manuel Munz <freifunk at somakoma dot de>
2 -- Licensed to the public under the Apache License 2.0.
3
4 module("luci.statistics.rrdtool.definitions.memory",package.seeall)
5
6 function item()
7         return luci.i18n.translate("Memory")
8 end
9
10 function rrdargs( graph, plugin, plugin_instance, dtype )
11         local p = {}
12
13         local memory = {
14                 title = "%H: Memory usage",
15                 vlabel = "MB",
16                 number_format = "%5.1lf%s",
17                 y_min = "0",
18                 alt_autoscale_max = true,
19                 data = {
20                         instances = {
21                                 memory = {
22                                         "free",
23                                         "buffered",
24                                         "cached",
25                                         "used"
26                                 }
27                         },
28
29                         options = {
30                                 memory_buffered = {
31                                         color = "0000ff",
32                                         title = "Buffered"
33                                 },
34                                 memory_cached = {
35                                         color = "ff00ff",
36                                         title = "Cached"
37                                 },
38                                 memory_used = {
39                                         color = "ff0000",
40                                         title = "Used"
41                                 },
42                                 memory_free = {
43                                         color = "00ff00",
44                                         title = "Free"
45                                 }
46                         }
47                 }
48         }
49
50         local percent = {
51                 title = "%H: Memory usage",
52                 vlabel = "Percent",
53                 number_format = "%5.1lf%%",
54                 y_min = "0",
55                 alt_autoscale_max = true,
56                 data = {
57                         instances = {
58                                 percent = {
59                                         "free",
60                                         "buffered",
61                                         "cached",
62                                         "used"
63                                 }
64                         },
65                         options = {
66                                 percent_buffered = {
67                                         color = "0000ff",
68                                         title = "Buffered"
69                                 },
70                                 percent_cached = {
71                                         color = "ff00ff",
72                                         title = "Cached"
73                                 },
74                                 percent_used = {
75                                         color = "ff0000",
76                                         title = "Used"
77                                 },
78                                 percent_free = {
79                                         color = "00ff00",
80                                         title = "Free"
81                                 }
82                         }
83                 }
84         }
85
86         local types = graph.tree:data_types( plugin, plugin_instance )
87
88         for _, t in ipairs(types) do
89                 if t == "percent" then
90                         p[#p+1] = percent
91                 end
92
93                 if t == "memory" then
94                         p[#p+1] = memory
95                 end
96         end
97
98         return p
99 end