]> git.ipfire.org Git - collecty.git/blobdiff - src/collecty/plugins/interface.py
Add graphs for IP fragmentation
[collecty.git] / src / collecty / plugins / interface.py
index 135a59c2348fef98ee32503c391fe11c4b7071ff..f0dcef50325bf22c00e0ec39426709227e4ad0f0 100644 (file)
 #                                                                             #
 ###############################################################################
 
-
-
 import os
 
 from . import base
+from .. import util
 
 from ..i18n import _
 
-SYS_CLASS_NET = "/sys/class/net"
-
 COLOUR_RX = "B22222"
 COLOUR_RX_AREA = "%sAA" % COLOUR_RX
 COLOUR_TX = "228B22"
@@ -243,7 +240,7 @@ class InterfaceObject(base.Object):
                return self.interface
 
        def collect(self):
-               interface_path = os.path.join(SYS_CLASS_NET, self.interface)
+               interface_path = os.path.join("/sys/class/net", self.interface)
 
                # Check if the interface exists.
                if not os.path.exists(interface_path):
@@ -295,19 +292,7 @@ class InterfacePlugin(base.Plugin):
 
        interval = 30
 
-       def get_interfaces(self):
-               for interface in os.listdir(SYS_CLASS_NET):
-                       # Skip some unwanted interfaces.
-                       if interface == "lo" or interface.startswith("mon."):
-                               continue
-
-                       path = os.path.join(SYS_CLASS_NET, interface)
-                       if not os.path.isdir(path):
-                               continue
-
-                       yield interface
-
        @property
        def objects(self):
-               for interface in self.get_interfaces():
+               for interface in util.get_network_interfaces():
                        yield InterfaceObject(self, interface=interface)