Skip to content

Instantly share code, notes, and snippets.

@JustinAzoff
Last active January 15, 2016 20:22
Show Gist options
  • Save JustinAzoff/4cfe3995013225d1d119 to your computer and use it in GitHub Desktop.
Save JustinAzoff/4cfe3995013225d1d119 to your computer and use it in GitHub Desktop.

Revisions

  1. JustinAzoff revised this gist Nov 30, 2015. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions InterfaceSetup.py
    Original file line number Diff line number Diff line change
    @@ -25,7 +25,7 @@ def init(self):
    return True

    def options(self):
    return [("mtu", "int", "9000", "Interface MTU"),
    return [("mtu", "int", "9710", "Interface MTU"),
    ("enabled", "string", "0", "Set to enable plugin")]

    def cmd_start_pre(self, nodes):
    @@ -38,7 +38,7 @@ def cmd_start_pre(self, nodes):
    host_nodes = {}
    for n in nodes:
    if n.interface:
    host_nodes[n.host] = n
    host_nodes[(n.host, n.interface)] = n

    cmds = []
    for n in host_nodes.values():
  2. JustinAzoff created this gist Apr 9, 2015.
    50 changes: 50 additions & 0 deletions InterfaceSetup.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,50 @@
    #
    # A plugin to setup capture interfaces
    # The plugin is off by default. To enable it, add "interfacesetup.enabled=1" to broctl.cfg.
    #

    import BroControl.plugin

    class InterfaceSetupPlugin(BroControl.plugin.Plugin):
    def __init__(self):
    super(InterfaceSetupPlugin, self).__init__(apiversion=1)

    def name(self):
    return "InterfaceSetupPlugin"

    def prefix(self):
    return "interfacesetup"

    def pluginVersion(self):
    return 1

    def init(self):
    if self.getOption("enabled") == "0":
    return False

    return True

    def options(self):
    return [("mtu", "int", "9000", "Interface MTU"),
    ("enabled", "string", "0", "Set to enable plugin")]

    def cmd_start_pre(self, nodes):
    if not nodes:
    return

    mtu = self.getOption("mtu")
    self.message("InterfaceSetupPlugin: mtu=%s" % (mtu))

    host_nodes = {}
    for n in nodes:
    if n.interface:
    host_nodes[n.host] = n

    cmds = []
    for n in host_nodes.values():
    cmd = "/sbin/ifconfig %s up mtu %s" % (n.interface, mtu)
    cmds.append((n, cmd))
    cmd = "/sbin/ethtool -K %s gro off lro off rx off tx off gso off" % (n.interface)
    cmds.append((n, cmd))

    self.executeParallel(cmds)