jarischaefer / docker-librenms

Docker image for LibreNMS
MIT License
115 stars 37 forks source link

Adjustment for snmp-scan.py #135

Closed elcign closed 2 years ago

elcign commented 2 years ago

Hi,

I'm setting up a layer 3-only network and noticed snmp-scan.py wasn't working, as I think it's the only discovery method that will work in that type of setup. After some further investigation I found the snmp-scan.py script was outputting some kind of error.

/15 * librenms . /etc/librenms_environment; /opt/librenms/snmp-scan.py -v > /opt/librenms/logs/snmpscanerror.log 2>&1 was giving me a bunch of this: /usr/bin/env: ‘lnms’/usr/bin/env: ‘lnms’: No such file or directory

I'm not sure if I did something wrong that it wasn't working to begin with as I'm very new to Linux/Docker.

I was able to get it working with consistency by running this on my docker host before compose: sudo mkdir -p /data/librenms/etc && sudo touch $_/librenms_environment && sudo chown -R systemd-coredump:systemd-coredump /data/librenms/etc/librenms_environment && sudo chmod 640 /data/librenms/etc/librenms_environment

And then adding this volume to my docker compose:

Then composing, and finally adding this to the end of librenms_environment on the docker host: export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin"

I'm sure those commands aren't perfect (I'm sure /usr/games:/usr/local/games, systemd-coredump ownership, and maybe other parts aren't necessary, for instance) but just thought I'd contribute if anyone else had a similar problem.

Thanks for your work on this container!

jarischaefer commented 2 years ago

@elcign Thanks for the report, it should be fixed in the latest version. Please test and provide feedback.

elcign commented 2 years ago

I did try it out on a fresh build with the latest tag but it didn't seem to work. It was outputting the same errors as before when I directed the cron job output to a file.

I verified I was on the correct image by checking the code was modified inside the container as found in: https://github.com/jarischaefer/docker-librenms/commit/81e10fb5f03e136d77418ee9ee51ed1964f2e067

I went ahead and plugged your refined PATH (export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin") into the bottom of the librenms_environment file inside the container and it immediately started picking up hosts again on the next cron run of snmp-scan.py. The output of the script looked like this as I made the modification:

/usr/bin/env: ‘lnms’: No such file or directory
?/usr/bin/env: ‘lnms’: No such file or directory
???Scanning IPs:
*.............................................................+.......................
jarischaefer commented 2 years ago

@elcign Sorry about that, some files were missing. As per your suggestion, I also added PATH to /etc/librenms_environment to be sure.

elcign commented 2 years ago

Beautiful, it's working fine now. Thanks for taking the time.