Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nagiosgraph not working #67

Closed
herbalizer404 opened this issue May 23, 2018 · 32 comments
Closed

Nagiosgraph not working #67

herbalizer404 opened this issue May 23, 2018 · 32 comments

Comments

@herbalizer404
Copy link

I created my different dirs, chown 999 to nagios dirs.
I launched the same command as yours, but when I try to see a graph, i ve this error in my logs:
Can't locate ngshared.pm in @INC (you may need to install the ngshared module) (@INC contains: /opt/nagiosgraph/etc /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.22.1 /usr/local/share/perl/5.22.1 /usr/lib/x86_64-linux-gnu/perl5/5.22 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.22 /usr/share/perl/5.22 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base .) at /opt/nagiosgraph/bin/insert.pl line 41. BEGIN failed--compilation aborted at /opt/nagiosgraph/bin/insert.pl line 41.

@herbalizer404
Copy link
Author

Or maybe, what are the good rights to apply to the directories?

@nicocolt
Copy link

nicocolt commented Jul 3, 2018

Hello,

Same issue here:

Can't locate ngshared.pm in @INC (you may need to install the ngshared module) (@INC contains: /opt/nagiosgraph/etc /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.22.1 /usr/local/share/perl/5.22.1 /usr/lib/x86_64-linux-gnu/perl5/5.22 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.22 /usr/share/perl/5.22 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base .) at /opt/nagiosgraph/bin/insert.pl line 41

I've tried with latest, 4.4.0 and 4.3.2. Maybe I have missed something ?

Let me know,
Best
Nicolas

@vhristev
Copy link

vhristev commented Jul 4, 2018

Yeaa there is some issue with perl path like /usr/local/lib/x86_64-linux-gnu/perl/5.22.1 ...etc.

The workaround is to reinstall NagiosGraph. Here is how you can do that:

Start your container with volumes
#Enter your container
docker exec -it nagios4 /bin/bash

#Clean /opt/nagiosgraph folder --- you will receive ...etc and ... var are busy dont worry.
rm -rf /opt/nagiosgraph

#Build your NagiosGraph --- you dont need to download it its already there just reinstall it.
cd /tmp/nagiosgraph &&
./install.pl --install
--prefix /opt/nagiosgraph
--nagios-user ${NAGIOS_USER}
--www-user ${NAGIOS_USER}
--nagios-perfdata-file ${NAGIOS_HOME}/var/perfdata.log
--nagios-cgi-url /cgi-bin
&&
cp share/nagiosgraph.ssi ${NAGIOS_HOME}/share/ssi/common-header.ssi

No errors anymore.

@JasonRivers
Copy link
Owner

I'd like to get more info on this, I am not seeing these errors at all.
Which log are you seeing these errors in?
Are you running the latest 4.4.1?
Are you getting the error when it's creating graphs or when you're trying to view them within Nagios?
What is the "action_url" you are using?

@vhristev
Copy link

vhristev commented Jul 4, 2018

Which log are you seeing these errors in? --- Docker logs ... docker logs -f nagios4
Are you running the latest 4.4.1? --- yes its latest build 4.4.1
Are you getting the error when it's creating graphs or when you're trying to view them within Nagios? --- when you run the container you get the errors in the logs so graphs are not working at all.
What is the "action_url" you are using? --- I dont think is relevant the problem is when /opt/nagiosgraph/bin/insert.pl script is executed its searching python in /usr/local/lib/x86_64-linux-gnu/perl/5.22.1 the problem is the /usr/local/lib/ folder does not contain anything.

That issues is only when you specify volumes for nagiosgraph (options below). If you dont use them its fine. If you run it without volumes if fine. As I said I didn't deep dive what is the problem I just reinstall it and now its fine.
-v /path-to-nagiosgraph-var:/opt/nagiosgraph/var
-v /path-to-nagiosgraph-etc:/opt/nagiosgraph/etc \

#Docker log pastebin
https://www.pastiebin.com/5b3c978f2fe63

@JasonRivers
Copy link
Owner

JasonRivers commented Jul 4, 2018

Thanks, OK so this looks like the nagiosgraph install is putting files in etc, so when externally mounted those files are no longer in-place. I understand the issue, I'll take a look and see if I can get the install of nagiosgraph to be a little more sensible with where it's putting files it requires.

