Commit graph

427 commits

Author SHA1 Message Date
Matthias Vallentin
1ce76da90f Use second granularity for ElasticSearch timeouts.
Since the millisecond resolution cannot be harnessed universally and is not
supported by older version of libcurl, we will allow only specifications at the
granularity of seconds.

This commit also fixes a typing issue that causes that prevented the
ElasticSearch timeout to work in the first place: curl_easy_setopt requires a
long but was given a uint64_t.
2012-09-27 16:34:16 -07:00
Matthias Vallentin
b73809d54f Fix compile issues with older versions of libcurl.
Older versions of libcurl do not offer *_MS timeout constants, which causes the
build to fail. For sub-second timeout specification, we now fall back to
hard-coded timeouts in older libcurl version.
2012-09-27 12:18:25 -07:00
Jon Siwek
06b7379bc3 Ignore small mem leak every rotation interval for dataseries logs.
Not sure if more can be done to work around it, but reported to
dataseries devs here: https://github.com/dataseries/DataSeries/issues/1

The core/leaks/dataseries-rotate.bro unit test fails without this.
2012-08-21 14:54:57 -05:00
Seth Hall
b13196cbf1 Fixed more potential problems with deadlocked ES threads and signals from libcurl. 2012-08-16 09:24:25 -04:00
Robin Sommer
9829cf9a29 Fixing little typo with big impact. 2012-08-03 10:45:45 -07:00
Jon Siwek
7b2c3db488 Improve log filter compatibility with remote logging.
If a log filter attempts to write to a path for which a writer is
already instantiated due to remote logging, it will re-use the writer
as long as the fields of the filter and writer are compatible, else
the filter path will be auto-adjusted to not conflict with existing
writer's.  Conflicts between two local filters are still always
auto-adjusted even if field types agree (since they could still
be semantically different).

Addresses #842.
2012-07-30 13:17:49 -05:00
Robin Sommer
38c2ee6894 Merge remote-tracking branch 'origin/fastpath'
* origin/fastpath:
  Add missing breaks to switch cases in ElasticSearch::HTTPReceive().
2012-07-30 09:13:49 -07:00
Jon Siwek
00d41bb549 Add missing breaks to switch cases in ElasticSearch::HTTPReceive().
Observed as reason for segfault in
testing/btest/scripts/check-test-all-policy.bro unit test when compiled
with optimizations.
2012-07-30 11:07:43 -05:00
Robin Sommer
4ba038070f Tweaking writer API for failed rotations.
There are now two FinishedRotation() methods, one that triggers
post-processing and one that doesn't. There's also insurance built in
against a writer not calling either (or both), in which case we abort
with an internal error.
2012-07-28 16:38:22 -07:00
Jon Siwek
4359bf6b42 Fix log manager hanging on waiting for pending file rotations.
This changes writer implementations to always respond to rotation
messages in their DoRotate() method, even for failure/no-op cases
with a new RotationFailedMessage.  This informs the manager to
decrement its count of pending rotations.

Addresses #860.
2012-07-28 16:23:59 -07:00
Robin Sommer
c66c6d7c46 Merge remote-tracking branch 'origin/fastpath'
* origin/fastpath:
  Small (potential performance) improvement for logging framework.
  Script-level rotation postprocessor fix.
  update input framework documentation to reflect want_record change.
  Fix crash when encountering an InterpreterException in a predicate in logging or input Framework.
  make want_record=T the default for events
2012-07-27 12:26:18 -07:00
Robin Sommer
1fd0d7a607 Changing the start/end markers in logs to open/close now reflecting
wall clock.

Triggers lots of (simple) baseline updates.
2012-07-27 12:15:21 -07:00
Bernhard Amann
f02ed65878 Fix crash when encountering an InterpreterException in a predicate in logging or input Framework.
Inputframework: did not contain any error handling for this case.

Logging framework: tried to catch the interpreter-exception. However the exception already was caught
by the call-function and not propagated. Instead, call returns a 0-pointer in this case, which
lead to a segmentation fault.
2012-07-26 21:51:29 -07:00
Robin Sommer
f5862fb014 Preventing writers/readers from receiving further messages after a
failure.

