]>
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 | ||
27 | from ..constants import * | |
28 | from ..i18n import _ | |
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 | |
cd8bba0b | 41 | "AREA:ip6_reasm_real_fails%s:%-24s" % \ |
29455c5f | 42 | (util.lighten(COLOUR_ERROR), _("Failed Reassemblies")), |
cd8bba0b MT |
43 | "GPRINT:ip6_reasm_fails_cur:%s %%5.0lf%%s" % _("Now"), |
44 | "GPRINT:ip6_reasm_fails_avg:%s %%5.0lf%%s" % _("Avg"), | |
45 | "GPRINT:ip6_reasm_fails_max:%s %%5.0lf%%s" % _("Max"), | |
46 | "GPRINT:ip6_reasm_fails_min:%s %%5.0lf%%s\\j" % _("Min"), | |
29455c5f | 47 | |
cd8bba0b | 48 | "AREA:ip6_reasm_timeout%s:%-24s:STACK" % \ |
29455c5f | 49 | (util.lighten(COLOUR_WARN), _("Reassembly Timeouts")), |
cd8bba0b MT |
50 | "GPRINT:ip6_reasm_timeout_cur:%s %%5.0lf%%s" % _("Now"), |
51 | "GPRINT:ip6_reasm_timeout_avg:%s %%5.0lf%%s" % _("Avg"), | |
52 | "GPRINT:ip6_reasm_timeout_max:%s %%5.0lf%%s" % _("Max"), | |
53 | "GPRINT:ip6_reasm_timeout_min:%s %%5.0lf%%s\\j" % _("Min"), | |
29455c5f | 54 | |
cd8bba0b MT |
55 | "LINE2:ip6_reasm_oks%s:%-24s" % (BLACK, _("Successful Reassemblies")), |
56 | "GPRINT:ip6_reasm_oks_cur:%s %%5.0lf%%s" % _("Now"), | |
57 | "GPRINT:ip6_reasm_oks_avg:%s %%5.0lf%%s" % _("Avg"), | |
58 | "GPRINT:ip6_reasm_oks_max:%s %%5.0lf%%s" % _("Max"), | |
59 | "GPRINT:ip6_reasm_oks_min:%s %%5.0lf%%s\\j" % _("Min"), | |
29455c5f MT |
60 | |
61 | "COMMENT: \\n", # empty line | |
62 | ||
63 | # Fragmentation | |
cd8bba0b MT |
64 | "LINE2:ip6_frags_fails%s:%-24s" % (COLOUR_ERROR, _("Failed Fragmentations")), |
65 | "GPRINT:ip6_frags_fails_cur:%s %%5.0lf%%s" % _("Now"), | |
66 | "GPRINT:ip6_frags_fails_avg:%s %%5.0lf%%s" % _("Avg"), | |
67 | "GPRINT:ip6_frags_fails_max:%s %%5.0lf%%s" % _("Max"), | |
68 | "GPRINT:ip6_frags_fails_min:%s %%5.0lf%%s\\j" % _("Min"), | |
69 | ||
70 | "LINE2:ip6_frags_oks%s:%-24s" % (COLOUR_OK, _("Fragmented Packets")), | |
71 | "GPRINT:ip6_frags_oks_cur:%s %%5.0lf%%s" % _("Now"), | |
72 | "GPRINT:ip6_frags_oks_avg:%s %%5.0lf%%s" % _("Avg"), | |
73 | "GPRINT:ip6_frags_oks_max:%s %%5.0lf%%s" % _("Max"), | |
74 | "GPRINT:ip6_frags_oks_min:%s %%5.0lf%%s\\j" % _("Min"), | |
29455c5f MT |
75 | ] |
76 | ||
77 | @property | |
78 | def graph_title(self): | |
79 | _ = self.locale.translate | |
80 | ||
81 | if self.object.interface: | |
82 | return _("IPv6 Fragmentation on %s") % self.object.interface | |
83 | ||
84 | return _("IPv6 Fragmentation") | |
85 | ||
86 | @property | |
87 | def graph_vertical_label(self): | |
88 | _ = self.locale.translate | |
89 | return _("Packets/s") | |
90 | ||
91 | @property | |
92 | def rrd_graph_args(self): | |
93 | return [ | |
94 | "--base", "1000", | |
95 | "--legend-direction=bottomup", | |
96 | ] | |
97 | ||
98 | ||
99 | class GraphTemplateIPv4Fragmentation(base.GraphTemplate): | |
100 | name = "ipv4-fragmentation" | |
101 | ||
102 | @property | |
103 | def rrd_graph(self): | |
104 | _ = self.locale.translate | |
105 | ||
106 | return [ | |
cd8bba0b | 107 | "CDEF:ip4_reasm_real_fails=ip4_reasm_fails,ip4_reasm_timeout,-", |
29455c5f MT |
108 | |
109 | # Reassembly | |
cd8bba0b | 110 | "AREA:ip4_reasm_real_fails%s:%-24s" % \ |
29455c5f | 111 | (util.lighten(COLOUR_ERROR), _("Failed Reassemblies")), |
cd8bba0b MT |
112 | "GPRINT:ip4_reasm_fails_cur:%s %%5.0lf%%s" % _("Now"), |
113 | "GPRINT:ip4_reasm_fails_avg:%s %%5.0lf%%s" % _("Avg"), | |
114 | "GPRINT:ip4_reasm_fails_max:%s %%5.0lf%%s" % _("Max"), | |
115 | "GPRINT:ip4_reasm_fails_min:%s %%5.0lf%%s\\j" % _("Min"), | |
29455c5f | 116 | |
cd8bba0b | 117 | "AREA:ip4_reasm_timeout%s:%-24s:STACK" % \ |
29455c5f | 118 | (util.lighten(COLOUR_WARN), _("Reassembly Timeouts")), |
cd8bba0b MT |
119 | "GPRINT:ip4_reasm_timeout_cur:%s %%5.0lf%%s" % _("Now"), |
120 | "GPRINT:ip4_reasm_timeout_avg:%s %%5.0lf%%s" % _("Avg"), | |
121 | "GPRINT:ip4_reasm_timeout_max:%s %%5.0lf%%s" % _("Max"), | |
122 | "GPRINT:ip4_reasm_timeout_min:%s %%5.0lf%%s\\j" % _("Min"), | |
29455c5f | 123 | |
cd8bba0b MT |
124 | "LINE2:ip4_reasm_oks%s:%-24s" % (BLACK, _("Successful Reassemblies")), |
125 | "GPRINT:ip4_reasm_oks_cur:%s %%5.0lf%%s" % _("Now"), | |
126 | "GPRINT:ip4_reasm_oks_avg:%s %%5.0lf%%s" % _("Avg"), | |
127 | "GPRINT:ip4_reasm_oks_max:%s %%5.0lf%%s" % _("Max"), | |
128 | "GPRINT:ip4_reasm_oks_min:%s %%5.0lf%%s\\j" % _("Min"), | |
29455c5f MT |
129 | |
130 | "COMMENT: \\n", # empty line | |
131 | ||
132 | # Fragmentation | |
cd8bba0b MT |
133 | "LINE2:ip4_frags_fails%s:%-24s" % (COLOUR_ERROR, _("Failed Fragmentations")), |
134 | "GPRINT:ip4_frags_fails_cur:%s %%5.0lf%%s" % _("Now"), | |
135 | "GPRINT:ip4_frags_fails_avg:%s %%5.0lf%%s" % _("Avg"), | |
136 | "GPRINT:ip4_frags_fails_max:%s %%5.0lf%%s" % _("Max"), | |
137 | "GPRINT:ip4_frags_fails_min:%s %%5.0lf%%s\\j" % _("Min"), | |
138 | ||
139 | "LINE2:ip4_frags_oks%s:%-24s" % (COLOUR_OK, _("Fragmented Packets")), | |
140 | "GPRINT:ip4_frags_oks_cur:%s %%5.0lf%%s" % _("Now"), | |
141 | "GPRINT:ip4_frags_oks_avg:%s %%5.0lf%%s" % _("Avg"), | |
142 | "GPRINT:ip4_frags_oks_max:%s %%5.0lf%%s" % _("Max"), | |
143 | "GPRINT:ip4_frags_oks_min:%s %%5.0lf%%s\\j" % _("Min"), | |
29455c5f MT |
144 | ] |
145 | ||
146 | @property | |
147 | def graph_title(self): | |
148 | _ = self.locale.translate | |
149 | ||
150 | if self.object.interface: | |
151 | return _("IPv4 Fragmentation on %s") % self.object.interface | |
152 | ||
153 | return _("IPv4 Fragmentation") | |
154 | ||
155 | @property | |
156 | def graph_vertical_label(self): | |
157 | _ = self.locale.translate | |
158 | return _("Packets/s") | |
159 | ||
160 | @property | |
161 | def rrd_graph_args(self): | |
162 | return [ | |
163 | "--base", "1000", | |
164 | "--legend-direction=bottomup", | |
165 | ] | |
166 | ||
167 | ||
168 | class IPFragmentationObject(base.Object): | |
169 | rrd_schema = [ | |
170 | "DS:ip6_frags_oks:DERIVE:0:U", | |
171 | "DS:ip6_frags_fails:DERIVE:0:U", | |
172 | "DS:ip6_frags_creates:DERIVE:0:U", | |
173 | "DS:ip6_reasm_timeout:DERIVE:0:U", | |
174 | "DS:ip6_reasm_reqds:DERIVE:0:U", | |
175 | "DS:ip6_reasm_oks:DERIVE:0:U", | |
176 | "DS:ip6_reasm_fails:DERIVE:0:U", | |
177 | "DS:ip4_frags_oks:DERIVE:0:U", | |
178 | "DS:ip4_frags_fails:DERIVE:0:U", | |
179 | "DS:ip4_frags_creates:DERIVE:0:U", | |
180 | "DS:ip4_reasm_timeout:DERIVE:0:U", | |
181 | "DS:ip4_reasm_reqds:DERIVE:0:U", | |
182 | "DS:ip4_reasm_oks:DERIVE:0:U", | |
183 | "DS:ip4_reasm_fails:DERIVE:0:U", | |
184 | ] | |
185 | ||
186 | def __repr__(self): | |
187 | if self.interface: | |
188 | return "<%s %s>" % (self.__class__.__name__, self.interface) | |
189 | ||
190 | return "<%s>" % self.__class__.__name__ | |
191 | ||
192 | def init(self, interface=None): | |
193 | self.interface = interface | |
194 | ||
195 | @property | |
196 | def id(self): | |
197 | return self.interface or "default" | |
198 | ||
199 | def collect(self): | |
200 | p = util.ProcNetSnmpParser(self.interface) | |
201 | ||
202 | # Description in RFC2465 | |
203 | results = [ | |
204 | p.get("Ip6", "FragOKs"), | |
205 | p.get("Ip6", "FragFails"), | |
206 | p.get("Ip6", "FragCreates"), | |
207 | p.get("Ip6", "ReasmTimeout"), | |
208 | p.get("Ip6", "ReasmReqds"), | |
209 | p.get("Ip6", "ReasmOKs"), | |
210 | p.get("Ip6", "ReasmFails"), | |
211 | p.get("Ip", "FragOKs"), | |
212 | p.get("Ip", "FragFails"), | |
213 | p.get("Ip", "FragCreates"), | |
214 | p.get("Ip", "ReasmTimeout"), | |
215 | p.get("Ip", "ReasmReqds"), | |
216 | p.get("Ip", "ReasmOKs"), | |
217 | p.get("Ip", "ReasmFails"), | |
218 | ] | |
219 | ||
220 | return results | |
221 | ||
222 | ||
223 | class IPFragmentationPlugin(base.Plugin): | |
224 | name = "ip-fragmentation" | |
225 | description = "IP Fragmentation Plugin" | |
226 | ||
227 | templates = [ | |
228 | GraphTemplateIPv6Fragmentation, | |
229 | GraphTemplateIPv4Fragmentation, | |
230 | ] | |
231 | ||
232 | @property | |
233 | def objects(self): | |
234 | # Overall statistics | |
235 | yield IPFragmentationObject(self) | |
236 | ||
237 | # Stats per interface | |
238 | for interface in util.get_network_interfaces(): | |
239 | yield IPFragmentationObject(self, interface) |