Right now we are having it log to are syslog via JSON, OSSEC.conf entry below:
<syslog_output>
<server>SERVER</server>
<format>json</format>
<level>1</level>
</syslog_output>
Here is a current example of the output we are getting:
2015-06-04T17:45:20-04:00 <OSSEC-SERVER> ossec: {"crit":3,"id":5715,"component":"(<OSSEC-Agent>) <AGENT-IP>->/var/log/authlog","classification":" syslog,sshd,authentication_success,","description":"SSHD authentication success.","message":"2015-06-04T13:45:18-04:00 <OSSEC-AGENT> sshd[47789]: [ID 800047 auth.info] Accepted publickey for <USER> from <AGENT-IP> port 45430 ssh2","acct":"<AGENT-IP>","src_ip":"<IP>"}
I have a few years of python and C programming under my belt, so if there is a source file I can modify and recompile i would be ok with doing that.
Any help that can be offered is thanked deeply in advance,
Jacob
def follow(filename):
try:
list_of_lines = []
fd = os.open(filename, os.O_RDONLY|os.O_NONBLOCK)
os.lseek(fd, 0, os.SEEK_END)
while True:
lines = os.read(fd, 4096).splitlines()
if not lines:
continue
else:
for line in lines:
list_of_lines.append(line)
length_of_line = len(list_of_lines) - 1
list_of_lines.pop(length_of_line)
log_to_syslog(list_of_lines[len(list_of_lines) - 1])
del list_of_lines[:]
os.close(fd)
except(KeyboardInterrupt):
print("[*] Ctrl-C Pressed")
logger = logging.getLogger()
logger.setLevel(logging.INFO)
handler = logging.handlers.SysLogHandler(address=(<server name goes here>, 514),
socktype=socket.SOCK_DGRAM)
formatter = logging.Formatter('ossec: %(message)s')
handler.setFormatter(formatter)
logger.addHandler(handler)