Docker-Nagios
Docker-Nagios copied to clipboard
Populate /opt/nagiosgraph/[etc|var] if empty
Reported by @jtome
If one is mounting /opt/nagiosgraph/etc or /opt/nagiosgraph/var outside of the container, and the mounted directory is empty nagiosgraph fails to load, Files should be copied in place if the directory is empty.
I think a simple solution to this is to make the owner of those directories nagios rather than root. Makes sense?
Hi! I just stumbled upon this project and created the pull request https://github.com/JasonRivers/Docker-Nagios/pull/65 to fix the ownership of a mounted /opt/nagios/var.
HTH Thomas
This happened again, because during docker build after building nagiosgraph the sources are deleted. During docker startup you check if nagiosgraph is installed and try to install it otherwise, but the source folder is missing now. Pull request #96 solves that.
which files need to be copied ? can you give instructions ?
can you update the docker image so I can use nagiosgraph out of the box ?
@JasonRivers
I've finally got nagiosgraph working with the docker container after a couple of days head-scratching, but to do it I had to:
- Outside the container, edit .\etc\objects\templates.cfg correcting the path of the two entries:
- action_url /nagios/cgi-bin/show.cgi?host=$HOSTNAME$&service=$SERVICEDESC$' onMouseOver='showGraphPopup(this)' onMouseOut='hideGraphPopup()' rel='/nagios/cgi-bin/showgraph.cgi?host=$HOSTNAME$&service=$SERVICEDESC$&period=day&rrdopts=-w+450+-j
- edit .\nagiosgraph\etc\nagiosgraph.conf correcting the three entries:
- graphcgiurl = /nagios/cgi-bin
- javascript = /nagios/nagiosgraph/nagiosgraph.js
- stylesheet = /nagios/nagiosgraph/nagiosgraph.css
The above two not too bad as the files are outside the container, but I also needed
- edit /opt/nagios/share/ssi/common-header.ssi. To do this I changed the startup command of the container in my docker-compose so that it runs the following before /usr/local/bin/start_nagios:
- /bin/sed -i -e "s/src="/nagiosgraph/nagiosgraph.js/src="/nagios/nagiosgraph/nagiosgraph.js/" /opt/nagios/share/ssi/common-header.ssi
I have to do it on each startup, otherwise the change is lost on container teardown/image update. Having done all of that lot, it now draws graphs on mouseover, loads the nagiosgraph.js without 404ing, and the graph pages work too.
HTH (thanks for your work on the docker container, much appreciated BTW)
I can't do that as my /opt/nagiosgraph location just contains 2 empty folders: etc and var How do I populate them and what further steps should I take ? I am not a docker expert - just a user...
Here is my docker run script
docker run --name nagios4
--hostname rcapp04-nagios
-v /srv/docker/volumes/nagios/opt/etc:/opt/nagios/etc
-v /srv/docker/volumes/nagios/opt/var:/opt/nagios/var
-v /srv/docker/volumes/Custom-Nagios-Plugins:/opt/Custom-Nagios-Plugins
-v /srv/docker/volumes/nagios/opt/nagiosgraph/var:/opt/nagiosgraph/var
-v /srv/docker/volumes/nagios/opt/nagiosgraph/etc:/opt/nagiosgraph/etc
-v /etc/timezone:/etc/timezone:ro
-v /etc/localtime:/etc/localtime:ro
-d --restart unless-stopped
-p 0.0.0.0:8099:80 jasonrivers/nagios:latest
here is what I see from docker exec -it nagios4 /bin/bash
root@rcapp04-nagios:/# ls / bin dev home lib64 mnt orig root sbin sys usr boot etc lib media opt proc run srv tmp var
root@rcapp04-nagios:/# ls /opt Custom-Nagios-Plugins JR-Nagios-Plugins nagios nagiosgraph JE-Nagios-Plugins WL-Nagios-Plugins nagios-mssql
root@rcapp04-nagios:/# ls -R /opt/nagiosgraph /opt/nagiosgraph: etc var
/opt/nagiosgraph/etc:
/opt/nagiosgraph/var:
@wpyung
Before you start, you need to drop mounting your external versions of /opt/nagiosgraph/etc and ./var, and mount your /srv/docker/volumes/nagios/opt/nagiosgraph somewhere else in the docker filesystem - e.g. /opt/nagiosgraph/mytmp. Then you can copy the docker image versions of ./etc and ./var out to your external filesystem.
Having done that, put the /opt/nagiosgraph/etc and /opt/nagiosgraph/var mounts back in and you should be good. This approach likely also needed for /opt/nagios/etc and /opt/nagios/var dirs too.
great that did it with no other changes required /opt/Nagios is OK Thanks for your help so far...
I see 4 graphs. Yearly and Monthly have data, weekly and daily are blank. Is there something I have to tweak ? Or is it just a question of waiting
Yay, glad it's working. There is one reading in the daily data (min=max=avg=curr), and you can just see the pixels on the RHS of the graph, so I think it's just a case of waiting.
Hi, how did you mount back the volumes ? Because it seems like you can't mount volumes in a running container.. Please let me know
you just need to stop the container to do the mounts and unmounts, then restart it
thanks