Once a writer/reader Do* method has returned false, no further ones
will be executed anymore. This is primarily a safety mechanism to make
it easier for writer/reader authors as otherwise they would often need
to track the failure state themselves (because with the now delayed
termination from the earlier commit, furhter messages can now still
arrive for a little bit).
2012-07-26 17:27:56 -07:00
Robin Sommer
d262a70509 Merge remote-tracking branch 'origin/fastpath'
Small tweak: I added the "same writer" constraint to the loop
condition as well. Makes sense?

* origin/fastpath:
  Change path conflicts between log filters to be auto-corrected.
2012-07-26 15:30:35 -07:00
Jon Siwek
63e8bf72ed Change path conflicts between log filters to be auto-corrected.
This change makes it so when differing logging filters on the same
stream attempt to write to the same writer/path combination, the path
of the filter doing the later write will be automatically adjusted so
that it does not conflict with the other.  The path is adjusted by
appending "-N", where N is the smallest integer greater or equal to 2
required to resolve the path name conflict.

Addresses #842.
2012-07-26 16:55:49 -05:00
Jon Siwek
734e5f68d3 Add more error handling for close() calls. 2012-07-26 12:40:12 -05:00
Bernhard Amann
d29e691da9 ...adapt to new api... 2012-07-25 15:05:08 -07:00
Bernhard Amann
da157c8ded Merge remote-tracking branch 'origin/master' into topic/bernhard/sqlite
Conflicts:
	scripts/base/frameworks/logging/__load__.bro
	src/CMakeLists.txt
	src/logging.bif
	src/types.bif
2012-07-25 15:04:23 -07:00
Seth Hall
f2a0afad3c Fixes to elasticsearch plugin to make libcurl handle http responses correctly. 2012-07-25 17:01:47 -04:00
Robin Sommer
a33e9a6941 Fixing FreeBSD compiler error. 2012-07-25 13:58:23 -07:00
Jon Siwek
2fafadd930 Fix differing log filters of streams from writing to same writer/path.
Since WriterFrontend objects are looked up internally by writer type and
path, and they also expect to write consistent field arguments, it could
be the case that more than one filter of a given stream attempts to
write to the same path (derived either from $path or $path_func fields
of the filter) with the same writer type.  This won't work, so now
WriterFrontend objects are bound to the filter that instantiated them so
that we can warn about other filters attempting to write to the
conflicting writer/path and the write can be skipped.  Remote logs don't
appear to suffer the same issue due to pre-filtering.

Addresses #842.
2012-07-25 12:20:12 -05:00
Daniel Thayer
b9a76d7ed0 Fix file permissions of log files
A recent commit was erroneously causing new log files to be created with
execute permissions.
2012-07-24 17:21:30 -05:00
Daniel Thayer
063fd204cc Merge remote-tracking branch 'origin/master' into fastpath 2012-07-24 17:13:05 -05:00
Robin Sommer
43752b3d9f Reverting accidentally committed changes.
Thanks, Bernhard!
2012-07-24 11:16:03 -07:00
Robin Sommer
0d748c117d Adding missing include needed on some systems. 2012-07-24 11:06:34 -07:00
Jon Siwek
d6da8365f5 Merge branch 'fastpath' of git://git.bro-ids.org/bro into fastpath 2012-07-24 11:27:05 -05:00
Bernhard Amann
13952154a1 add comparator functor to the info maps of readerbackend and readerwriteend.
This is required, because after the recent changes the info map containst a
char* as key. Without the comparator the map will compare the char addresses
for all operations - which is not really what we want.
2012-07-24 09:19:20 -07:00
Jon Siwek
3f4b4c88a6 Fix initialization of WriterFrontend names.
The string representation of the writer looked up based on the stream's
enum value instead of the writer's enum value, often causing this
component of the name to be "(null)" since a null pointer was returned
from the lookup.
2012-07-24 11:18:32 -05:00
Robin Sommer
c2e0949484 Merge remote-tracking branch 'remotes/origin/topic/jsiwek/ascii-timestamp-fix'
* remotes/origin/topic/jsiwek/ascii-timestamp-fix:
  Fix WriterBackend::WriterInfo serialization, reenable ascii start/end tags.