@vhristev
Copy link

vhristev commented Jul 4, 2018

You can mount share over any folder and the filesystem will use latest mount. If you unmount the volume you will start seeing files from first mount ,so solution is to:
mount volume before installation
copy files somewhere mount and then move them back

@JasonRivers
Copy link
Owner

Yep, That is one option to copy files after the container starts (I do this with example configs if there is no configs found), The alternative will be to have those files elsewhere anyway, I am looking at both options right now.

JasonRivers added a commit that referenced this issue Jul 4, 2018
If /opt/nagiosgraph/etc is externally mounted this will re-install the
files required. see #67 for more details
@JasonRivers
Copy link
Owner

@vhristev once dockerhub has built the latest commit, this should fix this issue, If the required file is not in /opt/nagiosgraph/etc then it will re-run the installation, in my tests, it is renaming the existing config files with a date if they exist. This will only run if ngshared.pm is not in the directory.

@JasonRivers
Copy link
Owner

@herbalizer404 @nicocolt ^^

@nicocolt
Copy link

nicocolt commented Jul 5, 2018

Hello,

Got this issue with the new image:
Warning: File '/opt/nagios/var/perfdata.log' could not be opened - service performance data will not be written to file! nagios: Warning: File '/opt/nagios/var/perfdata.log' could not be opened - service performance data will not be written to file! Error: Unable to create temp file '/opt/nagios/var/nagios.tmpwmeo2C' for writing status data: Permission denied nagios: Error: Unable to create temp file '/opt/nagios/var/nagios.tmpwmeo2C' for writing status data: Permission denied

Reinstall of nagiosgraph shows this error: nagios not found in any of:

my running command is, as root:
docker container run -d --name nagios4 -v /root/docker-nagios/etc:/opt/nagios/etc -v /root/docker-nagios/var:/opt/nagios/var -v /root/docker-nagios/Custom-Nagios-Plugins:/opt/Custom-Nagios-Plugins -v /root/docker-nagios/nagiosgraph/var:/opt/nagiosgraph/var -v /root/docker-nagios/nagiosgraph/etc:/opt/nagiosgraph/etc -p 0.0.0.0:8080:80 jasonrivers/nagios:latest

Best regards

@vhristev
Copy link

vhristev commented Jul 5, 2018

That is permissions related.

When you create your volume folders you must be sure your docker user can write in those folders. So if you create it with 'root' account change owner to your docker user. I dont know with which user your docker is running so check it out with "ps aux | grep docker"

If you want more info about that check that post: https://denibertovic.com/posts/handling-permissions-with-docker-volumes/

@nicocolt
Copy link

nicocolt commented Jul 5, 2018 via email

@vhristev
Copy link

vhristev commented Jul 5, 2018

Im not sure what you exactly doing but you can see its permissions issue in the log.
Unable to create temp file '/opt/nagios/var/nagios.tmpwmeo2C' for writing status data: Permission denied

Volumes are share points if you don't create the folders below and give them correct permissions its not going to work. Folders below must exist with correct permission. When you start docker with -v its not creating the folders for you:
Try commands below:

Create folders

mkdir /root/docker-nagios/etc /root/docker-nagios/var /root/docker-nagios/Custom-Nagios-Plugins /root/docker-nagios/nagiosgraph/var /root/docker-nagios/nagiosgraph/etc

Just for the test give 777 permissions.

chmod -R 777 /root/docker-nagios/etc /root/docker-nagios/var /root/docker-nagios/Custom-Nagios-Plugins /root/docker-nagios/nagiosgraph/var /root/docker-nagios/nagiosgraph/etc

JasonRivers added a commit that referenced this issue Jul 5, 2018
Take ownership of /opt/nagios and /opt/nagiosgraph for issue #67 when
thethe directory does not exist before starting the image.
@JasonRivers
Copy link
Owner

@nicocolt latest commit should take ownership of the directories when Nagios starts.

@nicocolt
Copy link

nicocolt commented Jul 5, 2018 via email

@vhristev
Copy link

vhristev commented Jul 5, 2018

JasonRivers last post is that he fix permissions ,so pull the latest code and try again.

As I said its a matter of user ownership ,so when you run the image you can see which user ID is creating files and chown to that ID

@nicocolt
Copy link

nicocolt commented Jul 5, 2018 via email

@nicocolt
Copy link

