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 ..colours
import *
28 from ..constants
import *
31 class GraphTemplateIPv6Fragmentation(base
.GraphTemplate
):
32 name
= "ipv6-fragmentation"
36 _
= self
.locale
.translate
39 "CDEF:ip6_reasm_real_fails=ip6_reasm_fails,ip6_reasm_timeout,-",
42 "AREA:ip6_reasm_real_fails%s:%-24s" % \
43 (util
.lighten(COLOUR_ERROR
), _("Failed Reassemblies")),
44 "GPRINT:ip6_reasm_fails_cur:%s %%5.0lf%%s" % _("Now"),
45 "GPRINT:ip6_reasm_fails_avg:%s %%5.0lf%%s" % _("Avg"),
46 "GPRINT:ip6_reasm_fails_max:%s %%5.0lf%%s" % _("Max"),
47 "GPRINT:ip6_reasm_fails_min:%s %%5.0lf%%s\\j" % _("Min"),
49 "AREA:ip6_reasm_timeout%s:%-24s:STACK" % \
50 (util
.lighten(COLOUR_WARN
), _("Reassembly Timeouts")),
51 "GPRINT:ip6_reasm_timeout_cur:%s %%5.0lf%%s" % _("Now"),
52 "GPRINT:ip6_reasm_timeout_avg:%s %%5.0lf%%s" % _("Avg"),
53 "GPRINT:ip6_reasm_timeout_max:%s %%5.0lf%%s" % _("Max"),
54 "GPRINT:ip6_reasm_timeout_min:%s %%5.0lf%%s\\j" % _("Min"),
56 "LINE2:ip6_reasm_oks%s:%-24s" % (BLACK
, _("Successful Reassemblies")),
57 "GPRINT:ip6_reasm_oks_cur:%s %%5.0lf%%s" % _("Now"),
58 "GPRINT:ip6_reasm_oks_avg:%s %%5.0lf%%s" % _("Avg"),
59 "GPRINT:ip6_reasm_oks_max:%s %%5.0lf%%s" % _("Max"),
60 "GPRINT:ip6_reasm_oks_min:%s %%5.0lf%%s\\j" % _("Min"),
62 "COMMENT: \\n", # empty line
65 "LINE2:ip6_frags_fails%s:%-24s" % (COLOUR_ERROR
, _("Failed Fragmentations")),
66 "GPRINT:ip6_frags_fails_cur:%s %%5.0lf%%s" % _("Now"),
67 "GPRINT:ip6_frags_fails_avg:%s %%5.0lf%%s" % _("Avg"),
68 "GPRINT:ip6_frags_fails_max:%s %%5.0lf%%s" % _("Max"),
69 "GPRINT:ip6_frags_fails_min:%s %%5.0lf%%s\\j" % _("Min"),
71 "LINE2:ip6_frags_oks%s:%-24s" % (COLOUR_OK
, _("Fragmented Packets")),
72 "GPRINT:ip6_frags_oks_cur:%s %%5.0lf%%s" % _("Now"),
73 "GPRINT:ip6_frags_oks_avg:%s %%5.0lf%%s" % _("Avg"),
74 "GPRINT:ip6_frags_oks_max:%s %%5.0lf%%s" % _("Max"),
75 "GPRINT:ip6_frags_oks_min:%s %%5.0lf%%s\\j" % _("Min"),
79 def graph_title(self
):
80 _
= self
.locale
.translate
82 if self
.object.interface
:
83 return _("IPv6 Fragmentation on %s") % self
.object.interface
85 return _("IPv6 Fragmentation")
88 def graph_vertical_label(self
):
89 _
= self
.locale
.translate
93 def rrd_graph_args(self
):
96 "--legend-direction=bottomup",
100 class GraphTemplateIPv4Fragmentation(base
.GraphTemplate
):
101 name
= "ipv4-fragmentation"
105 _
= self
.locale
.translate
108 "CDEF:ip4_reasm_real_fails=ip4_reasm_fails,ip4_reasm_timeout,-",
111 "AREA:ip4_reasm_real_fails%s:%-24s" % \
112 (util
.lighten(COLOUR_ERROR
), _("Failed Reassemblies")),
113 "GPRINT:ip4_reasm_fails_cur:%s %%5.0lf%%s" % _("Now"),
114 "GPRINT:ip4_reasm_fails_avg:%s %%5.0lf%%s" % _("Avg"),
115 "GPRINT:ip4_reasm_fails_max:%s %%5.0lf%%s" % _("Max"),
116 "GPRINT:ip4_reasm_fails_min:%s %%5.0lf%%s\\j" % _("Min"),
118 "AREA:ip4_reasm_timeout%s:%-24s:STACK" % \
119 (util
.lighten(COLOUR_WARN
), _("Reassembly Timeouts")),
120 "GPRINT:ip4_reasm_timeout_cur:%s %%5.0lf%%s" % _("Now"),
121 "GPRINT:ip4_reasm_timeout_avg:%s %%5.0lf%%s" % _("Avg"),
122 "GPRINT:ip4_reasm_timeout_max:%s %%5.0lf%%s" % _("Max"),
123 "GPRINT:ip4_reasm_timeout_min:%s %%5.0lf%%s\\j" % _("Min"),
125 "LINE2:ip4_reasm_oks%s:%-24s" % (BLACK
, _("Successful Reassemblies")),
126 "GPRINT:ip4_reasm_oks_cur:%s %%5.0lf%%s" % _("Now"),
127 "GPRINT:ip4_reasm_oks_avg:%s %%5.0lf%%s" % _("Avg"),
128 "GPRINT:ip4_reasm_oks_max:%s %%5.0lf%%s" % _("Max"),
129 "GPRINT:ip4_reasm_oks_min:%s %%5.0lf%%s\\j" % _("Min"),
131 "COMMENT: \\n", # empty line
134 "LINE2:ip4_frags_fails%s:%-24s" % (COLOUR_ERROR
, _("Failed Fragmentations")),
135 "GPRINT:ip4_frags_fails_cur:%s %%5.0lf%%s" % _("Now"),
136 "GPRINT:ip4_frags_fails_avg:%s %%5.0lf%%s" % _("Avg"),
137 "GPRINT:ip4_frags_fails_max:%s %%5.0lf%%s" % _("Max"),
138 "GPRINT:ip4_frags_fails_min:%s %%5.0lf%%s\\j" % _("Min"),
140 "LINE2:ip4_frags_oks%s:%-24s" % (COLOUR_OK
, _("Fragmented Packets")),
141 "GPRINT:ip4_frags_oks_cur:%s %%5.0lf%%s" % _("Now"),
142 "GPRINT:ip4_frags_oks_avg:%s %%5.0lf%%s" % _("Avg"),
143 "GPRINT:ip4_frags_oks_max:%s %%5.0lf%%s" % _("Max"),
144 "GPRINT:ip4_frags_oks_min:%s %%5.0lf%%s\\j" % _("Min"),
148 def graph_title(self
):
149 _
= self
.locale
.translate
151 if self
.object.interface
:
152 return _("IPv4 Fragmentation on %s") % self
.object.interface
154 return _("IPv4 Fragmentation")
157 def graph_vertical_label(self
):
158 _
= self
.locale
.translate
159 return _("Packets/s")
162 def rrd_graph_args(self
):
165 "--legend-direction=bottomup",
169 class IPFragmentationObject(base
.Object
):
171 "DS:ip6_frags_oks:DERIVE:0:U",
172 "DS:ip6_frags_fails:DERIVE:0:U",
173 "DS:ip6_frags_creates:DERIVE:0:U",
174 "DS:ip6_reasm_timeout:DERIVE:0:U",
175 "DS:ip6_reasm_reqds:DERIVE:0:U",
176 "DS:ip6_reasm_oks:DERIVE:0:U",
177 "DS:ip6_reasm_fails:DERIVE:0:U",
178 "DS:ip4_frags_oks:DERIVE:0:U",
179 "DS:ip4_frags_fails:DERIVE:0:U",
180 "DS:ip4_frags_creates:DERIVE:0:U",
181 "DS:ip4_reasm_timeout:DERIVE:0:U",
182 "DS:ip4_reasm_reqds:DERIVE:0:U",
183 "DS:ip4_reasm_oks:DERIVE:0:U",
184 "DS:ip4_reasm_fails:DERIVE:0:U",
189 return "<%s %s>" % (self
.__class
__.__name
__, self
.interface
)
191 return "<%s>" % self
.__class
__.__name
__
193 def init(self
, interface
=None):
194 self
.interface
= interface
198 return self
.interface
or "default"
201 p
= util
.ProcNetSnmpParser(self
.interface
)
203 # Description in RFC2465
205 p
.get("Ip6", "FragOKs"),
206 p
.get("Ip6", "FragFails"),
207 p
.get("Ip6", "FragCreates"),
208 p
.get("Ip6", "ReasmTimeout"),
209 p
.get("Ip6", "ReasmReqds"),
210 p
.get("Ip6", "ReasmOKs"),
211 p
.get("Ip6", "ReasmFails"),
212 p
.get("Ip", "FragOKs"),
213 p
.get("Ip", "FragFails"),
214 p
.get("Ip", "FragCreates"),
215 p
.get("Ip", "ReasmTimeout"),
216 p
.get("Ip", "ReasmReqds"),
217 p
.get("Ip", "ReasmOKs"),
218 p
.get("Ip", "ReasmFails"),
224 class IPFragmentationPlugin(base
.Plugin
):
225 name
= "ip-fragmentation"
226 description
= "IP Fragmentation Plugin"
229 GraphTemplateIPv6Fragmentation
,
230 GraphTemplateIPv4Fragmentation
,
236 yield IPFragmentationObject(self
)
238 # Stats per interface
239 for interface
in util
.get_network_interfaces():
240 yield IPFragmentationObject(self
, interface
)