NagVis / nagvis

Visualization addon for your open source monitoring core
http://nagvis.org/
GNU General Public License v2.0
113 stars 73 forks source link

Automap: The required graphviz binary "dot" could not be found #206

Open johnny-b2 opened 4 years ago

johnny-b2 commented 4 years ago

Hi, I installed latest stable version of NagVis on CentOS. After fixing SELinux problem all is working well except automap function. I have installed graphviz. All required binaries are in /usr/bin/ folder.

But I always get Error: The required graphviz binary "dot" could not be found in the paths: "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/usr/bin/".

I tried specify graphvizpath variable in General/Automap Configuration to value "/usr/bin/". I tried make symlink to /usr/local/bin/. I found function "automap_check_graphviz" to check if binaries exists in file: share/server/core/sources/automap_pos.php. I copy this function to new php file. I tried to search for binaries with this function and it is working. The function find all bineries with exitCode 0. The SELinux is in permisive mode now. I'm out of ideas where to look. In apache/php log files is no error.

NagVis version 1.9.13
Distribution CenOS 7.6
Apache version 2.4
PHP version 7.1 php-fpm
Are there error messages in webservers error log? No
Browser used (Equal behaviour in other browsers?) Firefox, Chromium, Midori
Are there JavaScript errors in the browser? No

Thanks in advance for any help.

math1eu commented 4 years ago

Hello,

I have exactly the same issue. Did you solve it ?

Regards.

johnny-b2 commented 4 years ago

Unfortunately no. Still the same. Can't figure out where is the problem. Need help from devs. Please help us with this "bug?". I'm not programmer so can't do more debugging. If someone tell me what to try, I can test it. If can be found at least some workaround will be appreciated. Automap is required function for our deployment.

p4k8 commented 4 years ago

dot is one of the programs installed with graphviz package. Maybe your distribution package didn't place it's binary file in correct place or is outdated. I suggest building graphviz from source and testing that. https://graphviz.gitlab.io/_pages/Download/Download_source.html

johnny-b2 commented 4 years ago

Thanks for tip. But still nothing. Still same. From CentOS distribution there is graphviz version 2.30.1-21. From source I downloaded graphviz stable version 2.40.1. Distribution graphviz binaries are placed in /usr/bin folder. Binaries from graphviz source install are placed in /usr/local/bin folder. Both locations are standard binary locations and both are (or should be) searched by NagVis as specified in Error message. Setting specific graphviz binaries path (which is added at the end of standard path list) in NagVis configuration don't helped too. Other things tried:

When upgraded NagVis - noticed that installer found all graphviz binaries. Again: When I try PHP function "automap_check_graphviz" to check if binaries exists (from file share/server/core/sources/automap_pos.php), the function find all bineries with exitCode 0.

ekrichbaum commented 4 years ago

Agreed. On Fedora the same. In share/server/core/sources/automap_pos.php the function automap_check_graphviz($binary) can just bypass the !$bFound to return true and it will function as expected. I didn't debug the exec to see what was happening there for the return.

johnny-b2 commented 4 years ago

Thanks for test and confirmation. I tried to set default value for $bFound = true; and now the automap function is working as expected. I used it now as workaround and can live with that for now.

There has to be some bug in automap_check_graphviz($binary) function. Function alone in separate new file is working with exitCode == 0. For test I have to substitue cfg('automap','graphvizpath') with '/usr/bin/'. When I substitue it with '/usr/bin' (without ending slash), then the function will concate the path and binary to wrong final file path '/usr/bindot' insted of '/usr/bin/dot' and the code will fail with exitCode == 1. If this is the problem, then I don't get that if I set graphvizpath variable in General/Automap Configuration to value "/usr/bin/", it should work. But it don't. Maybe it is not used to search for binaries.

R00T88 commented 3 years ago

Hi, issue still present and i set $bFound = true; to fix it

NicolasGoeddel commented 2 years ago

I've got the same issue here on CentOS 8 with nagvis in version 1.9.29 with dot installed in /bin and graphvizpath="/bin/". Even the error message shows the /bin/ path.

NicolasGoeddel commented 2 years ago

After wrapping the exec call into a var_dump I see this:

string(30) "which: no /bin/dot in ((null))"

So it seems that which has no environment in which it could potentially find the 'dot' binary. The same happens if you unset the PATH variable in command line:

user@home:~$ unset PATH
user@home:~ /usr/bin/which dot
/usr/bin/which: no dot in ((null))

By the way: It would be much cleaner to use escapeshellarg() because without this is a security risk if someones writes certain things into nagvis.ini.php

My fix would be this for now:

exec('PATH='.escapeshellarg($_SERVER['PATH']).' which '.escapeshellarg($path).' 2>&1', $arrReturn, $exitCode);
CTFSE commented 2 weeks ago

I just installed the latest as of today (1.9.41) and unfortunately I am having the same issue. 'dot' was installed with the graphviz package on Rocky 9.4. I can log in to NagVis but cannot do anything within the application because of this error. Any resolution on the horizon apart from stuffing that variable?