Created attachment 214088 [details]
I missed /dev/null in my previous checks for the logfile creation, now we actually tell it to copy something to the location intended. Pointyhat => Me :-)
Created attachment 214100 [details]
Also disable allowance of multiple instances.
When the -m flag is specified I had the following error:
Traceback (most recent call last):
File "/usr/local/www/librenms/librenms-service.py", line 48, in <module>
File "/usr/local/www/librenms/LibreNMS/service.py", line 232, in start
self.check_single_instance() # don't allow more than one service at a time
File "/usr/local/www/librenms/LibreNMS/service.py", line 494, in check_single_instance
self._fp = open(lock_file, 'w') # keep a reference so the file handle isn't garbage collected
PermissionError: [Errno 13] Permission denied: '/usr/local/www/librenms/.lock.service'
The service tries to write a lock file in the /usr/local/www/librenms dir, where it does not currently have the permissions for (owner is root:wheel). Solution: Either change ownership of the dir to www:wheel, or remove the -m flag in the service command.
The latter is proposed as librenms_flags="-m" can always be specified by the user to append it to the command args.
The dispatching service is now running happily on my system. :-)
(In reply to Dries Michiels from comment #1)
How did you get this error message? I cannot reproduce it.
What permissions do you have on /usr/local/www/librenms?
Mine are at stock created from the port @ 755 with root:wheel ownership.
Meaning that www user cannot create files in that directory and thus also not the daemon. The port creates it that way with a fresh install. I believe that if you manually have set permissions at one point in time they will have been retained even when upgrading librenms through the years.
(In reply to Dries Michiels from comment #4)
I have [dan@besser:~] $ ls -ld /usr/local/www/librenms
drwxr-xr-x 23 www www 66 May 3 18:15 /usr/local/www/librenms
That explains that.
I deinstalled the package, and moved that directory aside. It had many lingering items. I think there are more things in there which need to be in /var/db/ or /var/log
Post new-install, I have:
$ ls -ld /usr/local/www/librenms
drwxr-xr-x 22 root wheel 60 May 4 14:38 /usr/local/www/librenms
Here is what I had leftover in that directory:
[dan@besser:/usr/local/www/librenms.2020-05-04] $ ls -l
drwxr-xr-x 4 root www 5 May 4 14:36 LibreNMS
drwxr-xr-x 3 root www 3 May 4 14:36 bootstrap
-rwxr-xr-x 1 root www 1969526 Mar 19 18:57 composer.phar
lrwxr-xr-x 1 root www 34 Mar 3 14:23 config.php -> /usr/local/etc/librenms-config.php
drwxr-xr-x 2 root www 5 May 4 14:36 includes
drwxrwxr-x 2 www www 3 Oct 24 2018 logs
drwxrwxr-x 3 www www 3 May 4 14:36 storage
drwxr-xr-x 10 root www 10 May 4 14:36 vendor
I'll have a sniff around there.
As you can see, I put my config elsewhere. I'd like that to eventually be what the port does.
Are you able to reproduce now? Also, I am in full favor to support hier(7) for file locations, i.e. /usr/local/etc/ for config files. I noticed the same lingering things a while back when I did a fresh install of LibreNMS :O!
(In reply to Dan Langille from comment #5)
FYI, I was able to reproduce your error message.
I'm getting double logging. I'll look into that later.
*** /var/log/librenms/librenms-service.log ***
Alerting(INFO):Completed alerting run for alerts in 0.27s
Billing(INFO):Completed billing run for calculate in 0.25s
*** /var/log/messages ***
May 4 15:58:00 besser librenms: Alerting(INFO):Checking alerts
May 4 15:58:00 besser librenms: Billing(INFO):Calculating billing
May 4 15:58:00 besser librenms: Alerting(INFO):Completed alerting run for alerts in 0.27s
May 4 15:58:00 besser librenms: Billing(INFO):Completed billing run for calculate in 0.25s
For future consideration, these directories in /usr/local/www/librenms are bing updated by the application. They should be moved outside WWWDIR
storage - seems to be a caching directory - should be in /var/db/librenms/storage
logs - should by in /var/log/librenms but with a different name perhap
bootstrap/cache - should be in /var/db/librenms/cache
The existing /var/log/librenms/librenms.log should be named poller.log
In the meantime, we have a break. I'll commit that fix now.
A commit references this bug:
Date: Tue May 5 15:22:17 UTC 2020
New revision: 534092
fix log file creation in rc script
disable allowance of multiple instances (-m in rc.d script)
Submitted by: Dries Michiels <firstname.lastname@example.org>
Thank you Mark, well done.
(In reply to Dan Langille from comment #9)
Also: config.php should be in /usr/local/etc/librenms/
(In reply to Dan Langille from comment #8)
That double logging is fixed by removing '-T $name ' from the rc.d script
hehe, good catch, -T probably implies syslog logging because we explicitly specify its syslog tag.
This is what I use now for logging because it gets us timestamps:
command_args="-T $name -l local3 -p $pidfile /usr/local/www/librenms/librenms-service.py"
This in /etc/syslog.conf:
This in /usr/local/etc/syslog.d/librenms.conf
# this is a file for syslog.conf
# it should be installed to /usr/local/etc/syslog.d
(In reply to Dan Langille from comment #14)
> That double logging is fixed by removing '-T $name ' from the rc.d script
Would you fix it for the rest of us please?
For instance, if some one needs syslog logging we could introduce an rc.d flag.
Simply removing '-T' option is also fine.
In my opinion, port shouldn't log to two destination simultaneously out of the box, moreover it shouldn't flood /var/log/messages at 'inform' level (LibreNMS default).
I will make a patch tonight in a new PR. I'll CC you.