2 ###############################################################################
4 # collecty - A system statistics collection daemon for IPFire #
5 # Copyright (C) 2015 IPFire development team #
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. #
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. #
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/>. #
20 ###############################################################################
27 from ..constants
import *
30 class GraphTemplateIPv6Fragmentation(base
.GraphTemplate
):
31 name
= "ipv6-fragmentation"
35 _
= self
.locale
.translate
38 "CDEF:ip6_reasm_real_fails=ip6_reasm_fails,ip6_reasm_timeout,-",
41 "AREA:ip6_reasm_real_fails%s:%-24s" % \
42 (util
.lighten(COLOUR_ERROR
), _("Failed Reassemblies")),
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"),
48 "AREA:ip6_reasm_timeout%s:%-24s:STACK" % \
49 (util
.lighten(COLOUR_WARN
), _("Reassembly Timeouts")),
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"),
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"),
61 "COMMENT: \\n", # empty line
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"),
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"),
78 def graph_title(self
):
79 _
= self
.locale
.translate
81 if self
.object.interface
:
82 return _("IPv6 Fragmentation on %s") % self
.object.interface
84 return _("IPv6 Fragmentation")
87 def graph_vertical_label(self
):
88 _
= self
.locale
.translate
92 def rrd_graph_args(self
):
95 "--legend-direction=bottomup",
99 class GraphTemplateIPv4Fragmentation(base
.GraphTemplate
):
100 name
= "ipv4-fragmentation"
104 _
= self
.locale
.translate
107 "CDEF:ip4_reasm_real_fails=ip4_reasm_fails,ip4_reasm_timeout,-",
110 "AREA:ip4_reasm_real_fails%s:%-24s" % \
111 (util
.lighten(COLOUR_ERROR
), _("Failed Reassemblies")),
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"),
117 "AREA:ip4_reasm_timeout%s:%-24s:STACK" % \
118 (util
.lighten(COLOUR_WARN
), _("Reassembly Timeouts")),
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"),
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"),
130 "COMMENT: \\n", # empty line
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"),
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"),
147 def graph_title(self
):
148 _
= self
.locale
.translate
150 if self
.object.interface
:
151 return _("IPv4 Fragmentation on %s") % self
.object.interface
153 return _("IPv4 Fragmentation")
156 def graph_vertical_label(self
):
157 _
= self
.locale
.translate
158 return _("Packets/s")
161 def rrd_graph_args(self
):
164 "--legend-direction=bottomup",
168 class IPFragmentationObject(base
.Object
):
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",
188 return "<%s %s>" % (self
.__class
__.__name
__, self
.interface
)
190 return "<%s>" % self
.__class
__.__name
__
192 def init(self
, interface
=None):
193 self
.interface
= interface
197 return self
.interface
or "default"
200 p
= util
.ProcNetSnmpParser(self
.interface
)
202 # Description in RFC2465
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"),
223 class IPFragmentationPlugin(base
.Plugin
):
224 name
= "ip-fragmentation"
225 description
= "IP Fragmentation Plugin"
228 GraphTemplateIPv6Fragmentation
,
229 GraphTemplateIPv4Fragmentation
,
235 yield IPFragmentationObject(self
)
237 # Stats per interface
238 for interface
in util
.get_network_interfaces():
239 yield IPFragmentationObject(self
, interface
)