Comments (9)
It should read newer files.. Does it appear to be stuck on this file and not progressing to newer ones? What are the timestamps of the other files?
from py-idstools.
It does seem to get stuck, until I remove the bookmark and zero-sized files. The timestamps on the other files are afterwards ... i.e. the order is chronological as they happened via snort.
from py-idstools.
Have a test (manual, automated, whatever) that can demonstrate this? I just tested with idstools-u2json which uses unified2.SpoolEventReader. I created a 0 size unified2 file in my log directory with a timestamp newer than the existing one. I then restarted Snort which results in an even newer one being created. unified2.SpoolEventReader opened the 0 size file, deleted it then continued onto the newer file. What arguments are you creating SpoolEventReader with?
0 size files aren't that uncommon. If Snort is started, then restarted before any events are logged, you will get 0 sized unified2 files.
from py-idstools.
Well, I will have to check with the client for the files that currently cause this, but it sounds like you've tried the same situation but with success.
My call to SpoolEventReader is this:
u2json_reader = unified2.SpoolEventReader(
directory=args.unified2_directory,
prefix=args.unified2_prefix,
follow=args.unified2_follow,
bookmark=args.unified2_bookmark
)
... which is used like so:
for ok, result in streaming_bulk(
client,
read_events_as_json(u2json_reader),
chunk_size=int(chunk_size)
):
... where read_events_as_json is a generator like:
for event in u2json_reader:
test_serializer = JSONSerializer().dumps(encoded_json)
yield encoded_json
... if that helps.
from py-idstools.
I didn't catch this in your response ...
"delete – If True, unified2 files will be deleted when reading has moved onto the next one."
... is that a required setting for this to work ?
I just assumed the bookmark was "remembering" where it was and in which file, thus skipping
any older files.
from py-idstools.
Just tested without delete=True. Still works. Have you configured logging? With a logger configured, the SpoolEventReader will log to stderr lines like:
Closed file /var/log/snort/unified2.log.1413323322, opened file /var/log/snort/unified2.log.1413401177
Closed file /var/log/snort/unified2.log.1413401177, opened file /var/log/snort/unified2.log.1413401186
Closed file /var/log/snort/unified2.log.1413401186, opened file /var/log/snort/unified2.log.1413401263
In this case I was running u2json like:
python /usr/bin/idstools-u2json --snort-conf=etc/snort.conf
--directory=/var/log/snort
--prefix=unified2.log
--output=/var/log/snort/alerts.json
--follow
--bookmark
--stdout
--packets
The first 2 log lines are the result of me doing "touch unified2.log.$(date +%s)" in order to generate 0 sized files. The third is the result of me restarting Snort. For me its working as designed which is:
- Read from currently opened file.
- If no data read, check directory for a newer file.
- If newer file exists, open it, and optionally delete the previous open file (delete=True)
from py-idstools.
If I may ask, how would I configure a logger ? I have this:
import logging
logging.basicConfig(level=logging.INFO, format="%(message)s")
LOG = logging.getLogger("U2ELog")
... but I don't see messages like "Closed file ...".
As I'm not using the idstools' scripts in bin, perhaps I've missed something.
Also, our upstart script is:
description "U2E Indexer"
start on runlevel [2345]
stop on runlevel [016]
chdir /some/folder/u2e_indexer
exec /usr/bin/python u2e_indexer.py @u2e.args >> /var/log/u2e_indexer/indexer.log 2>&1
... I thought the ">> /var/log/u2e_indexer/indexer.log 2>&1" would redirect all stdout/stderr to
the log file.
Again, thanks for all of the info/testing.
from py-idstools.
That should do it.. For example, the u2json entry script has:
import logging
logging.basicConfig(level=logging.INFO, format="%(message)s")
And the unified2.SpoolEventReader will call:
if closed:
LOG.info("Closed file %s, opened file %s", closed, opened)
else:
LOG.info("Opened file %s", opened)
So yes, it looks like it should end up in your indexer.log.
Sorry I can't be much more help - until I can reproduce the issue of course.
from py-idstools.
I'm sure there's something in my code or our setup, so I'll close this but thanks for all your help.
from py-idstools.
Related Issues (20)
- appStats u2 can't work HOT 1
- Bug: Multiple instances of rule options fields clobber eachother HOT 4
- Recent versions of Snort unified2 not supported. HOT 5
- Feature Request: ability to parse the source, destination, protocol using dictionary.
- SoolRecordReader stop working HOT 2
- eve2pcap.py fails with IPv6 addresses HOT 1
- python2-scapy as pkg dependency
- Connection with suricata-update HOT 2
- Coverting packets object to pcap file HOT 7
- Feature request: mutate metadata key value pairs
- Add .md5 extension between URL's filename and its parameters HOT 1
- Provide option for idstools-u2eve to reload sid-msg.map after updating sid-msg.map contents. HOT 1
- Unified2 Event Types mpls, vlan, and appid not included in u2eve output
- u2json event.appid output is in byte format and mangled
- Tests fail with python 3.11 HOT 1
- Rule parsing fails if last option doesn't close with semi-colon HOT 1
- memory usage increase issue HOT 3
- New release to support python 3.13 HOT 6
- Wrong parsing of pcre and possibly others
- Invalid issue
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from py-idstools.