NagVis automap on CentOS 7.5


(Mj84) #1

Hi folks,

I’m currently struggling getting the NagVis automap feature to work with the following setup:
CentOS 7.5
nginx 1.12.2
php-fpm 7.1.8
GraphViz 2.30

First of, NagVis complained that the PHP $_SERVER variable did not have a key named “PATH” which I worked around by creating a fastcgi_param in my nginx config for that (all my GraphViz binaries where installed to /bin):
fastcgi_param PATH /bin;

Now I receive the message

The required graphviz binary “dot” could not be found in the paths: “/bin:/usr/local/bin/”.

SELinux is set to permissive and I can’t find any error messages in any log whatsoever.
The NagVis messages originates from /usr/local/nagvis/share/server/core/sources/automap_pos.php, line 27.
PHP calls which dot and checks if the return code is zero.
When I execute that command manually in the context of my PHP user, everything is fine, the binary is found.

Can someone provide any hint?

Cheers,
Markus

EDIT
These are the exact commands which are executed on my system:
which /usr/local/bin/dot 2>/dev/null
which dot 2>/dev/null

The first call uses the default value of automap graphvizpath, the second one searches in all of $PATH.
I have also tried symlinking /bin/dot to /usr/local/bin/dot but that didnt help either.


#2

Is the user running the nginx process allowed to access the dot binary (directory/file permissions)?


(Mj84) #3

I have nginx running under a different user than php-fpm, but both are allowed to execute /bin/dot.

How I see it, the exitcode of these “which” calls somehow always return non-zero, otherwise the loop in automap_check_graphviz() would be exited.


#4

I’d specify the full path to which. Processes mostly have a different environment than users.


(Mj84) #5

I placed the following php file to /usr/local/nagvis/share/whichtest.php:

<?php
  $path = 'dot';
  print('which '.$path.' 2>/dev/null;'."\n");
  exec('which '.$path.' 2>/dev/null', $arrReturn, $exitCode);
  print($exitCode."\n");
?>

So I can confirm if which is returning 1, which it is indeed.
I also changed the execution of which to /usr/bin/which but it did not change anything.
Even when I try

<?php
 exec('/usr/bin/which /bin/dot 2>/dev/null', $arrReturn, $exitCode);
?>

I get a return code of 1.


(Mj84) #6

I found the problem.
php-fpm provides a “clean” environment to its child processes, hence $PATH is not available.
I was able to fix NagVis automap by setting env[PATH] = /usr/local/bin:/usr/bin:/bin in /etc/opt/rh/rh-php71/php-fpm.d/www.conf