]> git.ipfire.org Git - collecty.git/blame - src/collecty/plugins/conntrack.py
locales: Drop our custom module
[collecty.git] / src / collecty / plugins / conntrack.py
CommitLineData
f37913e8 1#!/usr/bin/python3
0ec1854a
MT
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
f37913e8 22from . import base
0ec1854a 23
03ba5630 24from ..colours import *
9b315095 25from ..constants import *
72fc5ca5 26from ..i18n import _
0308c0f3 27
9b315095
MT
28class ConntrackGraphTemplate(base.GraphTemplate):
29 name = "conntrack"
0308c0f3 30
9b315095 31 lower_limit = 0
0308c0f3
MT
32
33 @property
34 def rrd_graph(self):
0308c0f3 35 return [
9b315095
MT
36 "COMMENT:%s" % EMPTY_LABEL,
37 "COMMENT:%s" % (COLUMN % _("Current")),
38 "COMMENT:%s" % (COLUMN % _("Average")),
39 "COMMENT:%s" % (COLUMN % _("Minimum")),
40 "COMMENT:%s\\j" % (COLUMN % _("Maximum")),
41
42 "AREA:count%s:%s" % (
43 transparency(PRIMARY, AREA_OPACITY),
44 LABEL % _("Entries"),
45 ),
46 "GPRINT:count_cur:%s" % INTEGER,
47 "GPRINT:count_avg:%s" % INTEGER,
48 "GPRINT:count_min:%s" % INTEGER,
49 "GPRINT:count_max:%s" % INTEGER,
50 "LINE1:count%s" % PRIMARY,
51
52 # Draw maximum line
53 "LINE:max%s:%s:dashes:skipscale" % (
54 COLOUR_CRITICAL, LABEL % _("Maximum"),
55 ),
76c12e91 56 ]
cd8bba0b 57
0308c0f3
MT
58 @property
59 def graph_title(self):
9b315095 60 return _("Connection Tracking Table")
0308c0f3
MT
61
62 @property
63 def graph_vertical_label(self):
9b315095 64 return _("Entries")
0308c0f3
MT
65
66
0ec1854a 67class ConntrackObject(base.Object):
0ec1854a 68 rrd_schema = [
9b315095
MT
69 "DS:count:GAUGE:0:U",
70 "DS:max:GAUGE:0:U",
0ec1854a
MT
71 ]
72
73 @property
74 def id(self):
9b315095 75 return "default"
0ec1854a
MT
76
77 def collect(self):
9b315095
MT
78 """
79 Read count and max values from /proc
80 """
81 return (
82 self.read_file_integer("/proc/sys/net/netfilter/nf_conntrack_count"),
83 self.read_file_integer("/proc/sys/net/netfilter/nf_conntrack_max"),
84 )
0ec1854a
MT
85
86
87class ConntrackPlugin(base.Plugin):
88 name = "conntrack"
89 description = "Conntrack Plugin"
90
0308c0f3 91 templates = [
9b315095 92 ConntrackGraphTemplate,
0308c0f3 93 ]
0ec1854a
MT
94
95 @property
96 def objects(self):
9b315095 97 yield ConntrackObject(self)