Merge pull request #501 from LuttyYang/master
[project/luci.git] / applications / luci-app-statistics / luasrc / statistics / rrdtool / definitions / netlink.lua
1 -- Copyright 2008 Freifunk Leipzig / Jo-Philipp Wich <jow@openwrt.org>
2 -- Licensed to the public under the Apache License 2.0.
3
4 module("luci.statistics.rrdtool.definitions.netlink", package.seeall)
5
6 function rrdargs( graph, plugin, plugin_instance )
7
8         --
9         -- traffic diagram
10         --
11         local traffic = {
12                 title = "%H: Netlink - Transfer on %pi",
13                 vlabel = "Bytes/s",
14
15                 -- diagram data description
16                 data = {
17                         -- defined sources for data types, if ommitted assume a single DS named "value" (optional)
18                         sources = {
19                                 if_octets = { "tx", "rx" }
20                         },
21
22                         -- special options for single data lines
23                         options = {
24                                 if_octets__tx = {
25                                         title = "Bytes (TX)",
26                                         total = true,           -- report total amount of bytes
27                                         color = "00ff00"        -- tx is green
28                                 },
29
30                                 if_octets__rx = {
31                                         title = "Bytes (RX)",
32                                         flip  = true,           -- flip rx line
33                                         total = true,           -- report total amount of bytes
34                                         color = "0000ff"        -- rx is blue
35                                 }
36                         }
37                 }
38         }
39
40
41         --
42         -- packet diagram
43         --
44         local packets = {
45                 title = "%H: Netlink - Packets on %pi",
46                 vlabel = "Packets/s", detail = true,
47
48                 -- diagram data description
49                 data = {
50                         -- data type order
51                         types = { "if_packets", "if_dropped", "if_errors" },
52
53                         -- defined sources for data types
54                         sources = {
55                                 if_packets = { "tx", "rx" },
56                                 if_dropped = { "tx", "rx" },
57                                 if_errors  = { "tx", "rx" }
58                         },
59
60                         -- special options for single data lines
61                         options = {
62                                 -- processed packets (tx DS)
63                                 if_packets__tx = {
64                                         weight  = 2,
65                                         title   = "Total   (TX)",
66                                         overlay = true,         -- don't summarize
67                                         total   = true,         -- report total amount of bytes
68                                         color   = "00ff00"      -- processed tx is green
69                                 },
70
71                                 -- processed packets (rx DS)
72                                 if_packets__rx = {
73                                         weight  = 3,
74                                         title   = "Total   (RX)",
75                                         overlay = true,         -- don't summarize
76                                         flip    = true,         -- flip rx line
77                                         total   = true,         -- report total amount of bytes
78                                         color   = "0000ff"      -- processed rx is blue
79                                 },
80
81                                 -- dropped packets (tx DS)
82                                 if_dropped__tx = {
83                                         weight  = 1,
84                                         title   = "Dropped (TX)",
85                                         overlay = true,         -- don't summarize
86                                         total   = true,         -- report total amount of bytes
87                                         color   = "660055"      -- dropped tx is ... dunno ;)
88                                 },
89
90                                 -- dropped packets (rx DS)
91                                 if_dropped__rx = {
92                                         weight  = 4,
93                                         title   = "Dropped (RX)",
94                                         overlay = true,         -- don't summarize
95                                         flip    = true,         -- flip rx line
96                                         total   = true,         -- report total amount of bytes
97                                         color   = "ff00ff"      -- dropped rx is violett
98                                 },
99
100                                 -- packet errors (tx DS)
101                                 if_errors__tx = {
102                                         weight  = 0,
103                                         title   = "Errors  (TX)",
104                                         overlay = true,         -- don't summarize
105                                         total   = true,         -- report total amount of packets
106                                         color   = "ff5500"      -- tx errors are orange
107                                 },
108
109                                 -- packet errors (rx DS)
110                                 if_errors__rx = {
111                                         weight  = 5,
112                                         title   = "Errors  (RX)",
113                                         overlay = true,         -- don't summarize
114                                         flip    = true,         -- flip rx line
115                                         total   = true,         -- report total amount of packets
116                                         color   = "ff0000"      -- rx errors are red
117                                 }
118                         }
119                 }
120         }
121
122
123         --
124         -- multicast diagram
125         --
126         local multicast = {
127                 title = "%H: Netlink - Multicast on %pi",
128                 vlabel = "Packets/s", detail = true,
129
130                 -- diagram data description
131                 data = {
132                         -- data type order
133                         types = { "if_multicast" },
134
135                         -- special options for single data lines
136                         options = {
137                                 -- multicast packets
138                                 if_multicast = {
139                                         title = "Packets",
140                                         total = true,           -- report total amount of packets
141                                         color = "0000ff"        -- multicast is blue
142                                 }
143                         }
144                 }
145         }
146
147
148         --
149         -- collision diagram
150         --
151         local collisions = {
152                 title = "%H: Netlink - Collisions on %pi",
153                 vlabel = "Collisions/s", detail = true,
154
155                 -- diagram data description
156                 data = {
157                         -- data type order
158                         types = { "if_collisions" },
159
160                         -- special options for single data lines
161                         options = {
162                                 -- collision rate
163                                 if_collisions = {
164                                         title = "Collisions",
165                                         total = true,           -- report total amount of packets
166                                         color = "ff0000"        -- collsions are red
167                                 }
168                         }
169                 }
170         }
171
172
173         --
174         -- error diagram
175         --
176         local errors = {
177                 title = "%H: Netlink - Errors on %pi",
178                 vlabel = "Errors/s", detail = true,
179
180                 -- diagram data description
181                 data = {
182                         -- data type order
183                         types = { "if_tx_errors", "if_rx_errors" },
184
185                         -- data type instances
186                         instances = {
187                                 if_tx_errors = { "aborted", "carrier", "fifo", "heartbeat", "window" },
188                                 if_rx_errors = { "length", "missed", "over", "crc", "fifo", "frame" }
189                         },
190
191                         -- special options for single data lines
192                         options = {
193                                 if_tx_errors_aborted_value   = { total = true, color = "ffff00", title = "Aborted   (TX)" },
194                                 if_tx_errors_carrier_value   = { total = true, color = "ffcc00", title = "Carrier   (TX)" },
195                                 if_tx_errors_fifo_value      = { total = true, color = "ff9900", title = "Fifo      (TX)" },
196                                 if_tx_errors_heartbeat_value = { total = true, color = "ff6600", title = "Heartbeat (TX)" },
197                                 if_tx_errors_window_value    = { total = true, color = "ff3300", title = "Window    (TX)" },
198
199                                 if_rx_errors_length_value    = { flip = true, total = true, color = "ff0000", title = "Length    (RX)" },
200                                 if_rx_errors_missed_value    = { flip = true, total = true, color = "ff0033", title = "Missed    (RX)" },
201                                 if_rx_errors_over_value      = { flip = true, total = true, color = "ff0066", title = "Over      (RX)" },
202                                 if_rx_errors_crc_value       = { flip = true, total = true, color = "ff0099", title = "CRC       (RX)" },
203                                 if_rx_errors_fifo_value      = { flip = true, total = true, color = "ff00cc", title = "Fifo      (RX)" },
204                                 if_rx_errors_frame_value     = { flip = true, total = true, color = "ff00ff", title = "Frame     (RX)" }
205                         }
206                 }
207         }
208
209
210         return { traffic, packets, multicast, collisions, errors }
211 end