pnp4nagios / pnp4nagios

PNP is an addon to NagiosCore which analyzes performance data provided by plugins and stores them automatically into RRD-databases. PNP= Pnp is Not Perfparse. Perfparse is first parsing tool in Nagios 0.x
https://github.com/pnp4nagios/pnp4nagios
GNU General Public License v2.0
11 stars 5 forks source link

After install "${prefix}" ist not replaced in config.php and SYSPATH is empty #48

Closed Aladiah2 closed 8 months ago

Aladiah2 commented 1 year ago

Describe the bug After configure, make all and make install in the /usr/local/pnp4nagios/etc/config.php the (install?-) variable "${prefix}" ist not replaced with the path. Also in pnp4nagios.conf and in install.php "${prefix}" is found. Also the SYSPATH is not set which is reported from install.php: "The configured system directory ('/') does not exist or does not contain required files."

To Reproduce Install on Ubuntu 20.04 as upgrade to 0.6.26.

Desktop (please complete the following information):

Additional context I tried to replace all values to the correct value (/usr/local/pnp4nagios/..) and I tried to configure with ./configure --prefix=/usr/local/pnp4nagios But the SYSPATH is still not set. So the kohana lib is not found (/usr/local/pnp4nagios/lib/kohana/system/) Is there a place to set SYSPATH=/usr/local/pnp4nagios/lib/kohana/system as workaround?

Thank you!

celane commented 12 months ago

This is 100% caused by me not testing the builds directly from source (as opposed to RPM builds). Finally did that, and (hopefully) have packages that work both building directly from source and also RPMs. Look for a new pre-release (on the 'testing' branch) that takes care of the problems you found.

Aladiah2 commented 12 months ago

Supplement: You may ignore this article (testing branch) and read the next one

Hello, using the testing branch today after ./configure the "Configuration summary" is totally wrong:

Nagios user/group:                nagios nagios
Install directory:
SELINUX enabled:                  no
Nagios cfg file:                  /etc/nagios/nagios.cfg
Nagios version                    4.4.14
HTML Dir:                         /usr/share/nagios/html/pnp4nagios
Config Dir:                       /etc/pnp4nagios
Location of rrdtool binary:       /usr/bin/rrdtool Version 1.7.2
RRDs Perl Modules:                FOUND (Version 1.7002)
RRD Files stored in:              /var/log/pnp4nagios/perfdata
process_perfdata.pl Logfile:      /var/log/pnp4nagios/perfdata.log
Perfdata files (NPCD) stored in:  /var/log/pnp4nagios/spool

It should be like this:

Nagios user/group:                nagios nagios
Install directory:                /usr/local/pnp4nagios
HTML Dir:                         /usr/local/pnp4nagios/share
Config Dir:                       /usr/local/pnp4nagios/etc
Location of rrdtool binary:       /usr/bin/rrdtool Version 1.7.2
RRDs Perl Modules:                FOUND (Version 1.7002)
RRD Files stored in:              /usr/local/pnp4nagios/var/perfdata
process_perfdata.pl Logfile:      /usr/local/pnp4nagios/var/perfdata.log
Perfdata files (NPCD) stored in:  /usr/local/pnp4nagios/var/spool

So I have tried a lot of parameters but I can't get it for the last two: ./configure --prefix=/usr/local/pnp4nagios --with-nagios-cfg=/usr/local/nagios/etc/nagios.cfg --with-perfdata-dir=/usr/local/pnp4nagios/var/perfdata --with-perfdata-logfile=/usr/local/pnp4nagios/var/perfdata.log --with-perfdata-spool-dir=/usr/local/pnp4nagios/var/spool

Still wrong:

HTML Dir:                         /usr/local/pnp4nagios/usr/share/nagios/html/pnp4nagios
Config Dir:                       /usr/local/pnp4nagios/etc/pnp4nagios

I have to use php8.1 and need your fork to work please (Ubuntu 22.04 now).

Thank you

Aladiah2 commented 12 months ago

...Ok, the "stable" one works now but with empty stats graphics: image

What I did: ./configure --prefix=/usr/local/pnp4nagios --with-nagios-cfg=/usr/local/nagios/etc/nagios.cfg --with-perfdata-dir=/usr/local/pnp4nagios/var/perfdata --with-perfdata-logfile=/usr/local/pnp4nagios/var/perfdata.log --with-perfdata-spool-dir=/usr/local/pnp4nagios/var/spool --sysconfdir=/usr/local/pnp4nagios/etc --with-kohana_system=/usr/local/pnp4nagios/lib/kohana/system

vi /usr/local/pnp4nagios/etc/config.php
%s/${prefix}/\/usr\/local\/pnp4nagios/g