2012-07-23 16:36:55 -07:00
Robin Sommer
24aea295fa Merge branch 'topic/robin/master-test'
* topic/robin/master-test: (60 commits)
  Script fix for Linux.
  Updating test base line.
  Another small change to MsgThread API.
  Bug fix for BasicThread.
  make version_ok return true for TLSv12
  Sed usage in canonifier script didn't work on non-Linux systems.
  Changing HTTP DPD port 3138 to 3128.
  Temporarily removing tuning/logs-to-elasticsearch.bro from the test-all-policy.
  More documentation updates.
  Revert "Fixing calc_next_rotate to use UTC based time functions."
  Some documentation updates for elasticsearch plugin.
  Give configure a --disable-perftools option.
  Updating tests for the #start/#end change.
  Further threading and API restructuring for logging and input frameworks.
  Reworking forceful thread termination.
  Moving the ASCII writer over to use UNIX I/O rather than stdio.
  Further reworking the thread API.
  Reworking thread termination logic.
  If a thread doesn't terminate, we log that but not longer proceed (because it could hang later still).
  Removing the thread kill functionality.
  ...
2012-07-23 16:20:44 -07:00
Jon Siwek
9b0fe744f2 Fix WriterBackend::WriterInfo serialization, reenable ascii start/end tags.
Instantiations of WriterInfo in RemoteSerializer::ProcessLogCreateWriter()
would leave the network_time member uninitialized which could later
cause localtime_r() calls in Ascii::Timestamp() to return a null pointer
due to the bizarre input and giving that to strftime() causes it to segfault.
2012-07-23 16:47:44 -05:00
Robin Sommer
71fc2a1728 Another small change to MsgThread API.
Threads will now reliably get a call to DoFinish() no matter how the
thread terminates. This will always be called from within the thread,
whereas the destructor is called from the main thread after the child
thread has already terminated.

Also removing debugging code.

However, two problems remain with the ASCII writer (seeing them only
on MacOS):

    - the #start/#end timestamps contain only dummy values right now.
      The odd thing is that once I enable strftime() to print actual
      timestamps, I get crashes (even though strftime() is supposed to
      be thread-safe).

    - occassionally, there's still output missing in tests. In those
      cases, the file descriptor apparently goes bad: a write() will
      suddently return EBADF for reasons I don't understand yet.
2012-07-22 15:50:12 -07:00
Robin Sommer
eef8b7d1c4 Merge remote-tracking branch 'remotes/origin/topic/seth/elasticsearch' into topic/robin/master-test
I've only tested that it compiles, not whether it still works. The
fact that we don't have any tests for this makes me uneasy ...

* remotes/origin/topic/seth/elasticsearch: (35 commits)
  Some documentation updates for elasticsearch plugin.
  Temporarily removing the ES timeout because it works with signals and is incompatible with Bro threads.
  Changed ES index names to localtime and added a meta index.
  New script for easily duplicating logs to ElasticSearch.
  Some better elasticsearch reliability.
  Fixed small elasticsearch problem in configure output.
  Re-adding the needed call to FinishedRotation in the ES writer plugin.
  Tiny updates.
  Bringing elasticsearch branch up to date with master.
  Adding a define to make the stdint C macros available.
  Adding an extra header.
  Fixed a bug with messed up time value passing to elasticsearch.
  Small updates and a little standardization for config.h.in naming.
  Bug fixes.
  Bug fix and feature.
  Forgot to call the parent method for DoHeartBeat.
  Changed the escaping method.
  Flush logs to ES daemon as Bro is shutting down.
  Reduce the batch size to 1000 and add a maximum time interval for batches.
  Reworked bulk operation string construction to use ODesc and added json escaping.
  ...
2012-07-20 07:43:05 -07:00
Robin Sommer
5cfb8d65c3 Updating tests for the #start/#end change. 2012-07-19 22:28:55 -07:00
Robin Sommer
87e10b5f97 Further threading and API restructuring for logging and input
frameworks.

There were a number of cases that weren't thread-safe. In particular,
we don't use std::string anymore for anything that's passed between
threads (but instead plain old const char*, with manual memmory
managmenet).

