~emersion/soju#177: 
don't log port testing in soju.log

As the freebsd package comes without a service file, I wrote a basic (and dirty) one, which run soju with daemon.

#!/bin/sh

. /etc/rc.subr

name="soju"
rcvar="${name}_enable"
load_rc_config $name
pidfile="/var/run/${name}.pid"

start_cmd="daemon -o /var/log/soju.log -p ${pidfile} /usr/local/bin/soju -config /usr/local/etc/soju/soju.conf"
stop_cmd="/bin/pkill soju && sleep 1"
status_cmd="/bin/pgrep soju"

run_rc_command "$1"

So it produces a soju.log file.

I use monit to periodically test my running services.

check process soju with pidfile /usr/local/bastille/jails/soju/root/var/run/soju.pid
    start program = "/usr/local/bin/bastille start soju"
    stop program  = "/usr/local/bin/bastille stop soju"
    if failed host domain.org port 6697 for 3 cycles then restart
    if changed pid then alert

Problem is that at each port test (which is basically a nc -vz domain.org 6697), it produces a log line. As the test is ran each 120s, I get soju.log flooded by start|end connection lines.

2022/01/06 06:05:14 downstream "192.168.0.254:48654": new connection
2022/01/06 06:05:14 downstream "192.168.0.254:48654": connection closed
2022/01/06 06:05:45 downstream "192.168.0.254:48659": new connection
2022/01/06 06:05:45 downstream "192.168.0.254:48659": connection closed
2022/01/06 06:06:15 downstream "192.168.0.254:48664": new connection
2022/01/06 06:06:15 downstream "192.168.0.254:48664": connection closed
2022/01/06 06:06:46 downstream "192.168.0.254:48673": new connection
2022/01/06 06:06:46 downstream "192.168.0.254:48673": connection closed
2022/01/06 06:07:17 downstream "192.168.0.254:48678": new connection
2022/01/06 06:07:17 downstream "192.168.0.254:48678": connection closed
2022/01/06 06:07:47 downstream "192.168.0.254:48687": new connection
2022/01/06 06:07:47 downstream "192.168.0.254:48687": connection closed

Is that possible to log those only in debug mode ?

Status
REPORTED
Submitter
~eoli3n
Assigned to
No-one
Submitted
8 months ago
Updated
8 months ago
Labels
No labels applied.

~eoli3n 8 months ago

each 30s*

Register here or Log in to comment, or comment via email.