Skip to content

Commit

Permalink
fix errors and typos
Browse files Browse the repository at this point in the history
  • Loading branch information
kuronosec committed Nov 2, 2023
1 parent 68e5691 commit 6dea026
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
data
.env*
venv*
14 changes: 9 additions & 5 deletions tikuna/sensor/log_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import json
import requests
import os
import threading
import logging

from os.path import join, dirname
from dotenv import load_dotenv
from threading import Thread, Event
Expand All @@ -17,17 +20,18 @@
TIKUNA_SERVER_URL = os.environ.get("TIKUNA_SERVER_URL")

class LogSensor(threading.Thread):

def __init__(self, client):
self.dkg = client.containers.get(client).logs(stream = True, follow = True, tail = 10)

def __init__(self, node_name):
super(LogSensor, self).__init__()
self.dkg = client.containers.get(node_name).logs(stream = True, follow = True, tail = 10)

def start_data_stream(self):
try:
print("Starting %s log collection..." % client)
logs_added = 0
log_list = []
while True:
line = next(dkg).decode("utf-8")
line = next(self.dkg).decode("utf-8")
if "Tikuna log" in line and "removed" in line:
line = ansi_escape.sub('', line)
words = line.split()
Expand All @@ -54,4 +58,4 @@ def run(self):
self.start_data_stream()

def stop(self):
pass
pass
9 changes: 5 additions & 4 deletions tikuna/sensor/sensor_daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from daemon import Daemon
from queue import Queue, Empty
from tikuna.sensor.log_sensor import LogSensor
from log_sensor import LogSensor

# The tikuna daemon service that collects security
# monitoring information.
Expand All @@ -21,10 +21,11 @@ def run(self):
logging.basicConfig(filename=log_file,
level=logging.INFO)
logging.info('Creating tikuna client services...')
log_sensor_service = tikunaSensors(None)
log_sensor_service = LogSensor("prysm-beacon")
# Start the services.
logging.info('Starting the tikuna client services...')
log_sensor_service.start_sensors()
log_sensor_service.start()
logging.info("Sensors started.")
logging.info('tikuna service client started...')

def stop(self):
Expand All @@ -48,4 +49,4 @@ def stop(self):
sys.exit(0)
else:
print("usage: %s start|stop|restart" % sys.argv[0])
sys.exit(2)
sys.exit(2)

0 comments on commit 6dea026

Please sign in to comment.