rm /usr/local/pnp4nagios/share/install.php (By the way the install.php is not compatible to php8.X Undefined constant "MB_OVERLOAD_STRING")

Sadly I have empty stats now and I don't know how to fix this and give up now :-/

celane commented 11 months ago

You might want to try the most recent "testing pre-release" 0.6.27-4k, at least to see if the configuration is working better.

If you know what the correct paths are for a debian installation, please take a look at the code in configure.ac for how paths are set based on the "layout" choice; most of which are reported at the end of doing a configure, but some aren't reported to the user yet.

Aladiah2 commented 11 months ago

Got this pnp4nagios-0.6.27-4k and configure with ./configure --prefix=/usr/local/pnp4nagios or ./configure sets the Install directory to /usr/local only!

After this changes in configure.ac case $layout in debian) prefix="/usr/local/hellohello"

I got this:

General Options:


Nagios user/group: nagios nagios directory layout: debian Install directory: /usr/local/hellohello SELINUX enabled: no Nagios cfg file: /etc/nagios/nagios.cfg Nagios version 4.4.6 HTML Dir: /usr/local/hellohello/pnp4nagios/share Config Dir: /usr/local/hellohello/pnp4nagios/etc Location of rrdtool binary: /usr/bin/rrdtool Version 1.7.2 RRDs Perl Modules: FOUND (Version 1.7002) RRD Files stored in: /usr/local/hellohello/pnp4nagios/var/perfdata process_perfdata.pl Logfile: /usr/local/hellohello/pnp4nagios/var/perfdata.log Perfdata files (NPCD) stored in: /usr/local/hellohello/pnp4nagios/var/spool

So instead of setting hellohello with pnp4nagios I would get a doubled path "pnp4nagios/pnp4nagios". How can I set the correct paths?

Anyway I compiled without anything and make install says "/usr/bin/install: ungültige Gruppe »apache“" wich means "invaid group". The correct group (and user) are www-data on debian systems instead of apache.

So I tried the next two parameters: ./configure --prefix=/usr/local/pnp4nagios --with-nagios-cfg=/usr/local/nagios/etc/nagios.cfg --with-perfdata-dir=/usr/local/pnp4nagios/var/perfdata --with-perfdata-logfile=/usr/local/pnp4nagios/var/perfdata.log --with-perfdata-spool-dir=/usr/local/pnp4nagios/var/spool --sysconfdir=/usr/local/pnp4nagios/etc --with-kohana_system=/usr/local/pnp4nagios/lib/kohana/system --with-http-user=www-data --with-http-group=www-data

The config.php ist without the prefix var, but the stats are still emtpy (broken image like before).

Ok, I tried the URL of the missing graph image directly (works exactly on our old nagios server): https://nagiosvm1.lcl.offis.de/pnp4nagios/image?host=api.bbb.infra.run&srv=_HOST_ "Please check the documentation for information about the following error. Implicit conversion from float 1.5 to int loses precision file [line]: application/models/rrdtool.php [233]:"

celane commented 11 months ago

Thanks for the further testing and information! I have an "ubuntu" (debian like) virtual machine set up for testing, but it is incredibly slow, and I'm not familiar with the "debian way" of doing things.

But I am going to look a lot closer at the Nagios autoconf setup. Everything you can tell me about how the pnp4nagios package "should" be set up for a debian system is very helpful.

Aladiah2 commented 11 months ago

Hello Celane, with all my parameters above it seems to work basicly. Performance data is written! The last barrier may be the conversion error from the rrdtool.php. That could be the reason that all images can't be generated in realtime:

https://nagios-server/pnp4nagios/image?host=hostname&srv=_HOST_

"Please check the documentation for information about the following error. Implicit conversion from float 1.5 to int loses precision file [line]: application/models/rrdtool.php [233]:"

This is a php 8 problem again: https://php.watch/versions/8.1/deprecate-implicit-conversion-incompatible-float-string

In line 232 I add this line: $font_size = (int)$font_size;

Now I get a big red windows with this message: env XDG_CACHE_HOME (/var/cache/httpd) is not writable

I don't know where to set this, so I do this: md /var/cache/httpd chown root:www-data /var/cache/httpd chmod 660 /var/cache/httpd

IT WORKS NOW :-)

The only thing I miss are the popups showing small previews of graphs. Example of embedded link: /pnp4nagios/popup?host=hostname&srv=HOST Nothing is popping up. I don't know how to debug this. Maybe an other php8 issue somewhere.

sistemmsn commented 9 months ago

Regarding your question, the issue is how it is declared in configure and configure.ac, since it is not well declared, the routes are as you want to have them predefined, I modified it this way so that just by running it ./ configure me set the path to: /opt/pnp4nagios and its directories

