nagvis icon indicating copy to clipboard operation
nagvis copied to clipboard

Error: Syntax Error - Invalid JSON response : Error (Error): Call to a member function prepare() on nullarray(1)

Open ACEM-COOP opened this issue 3 years ago • 6 comments

hello,

I just did a fresh installation of Nagvis and I encounter this error when I want to add a host or service on a map. Can you help me with this problem?

Error: Syntax Error

Invalid JSON response Time: 1598940649 URL: /nagvis/server/core/ajax_handler.php?mod=Map&act=addModify&show=SERVEUR&type=host&x=345&y=215&_ajaxid=1598940649 Response:

Error (Error): Call to a member function prepare() on nullarray(1) { [0]=> array(2) { ["function"]=> string(15) "nagvisException" ["args"]=> array(1) { [0]=> object(Error)#29 (7) { ["message":protected]=> string(43) "Call to a member function prepare() on null" ["string":"Error":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(62) "/usr/local/nagvis/share/server/core/classes/CorePDOHandler.php" ["line":protected]=> int(321) ["trace":"Error":private]=> array(11) { [0]=> array(5) { ["file"]=> string(62) "/usr/local/nagvis/share/server/core/classes/CorePDOHandler.php" ["line"]=> int(339) ["function"]=> string(4) "prep" ["class"]=> string(14) "CorePDOHandler" ["type"]=> string(2) "->" } [1]=> array(5) { ["file"]=> string(64) "/usr/local/nagvis/share/server/core/classes/GlobalBackendPDO.php" ["line"]=> int(248) ["function"]=> string(5) "query" ["class"]=> string(14) "CorePDOHandler" ["type"]=> string(2) "->" } [2]=> array(5) { ["file"]=> string(54) "/usr/local/nagvis/share/server/core/mapcfg/default.php" ["line"]=> int(147) ["function"]=> string(10) "getObjects" ["class"]=> string(16) "GlobalBackendPDO" ["type"]=> string(2) "->" } [3]=> array(3) { ["file"]=> string(54) "/usr/local/nagvis/share/server/core/mapcfg/default.php" ["line"]=> int(161) ["function"]=> string(14) "getObjectNames" } [4]=> array(3) { ["file"]=> string(64) "/usr/local/nagvis/share/server/core/classes/ViewMapAddModify.php" ["line"]=> int(394) ["function"]=> string(13) "listHostNames" } [5]=> array(5) { ["file"]=> string(64) "/usr/local/nagvis/share/server/core/classes/ViewMapAddModify.php" ["line"]=> int(512) ["function"]=> string(9) "drawField" ["class"]=> string(16) "ViewMapAddModify" ["type"]=> string(2) "->" } [6]=> array(5) { ["file"]=> string(64) "/usr/local/nagvis/share/server/core/classes/ViewMapAddModify.php" ["line"]=> int(540) ["function"]=> string(10) "drawFields" ["class"]=> string(16) "ViewMapAddModify" ["type"]=> string(2) "->" } [7]=> array(5) { ["file"]=> string(64) "/usr/local/nagvis/share/server/core/classes/ViewMapAddModify.php" ["line"]=> int(623) ["function"]=> string(8) "drawForm" ["class"]=> string(16) "ViewMapAddModify" ["type"]=> string(2) "->" } [8]=> array(5) { ["file"]=> string(58) "/usr/local/nagvis/share/server/core/classes/CoreModMap.php" ["line"]=> int(134) ["function"]=> string(5) "parse" ["class"]=> string(16) "ViewMapAddModify" ["type"]=> string(2) "->" } [9]=> array(5) { ["file"]=> string(55) "/usr/local/nagvis/share/server/core/functions/index.php" ["line"]=> int(120) ["function"]=> string(12) "handleAction" ["class"]=> string(10) "CoreModMap" ["type"]=> string(2) "->" } [10]=> array(4) { ["file"]=> string(52) "/usr/local/nagvis/share/server/core/ajax_handler.php" ["line"]=> int(59) ["args"]=> array(1) { [0]=> string(55) "/usr/local/nagvis/share/server/core/functions/index.php" } ["function"]=> string(7) "require" } } ["previous":"Error":private]=> NULL } } } }

Configuration : Ubuntu Server 20.04.1 LTS Nagvis 1.9.21 (Nagios 4.4.6 + Ndo 2.1.3) with Backend ndomy_1 Apache 2.4.41 + PHP 7.4.3

Firefox ESR 78.2.0

ACEM-COOP avatar Sep 01 '20 07:09 ACEM-COOP

Any idee ?

.../nagvis/frontend/nagvis-js/index.php?mod=Info :

Version Information

NagVis Version | 1.9.21 PHP Version | 7.4.3 MySQL Version | mysql Ver 8.0.21-0ubuntu0.20.04.4 for Linux on x86_64 ((Ubuntu)) OS | Linux srvnagios1 5.4.0-45-generic #49-Ubuntu SMP Wed Aug 26 13:38:52 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

SERVER_SOFTWARE | Apache/2.4.41 (Ubuntu) SCRIPT_FILENAME | /usr/local/nagvis/share/frontend/nagvis-js/index.php SCRIPT_NAME | /nagvis/frontend/nagvis-js/index.php REQUEST_TIME | 1599466068 (gmdate(): Mon, 07 Sep 2020 08:07:48 +0000)

error_reporting | 30719 safe_mode | no max_execution_time | 30 seconds memory_limit | 128M loaded modules | Core, date, libxml, openssl, pcre, zlib, filter, hash, Reflection, SPL, session, standard, sodium, apache2handler, mysqlnd, PDO, xml, bz2, calendar, ctype, curl, dom, mbstring, FFI, fileinfo, ftp, gd, gettext, iconv, json, exif, mysqli, pdo_mysql, pdo_sqlite, Phar, posix, readline, shmop, SimpleXML, sockets, sqlite3, sysvmsg, sysvsem, sysvshm, tokenizer, xmlreader, xmlwriter, xsl, zip, Zend OPcache json_encode | Oui json_decode | Oui

USER_AGENT | Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0

ACEM-COOP avatar Sep 07 '20 08:09 ACEM-COOP

Hello,

I add a complement : If I modify the GlobalBackendndomy.php file and replace : return 'mysql'; by return 'mysqld'; I don't have a synthax anymore, the menu allowing to configure the object appears but the menu doesn't find my hosts or services configured on Nagios :

The attribute needs to be set. Failed to get objects: Error: (0) Undefined property: CorePDOHandler::$data

URL: /nagvis/server/core/ajax_handler.php?mod=Map&act=addModify&_ajaxid=1599741691
File: /usr/local/nagvis/share/server/core/classes/CorePDOHandler.php
Line: 313
#0 /usr/local/nagvis/share/server/core/classes/CorePDOHandler.php(313): nagvisExceptionErrorHandler()
#1 /usr/local/nagvis/share/server/core/classes/CorePDOHandler.php(339): CorePDOHandler->prep()
#2 /usr/local/nagvis/share/server/core/classes/GlobalBackendPDO.php(248): CorePDOHandler->query()
#3 /usr/local/nagvis/share/server/core/mapcfg/default.php(147): GlobalBackendPDO->getObjects()
#4 /usr/local/nagvis/share/server/core/mapcfg/default.php(161): getObjectNames()
#5 /usr/local/nagvis/share/server/core/classes/ViewMapAddModify.php(394): listHostNames()
#6 /usr/local/nagvis/share/server/core/classes/ViewMapAddModify.php(512): ViewMapAddModify->drawField()
#7 /usr/local/nagvis/share/server/core/classes/ViewMapAddModify.php(540): ViewMapAddModify->drawFields()
#8 /usr/local/nagvis/share/server/core/classes/ViewMapAddModify.php(623): ViewMapAddModify->drawForm()
#9 /usr/local/nagvis/share/server/core/classes/CoreModMap.php(134): ViewMapAddModify->parse()
#10 /usr/local/nagvis/share/server/core/functions/index.php(120): CoreModMap->handleAction()
#11 /usr/local/nagvis/share/server/core/ajax_handler.php(59): require('/usr/local/nagv...')
#12 {main}
Output:
<form id="addmodify" name="addmodify" action="javascript:submitForm('/nagvis/server/core/ajax_handler.php?mod=Map&amp;act=addModify', 'addmodify');" method="POST"> <div class="error">The attribute needs to be set.</div> <input type="hidden" id="_form_name" name="_form_name" value="addmodify" /> <input type="hidden" id="_update" name="_update" value="0" /> <input type="hidden" id="sec" name="sec" value="general" /> <ul class="nav" id="nav"><li id="nav_general" class="active"><a href="javascript:toggle_section('general')">General</a></li><li id="nav_appearance" ><a href="javascript:toggle_section('appearance')">Appearance</a></li><li id="nav_state" ><a href="javascript:toggle_section('state')">Status</a></li><li id="nav_actions" ><a href="javascript:toggle_section('actions')">Actions</a></li><li id="nav_label" ><a href="javascript:toggle_section('label')">Label</a></li><li id="nav_worldmap" ><a href="javascript:toggle_section('worldmap')">Worldmap</a></li></ul><div id="sec_general" class="section" style=""><table class="mytable"><tr class="must"><td class=tdlabel>host_name</td><td class=tdbox></td><td class=tdfield>

I specify that I am not a developer and that I'm groping around with the different research I do on the net.

ACEM-COOP avatar Sep 10 '20 12:09 ACEM-COOP

Hi, I had a similar issue using MySQL 8. The problem: Nagvis tries to set 'sql_mode' to postgresql, which is not a valid option anymore.

Workaround: Change share/server/core/classes/CorePDOHandler.ph file line 239 (1.9.23) from: "SET SESSION sql_mode = 'postgresql'", TO "SET SESSION sql_mode = 'PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE'"

I´m not sure if these are the best options, I still need to dig more into it. But the problem was solved, and my maps are being loaded correctly now.

This page (from Mysql 5.7) describes the 'postgresql' mode and informs that will be removed in 8.0. https://dev.mysql.com/doc/refman/5.7/en/sql-mode.html

Hope it helps.

hammerli avatar Jan 27 '21 15:01 hammerli

Please send a pull request. I am not using these backends so I can not propose a fix or test it.

LarsMichelsen avatar Feb 08 '21 14:02 LarsMichelsen

@LarsMichelsen What backends you are using?

elico avatar Mar 09 '21 20:03 elico

I am using the livestatus backend.

LarsMichelsen avatar Mar 14 '21 14:03 LarsMichelsen

Solved by #348

LarsMichelsen avatar Jul 06 '23 14:07 LarsMichelsen