added start script
This commit is contained in:
@@ -102,7 +102,7 @@ def fetch_policies(args: argparse.Namespace) -> int:
|
||||
|
||||
|
||||
def listen_syslog(args: argparse.Namespace) -> int:
|
||||
listen_udp_syslog(args.host, args.port, args.output)
|
||||
listen_udp_syslog(args.host, args.port, args.output, quiet=args.quiet)
|
||||
return 0
|
||||
|
||||
|
||||
@@ -145,6 +145,7 @@ def build_parser() -> argparse.ArgumentParser:
|
||||
listener.add_argument("--host", default="0.0.0.0", help="Bind address")
|
||||
listener.add_argument("--port", type=int, default=5514, help="UDP port. Use 514 only with sudo/capability.")
|
||||
listener.add_argument("--output", default="logs/fg_syslog.jsonl", help="File to append received logs to")
|
||||
listener.add_argument("--quiet", action="store_true", help="Do not print each received syslog message")
|
||||
listener.set_defaults(func=listen_syslog)
|
||||
|
||||
return parser
|
||||
|
||||
@@ -4,7 +4,7 @@ import socket
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def listen_udp_syslog(host: str, port: int, output: str, *, max_bytes: int = 65535) -> None:
|
||||
def listen_udp_syslog(host: str, port: int, output: str, *, max_bytes: int = 65535, quiet: bool = False) -> None:
|
||||
output_path = Path(output)
|
||||
output_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
@@ -20,4 +20,5 @@ def listen_udp_syslog(host: str, port: int, output: str, *, max_bytes: int = 655
|
||||
if not message:
|
||||
continue
|
||||
handle.write(f"{message}\n")
|
||||
print(f"{address[0]}:{address[1]} {message}")
|
||||
if not quiet:
|
||||
print(f"{address[0]}:{address[1]} {message}")
|
||||
|
||||
Reference in New Issue
Block a user