I don't know which one you take so I edited both.

configure.ac: "rhel" | "default" ) prefix="/opt" exec_prefix=$prefix bindir="$prefix/${PACKAGE_NAME}/bin" sbindir="$prefix/${PACKAGE_NAME}/sbin" datadir="$prefix/${PACKAGE_NAME}/share" libdir="${prefix}/${PACKAGE_NAME}/lib${x64}" sysconfdir="${prefix}/${PACKAGE_NAME}/etc" localstatedir="${prefix}/${PACKAGE_NAME}/var/log" libexecdir="${prefix}/${PACKAGE_NAME}/libexec" libdir="${prefix}/${PACKAGE_NAME}/lib${x64}" datarootdir="${prefix}/${PACKAGE_NAME}/share" PERFDATA_LOG="${prefix}/${PACKAGE_NAME}/var/perfdata.log" PERFDATA_DIR="${prefix}/${PACKAGE_NAME}/var/perfdata" PERFDATA_SPOOL_DIR="${prefix}/${PACKAGE_NAME}/var/spool" mandir="${prefix}/${PACKAGE_NAME}/man"

configure: "rhel" | "default" ) prefix="/opt" exec_prefix=$prefix bindir="$prefix/${PACKAGE_NAME}/bin" sbindir="$prefix/${PACKAGE_NAME}/sbin" datadir="$prefix/${PACKAGE_NAME}/share" libdir="${prefix}/${PACKAGE_NAME}/lib${x64}" sysconfdir="${prefix}/${PACKAGE_NAME}/etc" localstatedir="${prefix}/${PACKAGE_NAME}/var/log" libexecdir="${prefix}/${PACKAGE_NAME}/libexec" libdir="${prefix}/${PACKAGE_NAME}/lib${x64}" datarootdir="${prefix}/${PACKAGE_NAME}/share" PERFDATA_LOG="${prefix}/${PACKAGE_NAME}/var/perfdata.log" PERFDATA_DIR="${prefix}/${PACKAGE_NAME}/var/perfdata" PERFDATA_SPOOL_DIR="${prefix}/${PACKAGE_NAME}/var/spool" mandir="${prefix}/${PACKAGE_NAME}/man"

image

I have a problem in which it does not run manually, I add my incident, because they refer to the compilation issue: #47

image I am correcting that it is already running, annex evidence:

image

Now I'll see if it generates performance data

I also remember that @celane says that the rpm version is stable, but I don't like the way it forks the files, apart from the fact that it requires nagios dependencies and installs a directory in: /etc/nagios with the nagios objects and Well I think that's unnecessary

Use the version "testing pre-release" 0.6.27-4k

sistemmsn commented 9 months ago

It works correctly, any changes you make in the build

image

Everything is being tested from an almalinux 8.9 PHP 8.0 image

sistemmsn commented 9 months ago

"rhel" | "default" ) prefix="/opt" exec_prefix=$prefix bindir="$prefix/${PACKAGE_NAME}/bin" sbindir="$prefix/${PACKAGE_NAME}/sbin" datadir="$prefix/${PACKAGE_NAME}/share" libdir="${prefix}/${PACKAGE_NAME}/lib${x64}" sysconfdir="${prefix}/${PACKAGE_NAME}/etc" localstatedir="${prefix}/${PACKAGE_NAME}/var/log" libexecdir="${prefix}/${PACKAGE_NAME}/libexec" libdir="${prefix}/${PACKAGE_NAME}/lib${x64}" datarootdir="${prefix}/${PACKAGE_NAME}/share" PERFDATA_LOG="${prefix}/${PACKAGE_NAME}/var/perfdata.log" PERFDATA_DIR="${prefix}/${PACKAGE_NAME}/var/perfdata" PERFDATA_SPOOL_DIR="${prefix}/${PACKAGE_NAME}/var/spool" mandir="${prefix}/${PACKAGE_NAME}/man"

Je viens de tester avec php 8.1 et tout semble bien fonctionner

image

image

sistemmsn commented 9 months ago

When you perform make fullinstall at the end of the installation it throws an error due to the issue of nagios files, it is not an impediment to it not working, but it looks ugly, what I did was run make by make so it only installs what is necessary and in fact that way it allows you to run it the traditional way: /opt/pnp4nagios/bin/npcd -d -f /opt/pnp4nagios/etc/npcd.cfg

./configure &&\ make all &&\ make install &&\ make install-webconf &&\ make install-config &&\ make install-init &&\ make install-processperfdata &&\ make install-html &&\ make install-plugins

celane commented 8 months ago

closing this issue, because new version 0.6.27-5 incorporates fixes for install/run, tested okay on debian.