nicocolt commented Jul 6, 2018 via email

@JasonRivers
Copy link
Owner

@nicocolt This should work fine, I do exactly that, What version of NRPE are you running on the host? I recommend using version 3.2.1 (Which is what the nagios container is running), Is it failing for other hosts or only the host that the container is running on? Could you raise a new issue for this and include your config for monitoring the host?

@nicocolt
Copy link

nicocolt commented Jul 11, 2018 via email

@nicocolt
Copy link

nicocolt commented Jul 12, 2018 via email

@JasonRivers
Copy link
Owner

I'm not sure about a binary package for NRPE I have always compiled from source because distro packages are always out of date. Please raise a new issue if you want further help.

@JasonRivers
Copy link
Owner

Closing as I believe original issue is resolved.

@samz-github
Copy link

This issue is not resolved yet..

@itsmepetrov
Copy link

same here

@mabazyar
Copy link

mabazyar commented Apr 4, 2019

Yeaa there is some issue with perl path like /usr/local/lib/x86_64-linux-gnu/perl/5.22.1 ...etc.

The workaround is to reinstall NagiosGraph. Here is how you can do that:

Start your container with volumes
#Enter your container
docker exec -it nagios4 /bin/bash

#Clean /opt/nagiosgraph folder --- you will receive ...etc and ... var are busy dont worry.
rm -rf /opt/nagiosgraph

#Build your NagiosGraph --- you dont need to download it its already there just reinstall it.
cd /tmp/nagiosgraph &&
./install.pl --install
--prefix /opt/nagiosgraph
--nagios-user ${NAGIOS_USER}
--www-user ${NAGIOS_USER}
--nagios-perfdata-file ${NAGIOS_HOME}/var/perfdata.log
--nagios-cgi-url /cgi-bin
&&
cp share/nagiosgraph.ssi ${NAGIOS_HOME}/share/ssi/common-header.ssi

No errors anymore.

It works like a dream for me...Thanks for sharing your experience 👍

@davorceman
Copy link

davorceman commented May 10, 2019

Hello, just to say... I'm also getting this error with 4.4.3 version

Can't locate ngshared.pm in @inc (you may need to install the ngshared module) (@inc contains: /opt/nagiosgraph/etc /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.22.1 /usr/local/share/perl/5.22.1 /usr/lib/x86_64-linux-gnu/perl5/5.22 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.22 /usr/share/perl/5.22 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base .) at /opt/nagiosgraph/bin/insert.pl line 41.

@kaka987
Copy link

kaka987 commented May 30, 2019

https://github.com/mconf/nagios-etc/blob/master/nagiosgraph/ngshared.pm
It works ok after putting the file here: nagiosgraph/etc

@iercan
Copy link

iercan commented Mar 17, 2020

I had same issue. Then I realized because of I mount my own empty nagiosgraph/etc directory nagios can not see any conf and ngshared.pm file. I fixed issue by creating another container without any volume mount and copy all files from /opt/nagiosgraph/etc to old one. To fix these issue nagios_start may create all these files when etc directory is empty.

@jonnymccullagh
Copy link

I fell over this issue today and would recommend that the documentation/readme be updated. Recommending the volume mount for nagiosgraph-etc was added in PR 64 but I have opened PR 146 to remove that line from the readme.
/opt/nagiosgraph/etc contains the following files by default.

access.conf     labels.conf               nagiosgraph-nagios.cfg  nagiosgraph_fr.conf
datasetdb.conf  map                       nagiosgraph.conf        ngshared.pm
groupdb.conf    nagiosgraph-apache.conf   nagiosgraph_de.conf     rrdopts.conf
hostdb.conf     nagiosgraph-commands.cfg  nagiosgraph_es.conf     servdb.conf

Mounting an empty volume at that location hides these files. I would suggest that new users do not want that to happen and experienced users will be able to copy those files out before mounting a volume over it.

@i15e
Copy link

i15e commented Jan 11, 2024

Per the comments above I worked around this by creating a temporary container and copying /opt/nagiosgraph/etc to the host filesystem's nagiosgraph basedir:

(c=$(docker create jasonrivers/nagios:latest) && {
   sudo docker cp -a $c:/opt/nagiosgraph/etc /HOST/PATH/TO/nagiosgraph
   docker rm $c >/dev/null
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests