4c52fc78112d9073446e7cefb7f6865b6898c92b
[project/luci.git] /
1 /*
2 * Copyright 2011 Manuel Munz <freifunk at somakoma dot de>
3 * Licensed to the public under the Apache License 2.0.
4 */
5
6 'use strict';
7
8 return L.Class.extend({
9 title: _('Memory'),
10
11 rrdargs: function(graph, host, plugin, plugin_instance, dtype) {
12 var p = [];
13
14 var memory = {
15 title: "%H: Memory usage",
16 vlabel: "MB",
17 number_format: "%5.1lf%s",
18 y_min: "0",
19 alt_autoscale_max: true,
20 data: {
21 instances: {
22 memory: [
23 "free",
24 "buffered",
25 "cached",
26 "used"
27 ]
28 },
29
30 options: {
31 memory_buffered: {
32 color: "0000ff",
33 title: "Buffered"
34 },
35 memory_cached: {
36 color: "ff00ff",
37 title: "Cached"
38 },
39 memory_used: {
40 color: "ff0000",
41 title: "Used"
42 },
43 memory_free: {
44 color: "00ff00",
45 title: "Free"
46 }
47 }
48 }
49 };
50
51 var percent = {
52 title: "%H: Memory usage",
53 vlabel: "Percent",
54 number_format: "%5.1lf%%",
55 y_min: "0",
56 alt_autoscale_max: true,
57 data: {
58 instances: {
59 percent: [
60 "free",
61 "buffered",
62 "cached",
63 "used"
64 ]
65 },
66 options: {
67 percent_buffered: {
68 color: "0000ff",
69 title: "Buffered"
70 },
71 percent_cached: {
72 color: "ff00ff",
73 title: "Cached"
74 },
75 percent_used: {
76 color: "ff0000",
77 title: "Used"
78 },
79 percent_free: {
80 color: "00ff00",
81 title: "Free"
82 }
83 }
84 }
85 };
86
87 var types = graph.dataTypes(host, plugin, plugin_instance);
88
89 for (var i = 0; i < types.length; i++)
90 if (types[i] == 'percent')
91 p.push(percent);
92 else if (types[i] == 'memory')
93 p.push(memory);
94
95 return p;
96 }
97 });