Closed jaxjexjox closed 1 year ago
Ok never mind, it looks like 'custom-config.php' is unrelated, to 'config.php' By adding the 2 lines I was after, to the normal config
$config['nets'][] = "192.168.0.0/24"; $config['discovery_by_ip'] = true;
The scan, now works for me.
Hi @jarischaefer
I'm so sorry to badger you every 6 months, I keep coming back to have a crack and get this running nicely. Can I ask a bit of an elementary question?
What is the point of custom.config.php, being mapped out. if LibreNMS won't parse the file or use it? I can see in my post above, that the only way snmp-scan.py will parse my 'nets' requirement, is by adding it to the config.php, inside the docker container.
What does the custom.config file actually do and can I add preferences for config.php into it? Otherwise I need to exec into my container, to modify the config file manually, if I ever destroy and recreate my container.
Thank you, sorry so much it's probably a very basic question.
@jaxjexjox config.custom.php
no longer works, see https://github.com/jarischaefer/docker-librenms/releases/tag/22.7.0 and https://github.com/jarischaefer/docker-librenms#custom-configuration.
Hi Jari,
So I've had a play and I'm still a tad confused here. If I mount 'config.php' in the /opt/librenms/conf.d folder, it'll map it, as a directory. Presumably I need to have a local copy of a file on my filesystem, before the mapping, I'm fairly sure it works this way.
Difficulty with that is pre-getting a working copy of that file. Should I just download one? What is the go-to method of mapping this file out?
I really would like to restrict my [nets] before running the container.
Also, even if I did have a correctly pre-formatted config.php in conf.d is the package actually parsing that version of the config file?
I apologise for the elementary questions, again :(
I have fixed my issue with it being a directory and made a file before hand, I've confirmed the file is correctly "in" the container.
When I exec commands it's 'parsing' the container in an odd way, as if it imports the file each exec?
https://i.imgur.com/tbqkXEz.png
It's also 'breaking' the snmp-scan.py command?
If I manually edit, the 'real' config.php file, inside the container and don't map config.php, this problem, does not exist
(Note, I confirmed this error is not due to it being the same file name (config.php) by re-doing it and mounting config-nets.php, precisely the same results)
Presumably I need to have a local copy of a file on my filesystem, before the mapping
Yes, Docker creates missing mounts as directories. It has been causing a lot of confusion since at least 2015 and I am not aware of any improvements since then.
Make sure the configs are PHP scripts that output nothing on exec. If you run php config.php
and it outputs something, the config file is wrong. It may be missing the <?php
start tag.
Oh my goodness of course.
I'm new to PHP, that makes total sense to have the correct source input format, not just plain text.
Thank you, I'll have a play with it this morning. Sorry I'm not super experienced so I very much appreciate any replies at all!
@jarischaefer Thank you for all the help over the years, this is lovely and I'm up and running! If I could offer one small piece of advice please.
https://github.com/jarischaefer/docker-librenms#custom-configuration
The snippet of code at the bottom for interface is lacking a >? to close out the PHP. Which embarassingly, I didn't know and had to google why I was having problems.
Otherwise though, I'm golden! Your help is really appreciated.
No problem, see https://www.php.net/manual/en/language.basic-syntax.phptags.php for PHP tags:
If a file contains only PHP code, it is preferable to omit the PHP closing tag at the end of the file. This prevents accidental whitespace or new lines being added after the PHP closing tag, which may cause unwanted effects because PHP will start output buffering when there is no intention from the programmer to send any output at that point in the script.
sudo docker exec -i librenms ./opt/librenms/snmp-scan.py -P Traceback (most recent call last): File "//./opt/librenms/snmp-scan.py", line 244, in
CONFIG = json.loads(
File "/usr/lib/python3.10/json/init.py", line 346, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3.10/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python3.10/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
I've tried adding nets to custom config and also the 'normal' config in /opt/librenms and both ways, it refuses to run the scan with the above error.
I'm unsure what I'm doing wrong. Any tips?