Nagvis WuiViewEditMainCfg.php error
Nagvis WuiViewEditMainCfg.php error
Nagios XI 5.27 running on centos 7.1.1503.
Nagvis Component 1.1.2 (up to date)
When I am trying to access HOME - NAGVIS - OPEN - WUI -OPTIONS - GENERAL CONFIGURATION
I am getting PHP error
PHP error in ajax request handler: Error: (8) Array to string conversion (/usr/local/nagvis/share/server/core/classes/WuiViewEditMainCfg.php
I found one post mentioning new Nagvis version, but Nagios XI docs telling me not to install it from nagvis site, but use Nagvis component.
So at this point I am stuck. Anything I missing?
Nagvis Component 1.1.2 (up to date)
When I am trying to access HOME - NAGVIS - OPEN - WUI -OPTIONS - GENERAL CONFIGURATION
I am getting PHP error
PHP error in ajax request handler: Error: (8) Array to string conversion (/usr/local/nagvis/share/server/core/classes/WuiViewEditMainCfg.php
I found one post mentioning new Nagvis version, but Nagios XI docs telling me not to install it from nagvis site, but use Nagvis component.
So at this point I am stuck. Anything I missing?
Re: Nagvis WuiViewEditMainCfg.php error
Where are you seeing this error? Can you post the entire file? /usr/local/nagvis/share/server/core/classes/WuiViewEditMainCfg.php
Former Nagios Employee
Re: Nagvis WuiViewEditMainCfg.php error
URL http://myname.mydomain.com/nagvis/front ... /index.php#
Code: Select all
<?php
/*****************************************************************************
*
* WuiViewEditMainCfg.php - Class to render the main configuration edit dialog
*
* Copyright (c) 2004-2010 NagVis Project (Contact: [email protected])
*
* License:
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*****************************************************************************/
/**
* @author Lars Michelsen <[email protected]>
*/
class WuiViewEditMainCfg {
private $CORE;
private $AUTHENTICATION;
private $AUTHORISATION;
/**
* Class Constructor
*
* @param GlobalCore $CORE
* @author Lars Michelsen <[email protected]>
*/
public function __construct(CoreAuthHandler $AUTHENTICATION, CoreAuthorisationHandler $AUTHORISATION) {
$this->CORE = GlobalCore::getInstance();
$this->AUTHENTICATION = $AUTHENTICATION;
$this->AUTHORISATION = $AUTHORISATION;
}
/**
* Parses the information in html format
*
* @return String String with Html Code
* @author Lars Michelsen <[email protected]>
*/
public function parse() {
// Initialize template system
$TMPL = New CoreTemplateSystem($this->CORE);
$TMPLSYS = $TMPL->getTmplSys();
$aData = Array(
'htmlBase' => $this->CORE->getMainCfg()->getValue('paths', 'htmlbase'),
'formContents' => $this->getFields(),
'langSave' => $this->CORE->getLang()->getText('save')
);
// Build page based on the template file and the data array
return $TMPLSYS->get($TMPL->getTmplFile('default', 'wuiEditMainCfg'), $aData);
}
/**
* Parses the Form fields
*
* @return Array Html
* @author Lars Michelsen <[email protected]>
* FIXME: Recode to have all the HTML code in the template
*/
function getFields() {
$ret = '';
$i = 1;
foreach($this->CORE->getMainCfg()->getValidConfig() AS $cat => $arr) {
// don't display backend,rotation and internal options
if(!preg_match("/^(backend|internal|rotation|auth)/i", $cat)) {
$ret .= '<tr><th class="cat" colspan="3"><h2>'.$cat.'</h2></th></tr>';
foreach($arr AS $propname => $prop) {
$class = '';
$style = '';
$isDefaultValue = false;
// Skip deprecated options
if(isset($prop['deprecated']) && $prop['deprecated'] == 1)
continue;
// Set field type to show
$fieldType = 'text';
if(isset($prop['field_type'])) {
$fieldType = $prop['field_type'];
}
// Don't show anything for hidden options
if($fieldType !== 'hidden') {
// Only get the really set value
$val2 = $this->CORE->getMainCfg()->getValue($cat, $propname, true);
// Check if depends_on and depends_value are defined and if the value
// is equal. If not equal hide the field
if(isset($prop['depends_on']) && isset($prop['depends_value'])
&& $this->CORE->getMainCfg()->getValue($cat, $prop['depends_on'], false) != $prop['depends_value']) {
$class = ' class="child-row"';
$style = ' style="display:none;"';
} elseif(isset($prop['depends_on']) && isset($prop['depends_value'])
&& $this->CORE->getMainCfg()->getValue($cat, $prop['depends_on'], false) == $prop['depends_value']) {
//$style .= 'display:;';
$class = ' class="child-row"';
}
// Create a "helper" field which contains the real applied value
if($val2 === false) {
$defaultValue = $this->CORE->getMainCfg()->getValue($cat, $propname, false);
if(is_array($defaultValue)) {
$defaultValue = implode(',', $defaultValue);
}
$ret .= '<input type="hidden" id="_'.$cat.'_'.$propname.'" name="_'.$cat.'_'.$propname.'" value="'.$defaultValue.'" />';
} else {
$ret .= '<input type="hidden" id="_'.$cat.'_'.$propname.'" name="_'.$cat.'_'.$propname.'" value="" />';
}
# we add a line in the form
$ret .= '<tr'.$class.$style.'>';
$ret .= '<td class="tdlabel">'.$propname.'</td>';
if(preg_match('/^TranslationNotFound:/', $this->CORE->getLang()->getText($propname)) > 0) {
$ret .= '<td class="tdfield"></td>';
} else {
$ret .= '<td class="tdfield">';
$ret .= "<img style=\"cursor:help\" src=\"./images/help_icon.png\" onclick=\"javascript:alert('".$this->CORE->getLang()->getText($propname)." (".$this->CORE->getLang()->getText('defaultValue').": ".$arr[$propname]['default'].")')\" />";
$ret .= '</td>';
}
$ret .= '<td class="tdfield">';
switch($fieldType) {
case 'dropdown':
switch($propname) {
case 'language':
$arrOpts = $this->CORE->getAvailableLanguages();
break;
case 'backend':
$arrOpts = $this->CORE->getDefinedBackends();
break;
case 'icons':
$arrOpts = $this->CORE->getAvailableIconsets();
break;
case 'headertemplate':
$arrOpts = $this->CORE->getAvailableHeaderTemplates();
break;
case 'autoupdatefreq':
$arrOpts = Array(Array('value'=>'0','label'=>$this->CORE->getLang()->getText('disabled')),
Array('value'=>'2','label'=>'2'),
Array('value'=>'5','label'=>'5'),
Array('value'=>'10','label'=>'10'),
Array('value'=>'25','label'=>'25'),
Array('value'=>'50','label'=>'50'));
break;
}
$ret .= '<select id="'.$cat.'_'.$propname.'" name="'.$cat.'_'.$propname.'" onBlur="validateMainConfigFieldValue(this)">';
$ret .= '<option value=""></option>';
foreach($arrOpts AS $val) {
if(is_array($val)) {
$ret .= '<option value="'.$val['value'].'">'.$val['label'].'</option>';
} else {
$ret .= '<option value="'.$val.'">'.$val.'</option>';
}
}
$ret .= '</select>';
$ret .= '<script>document.edit_config.elements[\''.$cat.'_'.$propname.'\'].value = \''.$val2.'\';</script>';
break;
case 'boolean':
$ret .= '<select id="'.$cat.'_'.$propname.'" name="'.$cat.'_'.$propname.'" onBlur="validateMainConfigFieldValue(this)">';
$ret .= '<option value=""></option>';
$ret .= '<option value="1">'.$this->CORE->getLang()->getText('yes').'</option>';
$ret .= '<option value="0">'.$this->CORE->getLang()->getText('no').'</option>';
$ret .= '</select>';
$ret .= '<script>document.edit_config.elements[\''.$cat.'_'.$propname.'\'].value = \''.$val2.'\';</script>';
break;
case 'text':
if(is_array($val2)) {
$val2 = implode(',', $val2);
}
$ret .= '<input id="'.$cat.'_'.$propname.'" type="text" name="'.$cat.'_'.$propname.'" value="'.$val2.'" onBlur="validateMainConfigFieldValue(this)" />';
if(isset($prop['locked']) && $prop['locked'] == 1) {
$ret .= "<script>document.edit_config.elements['".$cat."_".$propname."'].disabled=true;</script>";
}
break;
}
// Initially toggle the depending fields
$ret .= '<script>validateMainConfigFieldValue(document.getElementById("'.$cat.'_'.$propname.'"));</script>';
$ret .= '</td>';
$ret .= '</tr>';
}
}
if($i % 3 == 0) {
$ret .= '</table><table class="mytable" style="width:300px;float:left">';
}
$i++;
}
}
return $ret;
}
}
?>
Re: Nagvis WuiViewEditMainCfg.php error
That looks fine. What is the output of php -v and rpm -qa|grep php?
Former Nagios Employee
Re: Nagvis WuiViewEditMainCfg.php error
PHP 5.4.16 (cli) (built: Jun 23 2015 21:17:27)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
php-xml-5.4.16-36.el7_1.x86_64
php-pgsql-5.4.16-36.el7_1.x86_64
php-pear-1.9.4-21.el7.noarch
php-mcrypt-5.4.16-3.el7.x86_64
php-common-5.4.16-36.el7_1.x86_64
php-cli-5.4.16-36.el7_1.x86_64
php-5.4.16-36.el7_1.x86_64
php-mysql-5.4.16-36.el7_1.x86_64
php-mbstring-5.4.16-36.el7_1.x86_64
php-process-5.4.16-36.el7_1.x86_64
php-pecl-ssh2-0.12-1.el7.x86_64
php-ldap-5.4.16-36.el7_1.x86_64
php-gd-5.4.16-36.el7_1.x86_64
php-pdo-5.4.16-36.el7_1.x86_64
php-mssql-5.4.16-3.el7.x86_64
php-snmp-5.4.16-36.el7_1.x86_64
php-pear-HTML-Template-IT-1.3.0-2.el5.noarch
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
php-xml-5.4.16-36.el7_1.x86_64
php-pgsql-5.4.16-36.el7_1.x86_64
php-pear-1.9.4-21.el7.noarch
php-mcrypt-5.4.16-3.el7.x86_64
php-common-5.4.16-36.el7_1.x86_64
php-cli-5.4.16-36.el7_1.x86_64
php-5.4.16-36.el7_1.x86_64
php-mysql-5.4.16-36.el7_1.x86_64
php-mbstring-5.4.16-36.el7_1.x86_64
php-process-5.4.16-36.el7_1.x86_64
php-pecl-ssh2-0.12-1.el7.x86_64
php-ldap-5.4.16-36.el7_1.x86_64
php-gd-5.4.16-36.el7_1.x86_64
php-pdo-5.4.16-36.el7_1.x86_64
php-mssql-5.4.16-3.el7.x86_64
php-snmp-5.4.16-36.el7_1.x86_64
php-pear-HTML-Template-IT-1.3.0-2.el5.noarch
Re: Nagvis WuiViewEditMainCfg.php error
Some Nagvis Support Information
Code: Select all
NagVis Version 1.5.9
PHP Version 5.4.16
MySQL Version mysql Ver 15.1 Distrib 5.5.44-MariaDB, for Linux (x86_64) using readline 5.1
SERVER_SOFTWARE Apache/2.4.6 (CentOS) OpenSSL/1.0.1e-fips PHP/5.4.16
SCRIPT_FILENAME /usr/local/nagvis/share/frontend/nagvis-js/index.php
SCRIPT_NAME /nagvis/frontend/nagvis-js/index.php
REQUEST_TIME 1461696225 (gmdate(): Tue, 26 Apr 2016 18:43:45 +0000)
PHP Information
error_reporting 30719
safe_mode no
max_execution_time 30 seconds
memory_limit 128M
loaded modules Core, date, ereg, libxml, openssl, pcre, zlib, bz2, calendar, ctype, hash, filter, ftp, gettext, gmp, SPL, iconv, Reflection, session, standard, shmop, SimpleXML, sockets, mbstring, tokenizer, xml, apache2handler, bcmath, curl, dom, fileinfo, gd, json, ldap, exif, mcrypt, mssql, mysql, mysqli, PDO, pdo_dblib, pdo_mysql, pdo_pgsql, pdo_sqlite, pgsql, Phar, posix, snmp, SourceGuardian, sqlite3, ssh2, sysvmsg, sysvsem, sysvshm, tidy, wddx, xmlreader, xmlwriter, xsl, zip, mhash
Logon Module LogonEnv
Logon Var PHP_AUTH_USER
PHP_AUTH_USER nagiosadmin
Logon Create User? 1
Logon Create User Role? Guests
User Logged In nagiosadmin (1)
User Roles [{"roleId":"1","name":"Administrators"}]
User Permissions {"*":{"*":{"*":[]}}}Re: Nagvis WuiViewEditMainCfg.php error
NagVis Version 1.5.9 looks pretty old. 1.85 listed as latest stable version.
Re: Nagvis WuiViewEditMainCfg.php error
That bug seems to be version-specific: https://bugs.debian.org/cgi-bin/bugrepo ... bug=696235
We've discussed updating NagVis in the future, but a lot of testing needs to be done in order to make that change. Do you use mk_livestatus at all? I haven't seen this error before, and some searches seemed to include Livestatus in a lot of the reports. I'm not able to reproduce this on my system.
We've discussed updating NagVis in the future, but a lot of testing needs to be done in order to make that change. Do you use mk_livestatus at all? I haven't seen this error before, and some searches seemed to include Livestatus in a lot of the reports. I'm not able to reproduce this on my system.
Former Nagios employee
Re: Nagvis WuiViewEditMainCfg.php error
to replicate try this:
click OPEN, then click "edit" for one of the maps
It will show Open / Actions / Map /Options menus
Clicking on "Options" and "General Configuration" immediately produce the error
click OPEN, then click "edit" for one of the maps
It will show Open / Actions / Map /Options menus
Clicking on "Options" and "General Configuration" immediately produce the error
You do not have the required permissions to view the files attached to this post.
Re: Nagvis WuiViewEditMainCfg.php error
I was able to reproduce the error on CentOS 7 some time ago. We have an internal bug report filed on the issue (task_id=8313). I expect this to be fixed in the next release of XI. It's a known issue with an older version of NagVis and CentOS 7. Here's another post, describing the same problem:
https://support.nagios.com/forum/viewto ... 41#p159534
You can either upgrade NagVis version or wait for the next release of XI. FYI, if you upgrade NagVis, you will be on your own as newer versions of NagVis are still not supported.
https://support.nagios.com/forum/viewto ... 41#p159534
You can either upgrade NagVis version or wait for the next release of XI. FYI, if you upgrade NagVis, you will be on your own as newer versions of NagVis are still not supported.
Be sure to check out our Knowledgebase for helpful articles and solutions!