3cee6abc0092ed422b092b08a547f6ba163b3efd
[project/luci.git] / applications / luci-statistics / src / statistics / rrdtool / definitions / netlink.lua
1 module("luci.statistics.rrdtool.definitions.netlink", package.seeall)
2
3 function rrdargs( graph, host, plugin, plugin_instance )
4
5 local diagram_list = { }
6
7 -- diagram names
8 local dtypes_names = {
9 "Pakete",
10 "Paketkollisionen",
11 "Paketfehler",
12 "Verkehr",
13 "RX-Fehler",
14 "TX-Fehler"
15 }
16
17 -- diagram units
18 local dtypes_units = {
19 "Pakete/s",
20 "Kollisionen/s",
21 "Fehler/s", -- (?)
22 "Bytes/s",
23 "Fehler/s",
24 "Fehler/s"
25 }
26
27 -- data source overrides
28 local dtypes_sources = {
29 if_errors = { "rx", "tx" }, -- if_errors has rx and tx
30 if_octets = { "rx", "tx" } -- if_octets has rx and tx
31 }
32
33 -- diagram data types
34 local dtypes_list = {
35
36 -- diagram 1: combined interface packet statistics
37 {
38 if_dropped = { "" }, -- packets/s
39 if_multicast = { "" }, -- packets/s
40 if_packets = { "" } -- packets/s
41 },
42
43 -- diagram 2: interface collision statistics
44 {
45 if_collisions = { "" } -- collisions/s
46 },
47
48 -- diagram 3: interface error statistics
49 {
50 if_errors = { "" } -- errors/s (?)
51 },
52
53 -- diagram 4: interface traffic statistics
54 {
55 if_octets = { "" } -- bytes/s
56 },
57
58 -- diagram 5: interface rx error statistics
59 {
60 if_rx_errors = { -- errors/s
61 "length", "missed", "over", "crc", "fifo", "frame"
62 }
63 },
64
65 -- diagram 6: interface tx error statistics
66 {
67 if_tx_errors = { -- errors/s
68 "aborted", "carrier", "fifo", "heartbeat", "window"
69 }
70 }
71 }
72
73 -- diagram colors
74 local dtypes_colors = {
75
76 -- diagram 1
77 {
78 if_dropped = "ff0000",
79 if_multicast = "0000ff",
80 if_packets = "00ff00"
81 },
82
83 -- diagram 2
84 {
85 if_collisions = "ff0000"
86 },
87
88 -- diagram 3
89 {
90 if_errors__tx_ = "ff0000",
91 if_errors__rx_ = "ff5500"
92 },
93
94 -- diagram 4
95 {
96 if_octets__tx_ = "00ff00",
97 if_octets__rx_ = "0000ff"
98 },
99
100 -- diagram 5
101 {
102 length = "0000ff",
103 missed = "ff5500",
104 over = "ff0066",
105 crc = "ff0000",
106 fifo = "00ff00",
107 frame = "ffff00"
108 },
109
110 -- diagram 6
111 {
112 aborted = "ff0000",
113 carrier = "ffff00",
114 fifo = "00ff00",
115 heartbeat = "0000ff",
116 window = "8800ff"
117 }
118 }
119
120
121 for i, name in ipairs(dtypes_names) do
122
123 local dtypes = dtypes_list[i]
124 local opts = { }
125
126 opts.sources = { }
127 opts.image = graph:mkpngpath( host, plugin, plugin_instance, "netlink" .. i )
128 opts.title = host .. ": Netlink Statistiken - " .. name .. " auf " .. plugin_instance
129 opts.rrd = { "-v", dtypes_units[i] }
130 opts.colors = dtypes_colors[i]
131
132 for dtype, dinstances in pairs(dtypes) do
133 for i, inst in ipairs(dinstances) do
134
135 local name = inst
136 if name:len() == 0 then name = dtype end
137
138 -- check for data source override
139 if dtypes_sources[dtype] then
140
141 -- has override
142 for i, ds in ipairs(dtypes_sources[dtype]) do
143 table.insert( opts.sources, {
144 ds = ds, -- override
145 name = name .. " (" .. ds .. ")",
146 rrd = graph:mkrrdpath( host, plugin, plugin_instance, dtype, inst )
147 } )
148 end
149 else
150 -- no override, assume single "value" data source
151 table.insert( opts.sources, {
152 name = name,
153 rrd = graph:mkrrdpath( host, plugin, plugin_instance, dtype, inst )
154 } )
155 end
156 end
157 end
158
159 table.insert( diagram_list, opts )
160 end
161
162 return diagram_list
163 end