]>
Commit | Line | Data |
---|---|---|
29455c5f MT |
1 | #!/usr/bin/python3 |
2 | ############################################################################### | |
3 | # # | |
4 | # collecty - A system statistics collection daemon for IPFire # | |
5 | # Copyright (C) 2015 IPFire development team # | |
6 | # # | |
7 | # This program is free software: you can redistribute it and/or modify # | |
8 | # it under the terms of the GNU General Public License as published by # | |
9 | # the Free Software Foundation, either version 3 of the License, or # | |
10 | # (at your option) any later version. # | |
11 | # # | |
12 | # This program is distributed in the hope that it will be useful, # | |
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of # | |
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # | |
15 | # GNU General Public License for more details. # | |
16 | # # | |
17 | # You should have received a copy of the GNU General Public License # | |
18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. # | |
19 | # # | |
20 | ############################################################################### | |
21 | ||
22 | import os | |
23 | ||
24 | from .. import util | |
25 | from . import base | |
26 | ||
a031204a | 27 | from ..colours import * |
29455c5f | 28 | from ..constants import * |
29455c5f MT |
29 | |
30 | class GraphTemplateIPv6Fragmentation(base.GraphTemplate): | |
31 | name = "ipv6-fragmentation" | |
32 | ||
33 | @property | |
34 | def rrd_graph(self): | |
35 | _ = self.locale.translate | |
36 | ||
37 | return [ | |
cd8bba0b | 38 | "CDEF:ip6_reasm_real_fails=ip6_reasm_fails,ip6_reasm_timeout,-", |
29455c5f MT |
39 | |
40 | # Reassembly | |
03619914 MT |
41 | "AREA:ip6_reasm_real_fails%s:%s" % \ |
42 | (transparency(COLOUR_ERROR, AREA_OPACITY), | |
43 | LABEL % _("Failed Reassemblies"), | |
44 | ), | |
45 | "GPRINT:ip6_reasm_fails_cur:%s" % INTEGER, | |
46 | "GPRINT:ip6_reasm_fails_avg:%s" % INTEGER, | |
47 | "GPRINT:ip6_reasm_fails_min:%s" % INTEGER, | |
48 | "GPRINT:ip6_reasm_fails_max:%s" % INTEGER, | |
49 | ||
50 | "AREA:ip6_reasm_timeout%s:%s:STACK" % \ | |
51 | (transparency(COLOUR_WARN, AREA_OPACITY), | |
52 | LABEL % _("Reassembly Timeouts"), | |
53 | ), | |
54 | "GPRINT:ip6_reasm_timeout_cur:%s" % INTEGER, | |
55 | "GPRINT:ip6_reasm_timeout_avg:%s" % INTEGER, | |
56 | "GPRINT:ip6_reasm_timeout_max:%s" % INTEGER, | |
57 | "GPRINT:ip6_reasm_timeout_min:%s" % INTEGER, | |
58 | ||
59 | "LINE2:ip6_reasm_oks%s:%-24s" % ( | |
60 | BLACK, | |
61 | LABEL % _("Successful Reassemblies"), | |
62 | ), | |
63 | "GPRINT:ip6_reasm_oks_cur:%s" % INTEGER, | |
64 | "GPRINT:ip6_reasm_oks_avg:%s" % INTEGER, | |
65 | "GPRINT:ip6_reasm_oks_max:%s" % INTEGER, | |
66 | "GPRINT:ip6_reasm_oks_min:%s" % INTEGER, | |
67 | ||
68 | EMPTY_LINE, | |
29455c5f MT |
69 | |
70 | # Fragmentation | |
03619914 MT |
71 | "LINE2:ip6_frags_fails%s:%s" % ( |
72 | COLOUR_ERROR, | |
73 | LABEL % _("Failed Fragmentations"), | |
74 | ), | |
75 | "GPRINT:ip6_frags_fails_cur:%s" % INTEGER, | |
76 | "GPRINT:ip6_frags_fails_avg:%s" % INTEGER, | |
77 | "GPRINT:ip6_frags_fails_max:%s" % INTEGER, | |
78 | "GPRINT:ip6_frags_fails_min:%s" % INTEGER, | |
79 | ||
80 | "LINE2:ip6_frags_oks%s:%-24s" % ( | |
81 | COLOUR_OK, | |
82 | LABEL % _("Fragmented Packets"), | |
83 | ), | |
84 | "GPRINT:ip6_frags_oks_cur:%s" % INTEGER, | |
85 | "GPRINT:ip6_frags_oks_avg:%s" % INTEGER, | |
86 | "GPRINT:ip6_frags_oks_max:%s" % INTEGER, | |
87 | "GPRINT:ip6_frags_oks_min:%s" % INTEGER, | |
88 | ||
89 | # Headline | |
90 | "COMMENT:%s" % EMPTY_LABEL, | |
91 | "COMMENT:%s" % (COLUMN % _("Current")), | |
92 | "COMMENT:%s" % (COLUMN % _("Average")), | |
93 | "COMMENT:%s" % (COLUMN % _("Minimum")), | |
94 | "COMMENT:%s\\j" % (COLUMN % _("Maximum")), | |
29455c5f MT |
95 | ] |
96 | ||
97 | @property | |
98 | def graph_title(self): | |
99 | _ = self.locale.translate | |
100 | ||
101 | if self.object.interface: | |
102 | return _("IPv6 Fragmentation on %s") % self.object.interface | |
103 | ||
104 | return _("IPv6 Fragmentation") | |
105 | ||
106 | @property | |
107 | def graph_vertical_label(self): | |
108 | _ = self.locale.translate | |
03619914 | 109 | |
29455c5f MT |
110 | return _("Packets/s") |
111 | ||
112 | @property | |
113 | def rrd_graph_args(self): | |
114 | return [ | |
115 | "--base", "1000", | |
116 | "--legend-direction=bottomup", | |
117 | ] | |
118 | ||
119 | ||
120 | class GraphTemplateIPv4Fragmentation(base.GraphTemplate): | |
121 | name = "ipv4-fragmentation" | |
122 | ||
123 | @property | |
124 | def rrd_graph(self): | |
125 | _ = self.locale.translate | |
126 | ||
127 | return [ | |
cd8bba0b | 128 | "CDEF:ip4_reasm_real_fails=ip4_reasm_fails,ip4_reasm_timeout,-", |
29455c5f MT |
129 | |
130 | # Reassembly | |
03619914 MT |
131 | "AREA:ip4_reasm_real_fails%s:%s" % \ |
132 | (transparency(COLOUR_ERROR, AREA_OPACITY), | |
133 | LABEL % _("Failed Reassemblies"), | |
134 | ), | |
135 | "GPRINT:ip4_reasm_fails_cur:%s" % INTEGER, | |
136 | "GPRINT:ip4_reasm_fails_avg:%s" % INTEGER, | |
137 | "GPRINT:ip4_reasm_fails_min:%s" % INTEGER, | |
138 | "GPRINT:ip4_reasm_fails_max:%s" % INTEGER, | |
139 | ||
140 | "AREA:ip4_reasm_timeout%s:%s:STACK" % \ | |
141 | (transparency(COLOUR_WARN, AREA_OPACITY), | |
142 | LABEL % _("Reassembly Timeouts"), | |
143 | ), | |
144 | "GPRINT:ip4_reasm_timeout_cur:%s" % INTEGER, | |
145 | "GPRINT:ip4_reasm_timeout_avg:%s" % INTEGER, | |
146 | "GPRINT:ip4_reasm_timeout_max:%s" % INTEGER, | |
147 | "GPRINT:ip4_reasm_timeout_min:%s" % INTEGER, | |
148 | ||
149 | "LINE2:ip4_reasm_oks%s:%-24s" % ( | |
150 | BLACK, | |
151 | LABEL % _("Successful Reassemblies"), | |
152 | ), | |
153 | "GPRINT:ip4_reasm_oks_cur:%s" % INTEGER, | |
154 | "GPRINT:ip4_reasm_oks_avg:%s" % INTEGER, | |
155 | "GPRINT:ip4_reasm_oks_max:%s" % INTEGER, | |
156 | "GPRINT:ip4_reasm_oks_min:%s" % INTEGER, | |
157 | ||
158 | EMPTY_LINE, | |
29455c5f MT |
159 | |
160 | # Fragmentation | |
03619914 MT |
161 | "LINE2:ip4_frags_fails%s:%s" % ( |
162 | COLOUR_ERROR, | |
163 | LABEL % _("Failed Fragmentations"), | |
164 | ), | |
165 | "GPRINT:ip4_frags_fails_cur:%s" % INTEGER, | |
166 | "GPRINT:ip4_frags_fails_avg:%s" % INTEGER, | |
167 | "GPRINT:ip4_frags_fails_max:%s" % INTEGER, | |
168 | "GPRINT:ip4_frags_fails_min:%s" % INTEGER, | |
169 | ||
170 | "LINE2:ip4_frags_oks%s:%-24s" % ( | |
171 | COLOUR_OK, | |
172 | LABEL % _("Fragmented Packets"), | |
173 | ), | |
174 | "GPRINT:ip4_frags_oks_cur:%s" % INTEGER, | |
175 | "GPRINT:ip4_frags_oks_avg:%s" % INTEGER, | |
176 | "GPRINT:ip4_frags_oks_max:%s" % INTEGER, | |
177 | "GPRINT:ip4_frags_oks_min:%s" % INTEGER, | |
178 | ||
179 | # Headline | |
180 | "COMMENT:%s" % EMPTY_LABEL, | |
181 | "COMMENT:%s" % (COLUMN % _("Current")), | |
182 | "COMMENT:%s" % (COLUMN % _("Average")), | |
183 | "COMMENT:%s" % (COLUMN % _("Minimum")), | |
184 | "COMMENT:%s\\j" % (COLUMN % _("Maximum")), | |
29455c5f MT |
185 | ] |
186 | ||
187 | @property | |
188 | def graph_title(self): | |
189 | _ = self.locale.translate | |
190 | ||
191 | if self.object.interface: | |
192 | return _("IPv4 Fragmentation on %s") % self.object.interface | |
193 | ||
194 | return _("IPv4 Fragmentation") | |
195 | ||
196 | @property | |
197 | def graph_vertical_label(self): | |
198 | _ = self.locale.translate | |
199 | return _("Packets/s") | |
200 | ||
201 | @property | |
202 | def rrd_graph_args(self): | |
203 | return [ | |
204 | "--base", "1000", | |
205 | "--legend-direction=bottomup", | |
206 | ] | |
207 | ||
208 | ||
209 | class IPFragmentationObject(base.Object): | |
210 | rrd_schema = [ | |
211 | "DS:ip6_frags_oks:DERIVE:0:U", | |
212 | "DS:ip6_frags_fails:DERIVE:0:U", | |
213 | "DS:ip6_frags_creates:DERIVE:0:U", | |
214 | "DS:ip6_reasm_timeout:DERIVE:0:U", | |
215 | "DS:ip6_reasm_reqds:DERIVE:0:U", | |
216 | "DS:ip6_reasm_oks:DERIVE:0:U", | |
217 | "DS:ip6_reasm_fails:DERIVE:0:U", | |
218 | "DS:ip4_frags_oks:DERIVE:0:U", | |
219 | "DS:ip4_frags_fails:DERIVE:0:U", | |
220 | "DS:ip4_frags_creates:DERIVE:0:U", | |
221 | "DS:ip4_reasm_timeout:DERIVE:0:U", | |
222 | "DS:ip4_reasm_reqds:DERIVE:0:U", | |
223 | "DS:ip4_reasm_oks:DERIVE:0:U", | |
224 | "DS:ip4_reasm_fails:DERIVE:0:U", | |
225 | ] | |
226 | ||
227 | def __repr__(self): | |
228 | if self.interface: | |
229 | return "<%s %s>" % (self.__class__.__name__, self.interface) | |
230 | ||
231 | return "<%s>" % self.__class__.__name__ | |
232 | ||
233 | def init(self, interface=None): | |
234 | self.interface = interface | |
235 | ||
236 | @property | |
237 | def id(self): | |
238 | return self.interface or "default" | |
239 | ||
240 | def collect(self): | |
241 | p = util.ProcNetSnmpParser(self.interface) | |
242 | ||
243 | # Description in RFC2465 | |
244 | results = [ | |
245 | p.get("Ip6", "FragOKs"), | |
246 | p.get("Ip6", "FragFails"), | |
247 | p.get("Ip6", "FragCreates"), | |
248 | p.get("Ip6", "ReasmTimeout"), | |
249 | p.get("Ip6", "ReasmReqds"), | |
250 | p.get("Ip6", "ReasmOKs"), | |
251 | p.get("Ip6", "ReasmFails"), | |
252 | p.get("Ip", "FragOKs"), | |
253 | p.get("Ip", "FragFails"), | |
254 | p.get("Ip", "FragCreates"), | |
255 | p.get("Ip", "ReasmTimeout"), | |
256 | p.get("Ip", "ReasmReqds"), | |
257 | p.get("Ip", "ReasmOKs"), | |
258 | p.get("Ip", "ReasmFails"), | |
259 | ] | |
260 | ||
261 | return results | |
262 | ||
263 | ||
264 | class IPFragmentationPlugin(base.Plugin): | |
265 | name = "ip-fragmentation" | |
266 | description = "IP Fragmentation Plugin" | |
267 | ||
268 | templates = [ | |
269 | GraphTemplateIPv6Fragmentation, | |
270 | GraphTemplateIPv4Fragmentation, | |
271 | ] | |
272 | ||
273 | @property | |
274 | def objects(self): | |
275 | # Overall statistics | |
276 | yield IPFragmentationObject(self) | |
277 | ||
278 | # Stats per interface | |
279 | for interface in util.get_network_interfaces(): | |
280 | yield IPFragmentationObject(self, interface) |