Summary: | net-mgmt/librenms: service librenms start failing | ||
---|---|---|---|
Product: | Ports & Packages | Reporter: | Dries Michiels <driesm> |
Component: | Individual Port(s) | Assignee: | Dan Langille <dvl> |
Status: | Closed FIXED | ||
Severity: | Affects Only Me | Flags: | bugzilla:
maintainer-feedback?
(dvl) |
Priority: | --- | ||
Version: | Latest | ||
Hardware: | Any | ||
OS: | Any |
Description
Dries Michiels
2023-10-03 19:13:14 UTC
It's not this file: [19:29 besser dan ~] % head /usr/local/www/librenms/config_to_json.php #!/usr/local/bin/php <?php /* * Configuration to JSON converter * Written by Job Snijders <job@instituut.net> * */ use LibreNMS\Config; It's LibreNMS/__init__.py [19:30 besser dan /usr/local/www/librenms] % grep -r config_to_json.php * | head -2 LibreNMS/__init__.py: config_cmd = ["/usr/bin/env", "php", "%s/config_to_json.php" % base_dir] doc/General/Changelogs/2019.md:* Don't require db for config_to_json.php ([#10100](https://github.com/librenms/librenms/pull/10100)) - [murrant](https://github.com/murrant) The reason this works on Linux (I think), php is in /usr/bin. On most sane systems, it's in /usr/local/bin - and Apache's $PATH does not include that directory. The solution is much like shebang fixes. It reminds me of https://cgit.freebsd.org/ports/tree/net-mgmt/librenms/files/patch-LibreNMS_wrapper.py I'll work on a patch. I have this untested patch: config_cmd = "/usr/local/bin/php %s/config_to_json.php" % base_dir If you can try it out, great. (In reply to Dries Michiels from comment #0) Are you using Nginx? What version of LibreNMS are you running now? Do those messages appear in /var/log/messages? /var/log/librenms/librenms-service.log I ask because I'm using: apache24-2.4.57_1 librenms-23.9.1,1 I cannot reproduce the issue: [21:02 besser dan /usr/local/www/librenms] % sudo service librenms start Starting librenms. [21:02 besser dan /usr/local/www/librenms] % thanks Corrected patch to be applied via edit. config_cmd = ["/usr/local/bin/php", "%s/config_to_json.php" % base_dir] that should replace line 170 of /usr/local/www/librenms/LibreNMS/__init__ : config_cmd = ["/usr/bin/env", "php", "%s/config_to_json.php" % base_dir] Yeah patch works great! I'm on FreeBSD 14-STABLE with 23.9.1,1 LibreNMS package version. I indeed use nginx. I found the error messages in librenms-service.log, and of course noticed the problem when my graphs didn't show no data anymore (poller was not started). (In reply to Dries Michiels from comment #5) I will have a port update soon. I will also patch other similar situations and add more to the SHEBANG fixes. The nginx guess was based on my use of Apache and not seeing the error. I am not using Apache over Nginx for any particular reason. A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/ports/commit/?id=8ff190a6fb75c40acd4ebf3a579187ebd8a26d57 commit 8ff190a6fb75c40acd4ebf3a579187ebd8a26d57 Author: Dan Langille <dvl@FreeBSD.org> AuthorDate: 2023-10-04 14:10:57 +0000 Commit: Dan Langille <dvl@FreeBSD.org> CommitDate: 2023-10-04 15:30:33 +0000 net-mgmt/librenms: remove /usr/bin/env usage This problem occurred on Nginx, but not Apache. Instead of "/usr/bin/env php", use "/usr/local/bin/php". While here: * add more to SHEBANG_FILES * portfmnt PR: 274248 net-mgmt/librenms/Makefile | 26 +++++++++++++--------- .../files/patch-LibreNMS_____init____.py (new) | 11 +++++++++ net-mgmt/librenms/files/patch-snmp-scan.py (new) | 21 +++++++++++++++++ 3 files changed, 48 insertions(+), 10 deletions(-) Done, thank you for reporting this. There seems something else at play here too. The daemon now starts correctly after the patch, but the actual polling does not happen. Again, when I start the service on the CLI, it does. Probably somewhere another $path issue not including /usr/local/[sbin/bin]? Command I use to start from the CLI; "daemon -p /var/run/librenms/librenms.pid -u www -T librenms /usr/local/bin/python3.9 /usr/local/www/librenms/librenms-service.py" # find . -type file -exec grep "/usr/bin/env" {} \; base = ("/usr/bin/env", "php") First hit seems suspicious, also in __init__.py. I'm wondering if the change of the root shell (in STABLE 14, csh to sh) has anything to do with the problem as you have no observed anything so far? Reopening. I am not sure, I am guessing. Try changing that suspect line to: base = ("/usr/local/bin/php") I have tried it here, and it works, but then, mine was also working. For me, base = ("/usr/local/bin/php") does not work (/var/log/messages) output Oct 7 12:58:00 librenms librenms[98158]: Traceback (most recent call last): Oct 7 12:58:00 librenms syslogd: last message repeated 1 times Oct 7 12:58:00 librenms librenms[98158]: File "/usr/local/www/librenms/LibreNMS/queuemanager.py", line 85, in _ser vice_worker Oct 7 12:58:00 librenms librenms[98158]: self.do_work(device_id, queue_id) Oct 7 12:58:00 librenms librenms[98158]: File "/usr/local/www/librenms/LibreNMS/queuemanager.py", line 85, in _ser vice_worker Oct 7 12:58:00 librenms librenms[98158]: self.do_work(device_id, queue_id) Oct 7 12:58:00 librenms librenms[98158]: File "/usr/local/www/librenms/LibreNMS/queuemanager.py", line 370, in do_ work Oct 7 12:58:00 librenms librenms[98158]: exit_code, output = LibreNMS.call_script("billing-calculate.php", args) Oct 7 12:58:00 librenms librenms[98158]: File "/usr/local/www/librenms/LibreNMS/queuemanager.py", line 510, in do_ work Oct 7 12:58:00 librenms librenms[98158]: exit_code, output = LibreNMS.call_script("alerts.php", args) Oct 7 12:58:00 librenms librenms[98158]: File "/usr/local/www/librenms/LibreNMS/__init__.py", line 203, in call_sc ript Oct 7 12:58:00 librenms librenms[98158]: cmd = base + ("{}/{}".format(base_dir, script),) + tuple(map(str, args) ) Oct 7 12:58:00 librenms librenms[98158]: File "/usr/local/www/librenms/LibreNMS/__init__.py", line 203, in call_sc ript Oct 7 12:58:00 librenms librenms[98158]: cmd = base + ("{}/{}".format(base_dir, script),) + tuple(map(str, args) ) Oct 7 12:58:00 librenms librenms[98158]: TypeError: can only concatenate str (not "tuple") to str with base = ("/usr/local/bin/php",) it works I could investigate the patch issue and look at adding /usr/local/bin ... but I'm not. I suspect that may be the root cause. I'm happy for someone else to look into that possibility. Until then, I'll use your solution. A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/ports/commit/?id=73922d6b363a6902a05721d9102386ce657b03d4 commit 73922d6b363a6902a05721d9102386ce657b03d4 Author: Dan Langille <dvl@FreeBSD.org> AuthorDate: 2023-10-07 11:49:41 +0000 Commit: Dan Langille <dvl@FreeBSD.org> CommitDate: 2023-10-07 11:49:41 +0000 net-mgmt/librenms: Fix start on FreeBSD 14/nginx This may be a path issue or a shell issue, but nginx on FreeBSD 14 is not finding /usr/local/bin/php. The fix: use /usr/local/bin/php as we have done with other patches. PR: 274248 net-mgmt/librenms/Makefile | 2 +- net-mgmt/librenms/files/patch-LibreNMS_____init____.py | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) Works and polling also works now. Great! |