Skip to content

Commit

Permalink
Merge branch 'distributed_log_rotation' of https://github.com/stefanm…
Browse files Browse the repository at this point in the history
…aerz/broctl

* 'distributed_log_rotation' of https://github.com/stefanmaerz/broctl:
  Adding support for log rotation for distributed loggers.

I made changes to get this to still work in standalone mode and also to
depend on node type rather than node name.
  • Loading branch information
jsiwek committed Jan 4, 2019
2 parents 31e4e73 + da5d650 commit 4808c07
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
23 changes: 20 additions & 3 deletions BroControl/cron.py
Expand Up @@ -6,6 +6,7 @@

from BroControl import execute
from BroControl import py3bro
from BroControl import node as node_mod

class CronUI:
def __init__(self):
Expand Down Expand Up @@ -121,10 +122,26 @@ def expire_logs(self):
if self.config.logexpireminutes == 0 and self.config.statslogexpireinterval == 0:
return

success, output = execute.run_localcmd(os.path.join(self.config.scriptsdir, "expire-logs"))
if self.config.standalone:
success, output = execute.run_localcmd(os.path.join(self.config.scriptsdir, "expire-logs"))

if not success:
self.ui.error("expire-logs failed\n%s" % output)
else:
nodes = self.config.hosts(tag=node_mod.logger_group())

if not nodes:
nodes = self.config.hosts(tag=node_mod.manager_group())

expirelogs = os.path.join(self.config.scriptsdir, "expire-logs")
cmds = [(node, expirelogs, []) for node in nodes]

for (node, success, output) in self.executor.run_cmds(cmds):
if not success:
self.ui.error("expire-logs failed for node %s\n" % node)
if output:
self.ui.error(output)

if not success:
self.ui.error("expire-logs failed\n%s" % output)

def expire_crash(self):
if self.config.crashexpireinterval == 0:
Expand Down
4 changes: 4 additions & 0 deletions CHANGES
@@ -1,4 +1,8 @@

1.9-11 | 2019-01-04 13:10:54 -0600

* Adding support for log rotation/expiration for distributed loggers. (Stefan Maerz)

1.9-8 | 2018-12-10 15:07:31 -0600

* Change Travis btest commnad to help isolate hung tests (Jon Siwek, Corelight)
Expand Down
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
1.9-8
1.9-11
2 changes: 1 addition & 1 deletion doc/main.rst
Expand Up @@ -3,7 +3,7 @@
.. Note: This file includes further autogenerated ones.
..
.. Version number is filled in automatically.
.. |version| replace:: 1.9-8
.. |version| replace:: 1.9-11

==========
BroControl
Expand Down

0 comments on commit 4808c07

Please sign in to comment.