This is still a check-point commit, I'll do more testing.
2012-07-19 22:28:30 -07:00
Robin Sommer
490859cfef Reworking forceful thread termination.
Ctrl-C now kills a thread even if it hangs at termination. And readded
a (rather long) timeout to kill threads automatically that don't
shutdown.
2012-07-19 21:22:28 -07:00
Robin Sommer
e90918aa50 Moving the ASCII writer over to use UNIX I/O rather than stdio. 2012-07-19 21:22:28 -07:00
Robin Sommer
f6b883bafc Further reworking the thread API. 2012-07-19 21:22:28 -07:00
Robin Sommer
f7a6407ab1 Reworking thread termination logic.
Turns out the finish methods weren't called correctly, caused by a
mess up with method names which all sounded too similar and the wrong
one ended up being called. I've reworked this by changing the
thread/writer/reader interfaces, which actually also simplifies them
by getting rid of the requirement for writer backends to call their
parent methods (i.e., less opportunity for errors).

This commit also includes the following (because I noticed the problem
above when working on some of these):

     - The ASCII log writer now includes "#start <timestamp>" and
      "#end <timestamp> lines in the each file. The latter supersedes
      Bernhard's "EOF" patch.

      This required a number of tests updates. The standard canonifier
      removes the timestamps, but some tests compare files directly,
      which doesn't work if they aren't printing out the same
      timestamps (like the comm tests).

     - The above required yet another change to the writer API to
       network_time to methods.

     - Renamed ASCII logger "header" options to "meta".

     - Fixes #763 "Escape # when first character in log file line".

All btests pass for me on Linux FC15. Will try MacOS next.
2012-07-19 21:22:22 -07:00
Robin Sommer
c8789cff94 If a thread doesn't terminate, we log that but not longer proceed
(because it could hang later still).

Also logging to stderr as well to make sure one sees it.

Also adding code to the ASCII writer to catch termination
inconsistencies.
2012-07-19 21:21:53 -07:00
Robin Sommer
f73eb3b086 Reworking thread termination logic.
Turns out the finish methods weren't called correctly, caused by a
mess up with method names which all sounded too similar and the wrong
one ended up being called. I've reworked this by changing the
thread/writer/reader interfaces, which actually also simplifies them
by getting rid of the requirement for writer backends to call their
parent methods (i.e., less opportunity for errors).

This commit also includes the following (because I noticed the problem
above when working on some of these):

     - The ASCII log writer now includes "#start <timestamp>" and
      "#end <timestamp> lines in the each file. The latter supersedes
      Bernhard's "EOF" patch.

      This required a number of tests updates. The standard canonifier
      removes the timestamps, but some tests compare files directly,
      which doesn't work if they aren't printing out the same
      timestamps (like the comm tests).

     - The above required yet another change to the writer API to
       network_time to methods.

     - Renamed ASCII logger "header" options to "meta".

     - Fixes #763 "Escape # when first character in log file line".

All btests pass for me on Linux FC15. Will try MacOS next.
2012-07-19 21:21:53 -07:00
Seth Hall
0c4c5ff335 Temporarily removing the ES timeout because it works with signals and is incompatible with Bro threads. 2012-07-19 12:14:13 -04:00
Seth Hall
1826827359 Changed ES index names to localtime and added a meta index. 2012-07-18 15:42:23 -04:00
Seth Hall
1fa182c169 Some better elasticsearch reliability.
- Added a configurable option for timing out ES HTTP requests.

 - Stop sending reporter messages after one message for one failure.
2012-07-18 00:00:31 -04:00
Seth Hall
6e5382da54 Re-adding the needed call to FinishedRotation in the ES writer plugin. 2012-07-10 23:49:31 -04:00
Seth Hall
728888ad45 Merge remote-tracking branch 'origin/master' into topic/seth/elasticsearch 2012-07-10 20:32:42 -04:00
Daniel Thayer
7f4b0b52f8 Fix compiler warnings
These changes eliminate 405 of 571 warnings seen on OS X 10.7.4 with clang.
2012-07-10 15:39:05 -05:00
Seth Hall
9b70ee8799 Tiny updates. 2012-07-09 16:50:42 -04:00
Seth Hall
84e91b8b8d Bringing elasticsearch branch up to date with master. 2012-07-09 16:38:05 -04:00