Bug 246598 - net-mgmt/librenms: Fix double logging
Summary: net-mgmt/librenms: Fix double logging
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Dan Langille
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-05-20 09:56 UTC by Dries Michiels
Modified: 2020-07-26 17:49 UTC (History)
2 users (show)

See Also:
bugzilla: maintainer-feedback? (dvl)


Attachments
librenms.diff (1.51 KB, patch)
2020-05-20 09:56 UTC, Dries Michiels
no flags Details | Diff
librenms.diff (1.52 KB, patch)
2020-06-12 11:23 UTC, Dries Michiels
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dries Michiels freebsd_committer freebsd_triage 2020-05-20 09:56:59 UTC
Created attachment 214687 [details]
librenms.diff

This patch adds a new rc_variable: librenms_logflags, which defaults to logging to a logfile. When overwriting this variable from rc.conf by eg "-S -T librenms", this can be used to use syslog instead of direct logfile logging.

I default to logfile logging because not everyone wants to use the same syslog parameters. Also, I don't like ports including syslog or newsyslog sample files because of the various flags people tend to keep consistent. EG compression on or off for newsyslog rotation probably depends on if you have ZFS (already compressed) or UFS.
Comment 1 Dan Langille freebsd_committer freebsd_triage 2020-05-22 16:40:00 UTC
I my not get to this until June. PGCon is next week and BSDCan is the week after.

My current priorities are there.
Comment 2 Dries Michiels freebsd_committer freebsd_triage 2020-06-12 11:23:27 UTC
Created attachment 215481 [details]
librenms.diff

Rename librenms_logflags to librenms_daemonflags, to make it more general and correct.
Comment 3 Dries Michiels freebsd_committer freebsd_triage 2020-07-09 11:15:04 UTC
Hi Dan, friendly bump :).
Comment 4 Alexander Moisseev 2020-07-26 06:55:03 UTC
I've found another logging issue.
In some cases librenms doesn't respect $config['log_dir'].

With $config['log_dir'] = '/var/log/librenms'; it writes errors like below in the /usr/local/www/librenms/logs/librenms.log, though other poller log messages go in the /var/log/librenms/librenms.log.

[2020-07-26 09:44:06] production.ERROR: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '35-5' for key 'ports_device_id_ifindex_unique' (SQL: UPDATE `ports` set `ifIndex`=5,`ifSpeed_pre
v`=0,`ifHighSpeed_prev`=0,`poll_time`=1595745846,`poll_prev`=1592753465,`poll_period`=2992381 WHERE `port_id` = 75066) (SQL: UPDATE `ports` set `ifIndex`=5,`ifSpeed_prev`=0,`ifHighSpeed_prev`=0,`poll_time`=1
595745846,`poll_prev`=1592753465,`poll_period`=2992381 WHERE `port_id` = 75066)#0 /usr/local/www/librenms/includes/polling/ports.inc.php(896): dbUpdate(Array, 'ports', '`port_id` = ?', Array)
#1 /usr/local/www/librenms/includes/polling/functions.inc.php(315): include('/usr/local/www/...')
#2 /usr/local/www/librenms/poller.php(142): poll_device(Array, false)
#3 {main}
Comment 5 Dan Langille freebsd_committer freebsd_triage 2020-07-26 12:52:25 UTC
(In reply to Alexander Moisseev from comment #4)

Perhaps what you say is related to #246598
Comment 6 Dan Langille freebsd_committer freebsd_triage 2020-07-26 12:52:49 UTC
(In reply to Dan Langille from comment #5)
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=246598
Comment 7 Dan Langille freebsd_committer freebsd_triage 2020-07-26 12:54:51 UTC
It is early. I need to wake up. :)
Comment 8 Dan Langille freebsd_committer freebsd_triage 2020-07-26 13:13:41 UTC
(In reply to Alexander Moisseev from comment #4)

More recent versions of LibreNMS do not use config.php as much as previous versions.

I found this:

config/logging.php:            'path' => env('APP_LOG', \LibreNMS\Config::get('log_file', base_path('logs/librenms.log'))),
config/logging.php:            'path' => env('APP_LOG', \LibreNMS\Config::get('log_file', base_path('logs/librenms.log'))),
Comment 9 Dan Langille freebsd_committer freebsd_triage 2020-07-26 14:01:10 UTC
Please try adding this line to /usr/local/www/librenms/.env:

APP_LOG=/var/log/librenms/librenms.log
Comment 10 Alexander Moisseev 2020-07-26 15:36:05 UTC
(In reply to Dan Langille from comment #9)

Thanks, it worked. Now LibreNMS writes those errors in the proper place (/var/log/librenms/librenms.log).
Comment 11 commit-hook freebsd_committer freebsd_triage 2020-07-26 17:48:50 UTC
A commit references this bug:

Author: dvl
Date: Sun Jul 26 17:48:43 UTC 2020
New revision: 543487
URL: https://svnweb.freebsd.org/changeset/ports/543487

Log:
  Fix double logging

  HEADS UP: See UPDATING for changes affecting your upgrade.
            New installs not affected.

  This patch adds a new rc_variable: librenms_daemonflags

  The -T option is gone as that will force a log to syslog, doubling up on log
  entries.

  A new APP_LOG setting has been added to the .env file. Please update and
  move your logs.  See UPDATING.

  PR:		246598
  Submitted by:	Dries Michiels <driesm.michiels@gmail.com>

Changes:
  head/UPDATING
  head/net-mgmt/librenms/Makefile
  head/net-mgmt/librenms/files/librenms.in
  head/net-mgmt/librenms/files/patch-.env.example
  head/net-mgmt/librenms/files/pkg-message.in
Comment 12 Dan Langille freebsd_committer freebsd_triage 2020-07-26 17:49:50 UTC
Thank you.