efa631d557c1714196ecaa8e381d2381c9ccdff7
[project/luci.git] / applications / luci-app-statistics / luasrc / statistics / rrdtool / definitions / interface.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.interface", package.seeall)
5
6 function rrdargs( graph, plugin, plugin_instance )
7
8         --
9         -- traffic diagram
10         --
11         local traffic = {
12
13                 -- draw this diagram for each plugin instance
14                 per_instance = true,
15                 title = "%H: Transfer on %pi",
16                 vlabel = "Bytes/s",
17
18                 -- diagram data description
19                 data = {
20                         -- defined sources for data types, if ommitted assume a single DS named "value" (optional)
21                         sources = {
22                                 if_octets = { "tx", "rx" }
23                         },
24
25                         -- special options for single data lines
26                         options = {
27                                 if_octets__tx = {
28                                         total = true,           -- report total amount of bytes
29                                         color = "00ff00",       -- tx is green
30                                         title = "Bytes (TX)"
31                                 },
32
33                                 if_octets__rx = {
34                                         flip  = true,           -- flip rx line
35                                         total = true,           -- report total amount of bytes
36                                         color = "0000ff",       -- rx is blue
37                                         title = "Bytes (RX)"
38                                 }
39                         }
40                 }
41         }
42
43
44         --
45         -- packet diagram
46         --
47         local packets = {
48
49                 -- draw this diagram for each plugin instance
50                 per_instance = true,
51                 title = "%H: Packets on %pi",
52                 vlabel = "Packets/s",
53
54                 -- diagram data description
55                 data = {
56                         -- data type order
57                         types = { "if_packets", "if_errors" },
58
59                         -- defined sources for data types
60                         sources = {
61                                 if_packets = { "tx", "rx" },
62                                 if_errors  = { "tx", "rx" }
63                         },
64
65                         -- special options for single data lines
66                         options = {
67                                 -- processed packets (tx DS)
68                                 if_packets__tx = {
69                                         overlay = true,         -- don't summarize
70                                         total   = true,         -- report total amount of bytes
71                                         color   = "00ff00",     -- processed tx is green
72                                         title   = "Processed (tx)"
73                                 },
74
75                                 -- processed packets (rx DS)
76                                 if_packets__rx = {
77                                         overlay = true,         -- don't summarize
78                                         flip    = true,         -- flip rx line
79                                         total   = true,         -- report total amount of bytes
80                                         color   = "0000ff",     -- processed rx is blue
81                                         title   = "Processed (rx)"
82                                 },
83
84                                 -- packet errors (tx DS)
85                                 if_errors__tx = {
86                                         overlay = true,         -- don't summarize
87                                         total   = true,         -- report total amount of packets
88                                         color   = "ff5500",     -- tx errors are orange
89                                         title   = "Errors (tx)"
90                                 },
91
92                                 -- packet errors (rx DS)
93                                 if_errors__rx = {
94                                         overlay = true,         -- don't summarize
95                                         flip    = true,         -- flip rx line
96                                         total   = true,         -- report total amount of packets
97                                         color   = "ff0000",     -- rx errors are red
98                                         title   = "Errors (rx)"
99                                 }
100                         }
101                 }
102         }
103
104         return { traffic, packets }
105 end