Skip to content

Commit

Permalink
Feature: Select port number other than 514 for remote syslog logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian Roth committed Nov 12, 2017
1 parent a665a95 commit 1d97792
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/lokilogger.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class LokiLogger():
debug = False
linesep = "\n"

def __init__(self, no_log_file, log_file, hostname, remote_host, csv, only_relevant, debug, platform, caller):
def __init__(self, no_log_file, log_file, hostname, remote_host, remote_port, csv, only_relevant, debug, platform, caller):
self.no_log_file = no_log_file
self.log_file = log_file
self.hostname = hostname
Expand All @@ -54,7 +54,7 @@ def __init__(self, no_log_file, log_file, hostname, remote_host, csv, only_relev
# Create remote logger
self.remote_logger = logging.getLogger('LOKI')
self.remote_logger.setLevel(logging.DEBUG)
remote_syslog_handler = logging.handlers.SysLogHandler(address=(remote_host, 514), facility=19)
remote_syslog_handler = logging.handlers.SysLogHandler(address=(remote_host, remote_port), facility=19)
self.remote_logger.addHandler(remote_syslog_handler)
self.remote_logging = True

Expand Down
2 changes: 1 addition & 1 deletion loki-upgrader.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def get_application_path():
t_hostname = os.uname()[1]

# Logger
logger = LokiLogger(args.nolog, args.l, t_hostname, '', False, False, args.debug, platform=platform, caller='upgrader')
logger = LokiLogger(args.nolog, args.l, t_hostname, '', '', False, False, args.debug, platform=platform, caller='upgrader')

# Update Loki
updater = LOKIUpdater(args.debug, logger, get_application_path())
Expand Down
3 changes: 2 additions & 1 deletion loki.py
Original file line number Diff line number Diff line change
Expand Up @@ -1367,6 +1367,7 @@ def signal_handler(signal_name, frame):
parser.add_argument('-s', help='Maximum file size to check in KB (default 5000 KB)', metavar='kilobyte', default=5000)
parser.add_argument('-l', help='Log file', metavar='log-file', default='loki-%s.log' % t_hostname)
parser.add_argument('-r', help='Remote syslog system', metavar='remote-loghost', default='')
parser.add_argument('-t', help='Remote syslog port', metavar='remote-syslog-port', default=514)
parser.add_argument('-a', help='Alert score', metavar='alert-level', default=100)
parser.add_argument('-w', help='Warning score', metavar='warning-level', default=60)
parser.add_argument('-n', help='Notice score', metavar='notice-level', default=40)
Expand All @@ -1393,7 +1394,7 @@ def signal_handler(signal_name, frame):
os.remove(args.l)

# Logger
logger = LokiLogger(args.nolog, args.l, t_hostname, args.r, args.csv, args.onlyrelevant, args.debug,
logger = LokiLogger(args.nolog, args.l, t_hostname, args.r, int(args.t), args.csv, args.onlyrelevant, args.debug,
platform=platform, caller='main')

# Update
Expand Down

0 comments on commit 1d97792

Please sign in to comment.