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.


. /etc/rc.subr

load_rc_config $name

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 "": new connection
2022/01/06 06:05:14 downstream "": connection closed
2022/01/06 06:05:45 downstream "": new connection
2022/01/06 06:05:45 downstream "": connection closed
2022/01/06 06:06:15 downstream "": new connection
2022/01/06 06:06:15 downstream "": connection closed
2022/01/06 06:06:46 downstream "": new connection
2022/01/06 06:06:46 downstream "": connection closed
2022/01/06 06:07:17 downstream "": new connection
2022/01/06 06:07:17 downstream "": connection closed
2022/01/06 06:07:47 downstream "": new connection
2022/01/06 06:07:47 downstream "": connection closed

Is that possible to log those only in debug mode ?

Assigned to
8 months ago
8 months ago
No labels applied.

~eoli3n 8 months ago

each 30s*

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