php errors with Nagios xi on Debian

This support forum board is for support questions relating to Nagios xi, our flagship commercial network monitoring solution.
andrew.nicolson
Posts: 6
Joined: Tue Dec 21, 2010 3:17 am

php errors with Nagios xi on Debian

Post by andrew.nicolson »

Hi All...

I know installing Nagios xi on Debian is not officially supported, but I've decided to have a go.

I have managed to install what I think are all of the required patches and execute the install scripts with a couple of modifications (apache user and a couple of paths in the init.sh file). What I currently have is an installation that I can login to and navigate through. If I want to make any changes to anything eg add a host or service, I work my way through the wizard and begin to get "Invalid Argument supplied" errors relating to the use of foreach() in a number of php files.

After a quick look, it appears that the php file is expecting data in the form of an array and it is not getting an array.

Some examples are:

On the Service Status page - Warning: Invalid argument supplied for foreach() in /usr/local/nagiosxi/html/includes/components/xicore/ajaxhelpers-servicestatus.inc.php on line 361
Step 5 of the Generic Network Device Monitoring Wizard in the Other Individual Contacts box - Warning: Invalid argument supplied for foreach() in /usr/local/nagiosxi/html/config/monitoringwizard.php on line 859
Step 5 of the Generic Network Device Monitoring Wizard in the Specific contact groups box - Warning: Invalid argument supplied for foreach() in /usr/local/nagiosxi/html/config/monitoringwizard.php on line 882
Step 6 of the Generic Network Device Monitoring Wizard in the Host Groups box - Warning: Invalid argument supplied for foreach() in /usr/local/nagiosxi/html/config/monitoringwizard.php on line 1182
Step 6 of the Generic Network Device Monitoring Wizard in the Service Groups box - Warning: Invalid argument supplied for foreach() in /usr/local/nagiosxi/html/config/monitoringwizard.php on line 1207
Step 6 of the Generic Network Device Monitoring Wizard in the Parent Host box - Warning: Invalid argument supplied for foreach() in /usr/local/nagiosxi/html/config/monitoringwizard.php on line 1233
Applying the new service - Warning: Invalid argument supplied for foreach() in /usr/local/nagiosxi/html/includes/configwizards/genericnetdevice/genericnetdevice.inc.php on line 243

I would greatly appreciate any assistance with overcoming these errors. I suspect it will be something simple for someone who knows the back end code.

Andrew Nicolson
http://www.fdc.net.nz
mguthrie
Posts: 4380
Joined: Mon Jun 14, 2010 10:21 am

Re: php errors with Nagios xi on Debian

Post by mguthrie »

What version of PHP are you running?

The key items what would likely break on a Debian install are the postgresql and mysql setup for the Core Config Manager. Are you able to access and use the Core Config Manager in xi? If not, you'll have to really pick apart the install scripts to get things working and setup.

There's a LOT of places for an xi install to break in a Debian install. It will be hard to nail down where all the problems are without knowing more details in the install steps, and what succeeded, etc. The more details you can give on that, the better we might be able to point you in the right direction.
tonyyarusso
Posts: 1128
Joined: Wed Mar 03, 2010 12:38 pm
Location: St. Paul, MN, USA

Re: php errors with Nagios xi on Debian

Post by tonyyarusso »

Lenny or Squeeze? I would think Lenny's PHP would be compatible at least, but Squeeze has a version that finally dropped a number of long-deprecated behaviors, breaking all sorts of stuff targeting "legacy" PHP installs like what Red Hat has.
Tony Yarusso
Technical Services
___
TIES
Web: http://ties.k12.mn.us/
andrew.nicolson
Posts: 6
Joined: Tue Dec 21, 2010 3:17 am

Re: php errors with Nagios xi on Debian

Post by andrew.nicolson »

Hi Guys...

Firstly, thanks very much for your replys.

I can confirm that I can login to the Nagiox xi Core Config Portal. I am able to click the config options in the menu down the left hand side and there don't appear to be any php errors when viewing any of the data. I am able to see one of the hosts I tried to create a service on previously, but no services defined.

I have edited a few files along the installation process, mainly to adjust install paths and usernames. I can provide copies of the files if required. Here is a breakdown of the installation steps performed:

nagios-dv-01:/home/andrew/nagiosxi# apt-get install perl make sysstat apache2 php5 gcc libc6 mysql-client libmysqlclient15-dev libsnmp-dev libsnmp-base libmcrypt4 libmcrypt-dev dstat rrdtool php5-mysql unzip nmap php-pear bind9utils slapd libldap2-dev fping mrtg php5-pgsql php5-snmp php5-mcrypt cacti libexpat1-dev graphviz freetds-common freetds-dev unixODBC unixODBC-dev php5-odbc php5-mssql openssl libssl-dev unzip librpm-dev php5-xmlrpc sudo php5-gd libpng3 libjpeg62-dev libgd2-xpm-dev libpng12-0 libpng12-dev chkconfig postgresql
nagios-dv-01:/home/andrew/nagiosxi# pear install HTML_Template_IT
nagios-dv-01:/home/andrew/nagiosxi# perl -MCPAN -e 'install HTTP::Cookies'
nagios-dv-01:/home/andrew/nagiosxi# perl -MCPAN -e 'install HTTP::Request::Common'
nagios-dv-01:/home/andrew/nagiosxi# perl -MCPAN -e 'install Time::HiRes'
nagios-dv-01:/home/andrew/nagiosxi# perl -MCPAN -e 'install Getopt::Long'
nagios-dv-01:/home/andrew/nagiosxi# perl -MCPAN -e 'install Error'
nagios-dv-01:/home/andrew/nagiosxi# perl -MCPAN -e 'install Crypt::SSLeay'
nagios-dv-01:/home/andrew/nagiosxi# perl -MCPAN -e 'install XML::Simple'
nagios-dv-01:/home/andrew/nagiosxi# perl -MCPAN -e 'install XML::Parser'
nagios-dv-01:/home/andrew/nagiosxi# perl -MCPAN -e 'install DBD::mysql'
nagios-dv-01:/home/andrew/nagiosxi# perl -MCPAN -e 'install DBD::ODBC'
nagios-dv-01:/home/andrew/nagiosxi# perl -MCPAN -e 'install Mail::POP3Client'
nagios-dv-01:/home/andrew/nagiosxi# perl -MCPAN -e 'install Net::SMTP'
nagios-dv-01:/home/andrew/nagiosxi# perl -MCPAN -e 'install Net::SMTP::TLS'
nagios-dv-01:/home/andrew/nagiosxi# perl -MCPAN -e 'install DBD::Sybase'
nagios-dv-01:/home/andrew/nagiosxi# vi init.sh ************* to adjust apache username and paths ****************
nagios-dv-01:/home/andrew/nagiosxi/nagiosxi/basedir/scripts# vi import_nagiosql.sh
/home/andrew/nagiosxi/subcomponents/nagioscore# vi ./post-install
nagios-dv-01:/home/andrew/nagiosxi/subcomponents/nsca# vi post-install
nagios-dv-01:/home/andrew/nagiosxi/subcomponents/nagiosql# vi post-install
nagios-dv-01:/home/andrew/nagiosxi/subcomponents/nagiosql# vi pre-install
nagios-dv-01:/home/andrew/nagiosxi/subcomponents/nagiosql# vi install
nagios-dv-01:/home/andrew/nagiosxi/nagiosxi/basedir/scripts# vi fixperms.sh
nagios-dv-01:/home/andrew/nagiosxi/nagiosxi/basedir/scripts# vi reset_config_perms.sh
nagios-dv-01:/home/andrew/nagiosxi/subcomponents/nagioscore/nagios-3.2.3# make install-config
nagios-dv-01:/home/andrew/nagiosxi# useradd nagios
nagios-dv-01:/home/andrew/nagiosxi# groupadd nagcmd
nagios-dv-01:/home/andrew/nagiosxi# usermod -G nagcmd nagios
nagios-dv-01:/home/andrew/nagiosxi# usermod -G "nagios,nagcmd" www-data
nagios-dv-01:/home/andrew/nagiosxi# ./3-dbservers
nagios-dv-01:/home/andrew/nagiosxi# ./4-services
nagios-dv-01:/home/andrew/nagiosxi# ./5-sudoers
nagios-dv-01:/home/andrew/nagiosxi# ./6-firewall
nagios-dv-01:/home/andrew/nagiosxi# vi 10-phplimits ************
nagios-dv-01:/home/andrew/nagiosxi# ./10-phplimits
nagios-dv-01:/home/andrew/nagiosxi# vi 11-sourceguardian ******* Change extract path to /usr/lib/php5
nagios-dv-01:/home/andrew/nagiosxi# ./11-sourceguardian
nagios-dv-01:/home/andrew/nagiosxi# vi 12-mrtg *****************
nagios-dv-01:/home/andrew/nagiosxi# ./12-mrtg
nagios-dv-01:/home/andrew/nagiosxi# ./A-subcomponents
nagios-dv-01:/home/andrew/nagiosxi# vi B-installxi
nagios-dv-01:/home/andrew/nagiosxi# ./B-installxi
nagios-dv-01:/home/andrew/nagiosxi# ./C-cronjobs
nagios-dv-01:/home/andrew/nagiosxi# ./D-chkconfigalldaemons
nagios-dv-01:/home/andrew/nagiosxi# vi E-importnagiosql
nagios-dv-01:/home/andrew/nagiosxi# ./E-importnagiosql
nagios-dv-01:/home/andrew/nagiosxi/nagiosxi/basedir/scripts# vi ./import_nagiosql.sh
nagios-dv-01:/home/andrew/nagiosxi# vi F-startdaemons
nagios-dv-01:/home/andrew/nagiosxi# ./F-startdaemons
nagios-dv-01:/home/andrew/nagiosxi# vi Z-webroot
nagios-dv-01:/home/andrew/nagiosxi# ./Z-webroot

I am using Debian Lenny with the following package versions:

PHP:
ii php-pear 5.2.6.dfsg.1-1+lenny9 PEAR - PHP Extension and Application Repository
ii php5 5.2.6.dfsg.1-1+lenny9 server-side, HTML-embedded scripting language (metapackage)
ii php5-cli 5.2.6.dfsg.1-1+lenny9 command-line interpreter for the php5 scripting language
ii php5-common 5.2.6.dfsg.1-1+lenny9 Common files for packages built from the php5 source
ii php5-dev 5.2.6.dfsg.1-1+lenny9 Files for PHP5 module development
ii php5-gd 5.2.6.dfsg.1-1+lenny9 GD module for php5
ii php5-mcrypt 5.2.6.dfsg.1-1+lenny9 MCrypt module for php5
ii php5-mysql 5.2.6.dfsg.1-1+lenny9 MySQL module for php5
ii php5-odbc 5.2.6.dfsg.1-1+lenny9 ODBC module for php5
ii php5-pgsql 5.2.6.dfsg.1-1+lenny9 PostgreSQL module for php5
ii php5-snmp 5.2.6.dfsg.1-1+lenny9 SNMP module for php5
ii php5-sybase 5.2.6.dfsg.1-1+lenny9 Sybase / MS SQL Server module for php5
ii php5-xmlrpc 5.2.6.dfsg.1-1+lenny9 XML-RPC module for php5

MySQL:
ii libdbd-mysql-perl 4.007-1+lenny1 A Perl5 database interface to the MySQL database
ii libmysqlclient15-dev 5.0.51a-24+lenny4 MySQL database development files
ii libmysqlclient15off 5.0.51a-24+lenny4 MySQL database client library
ii mysql-client 5.0.51a-24+lenny4 MySQL database client (metapackage depending on the latest ver
ii mysql-client-5.0 5.0.51a-24+lenny4 MySQL database client binaries
ii mysql-common 5.0.51a-24+lenny4 MySQL database common files
ii mysql-server 5.0.51a-24+lenny4 MySQL database server (metapackage depending on the latest ver
ii mysql-server-5.0 5.0.51a-24+lenny4 MySQL database server binaries

PostgreSQL:
ii postgresql 8.3.12-0lenny1 object-relational SQL database (supported version)
ii postgresql-8.3 8.3.12-0lenny1 object-relational SQL database, version 8.3 server
ii postgresql-client-8.3 8.3.12-0lenny1 front-end programs for PostgreSQL 8.3
ii postgresql-client-common 94lenny1 manager for multiple PostgreSQL client versions
ii postgresql-common 94lenny1 PostgreSQL database-cluster manager

I look forward to any suggestions.

Andrew
mguthrie
Posts: 4380
Joined: Mon Jun 14, 2010 10:21 am

Re: php errors with Nagios xi on Debian

Post by mguthrie »

I tried to muscle my way through the install scripts on Ubuntu about 2 months ago, the place I got hung up was on the setup and importing of the DB config for postgres. The configs for postgres are in different locations on Debian based machines, and you'll probably have to pick apart that part of the setup script to get those pieces installed correctly.

What were your results upon accessing the main xi page?
andrew.nicolson
Posts: 6
Joined: Tue Dec 21, 2010 3:17 am

Re: php errors with Nagios xi on Debian

Post by andrew.nicolson »

Hi There...

Thanks for the pointers. I'm not much of a PostgreSQL expert to say the least (guess I'm about to get better at it then)...

Opening up the main Nagios xi front page produces only 2 php errors, everything else appears and works fine (as far as I can tell):

Warning: fileowner() [function.fileowner]: stat failed for reset_config_perms in /usr/local/nagiosxi/nagiosql.inc.php on line 91
Warning: fileowner() [function.filewoner]: stat failed for reset_config_perms.sh in /usr/local/nagiosxi/html/includes/components/nagiosql/nagiosql.inc.php on line 91

Both of the php files are encrypted. The reset_config_perms and reset_config_perms.sh files have the following attributes:
-rwsr-xr-x 1 root nagios 6763 2011-01-02 01:12 /usr/local/nagiosxi/scripts/reset_config_perms
-rwxr-xr-x 1 nagios nagios 280 2011-01-02 01:12 /usr/local/nagiosxi/scripts/reset_config_perms.c
-rwsr-xr-x 1 root nagios 487 2011-01-02 01:12 /usr/local/nagiosxi/scripts/reset_config_perms.sh

Thanks again.

Andrew
mguthrie
Posts: 4380
Joined: Mon Jun 14, 2010 10:21 am

Re: php errors with Nagios xi on Debian

Post by mguthrie »

Oh, hehe, those php errors are actually bugs in that php function, and that error message should disappear in our next update. If those are your only errors, then so far so good. So is the interface up and running then?
andrew.nicolson
Posts: 6
Joined: Tue Dec 21, 2010 3:17 am

Re: php errors with Nagios xi on Debian

Post by andrew.nicolson »

Hi There...

Yes, the interface appears to be fine. The only real issues I currently have is when I want to add some services to monitor via the wizard, I get php errors relating to the services array. eg

Step 5 of the Generic Network Device Monitoring Wizard in the Other Individual Contacts box - Warning: Invalid argument supplied for foreach() in /usr/local/nagiosxi/html/config/monitoringwizard.php on line 859

Standard php errors suggest that these errors mean that the input is not of the type array.

Andrew
mguthrie
Posts: 4380
Joined: Mon Jun 14, 2010 10:21 am

Re: php errors with Nagios xi on Debian

Post by mguthrie »

That function calls an XML object. I'd check to make sure you've got all of the XML packages for PHP installed.
andrew.nicolson
Posts: 6
Joined: Tue Dec 21, 2010 3:17 am

Re: php errors with Nagios xi on Debian

Post by andrew.nicolson »

Hi There...

I'm pretty sure I have all of the required XML packages installed. I thought I'd have a look through the apache logs in the meantime. Found the monitoringwizard.php file is trying to call a jquery file that doesn't exist:

[Thu Jan 27 20:59:58 2011] [error] [client 192.168.16.35] File does not exist: /usr/local/nagiosxi/html/includes/js/jquery/timepickr, referer: http://nagios-dv-01.melbourne.fdc.net.n ... wizard.php

nagios-dv-01:/home/andrew# ls -l /usr/local/nagiosxi/html/includes/js/jquery/timepickr
ls: cannot access /usr/local/nagiosxi/html/includes/js/jquery/timepickr: No such file or directory
nagios-dv-01:/home/andrew# ls -l /usr/local/nagiosxi/html/includes/js/jquery
total 672
drwxr-sr-x 5 nagios nagios 4096 2011-01-01 22:47 colorpicker
drwxr-sr-x 3 nagios nagios 4096 2011-01-01 22:47 css
-rwxr-xr-x 1 nagios nagios 120619 2011-01-02 01:12 jquery-1.3.2.js
-rwxr-xr-x 1 nagios nagios 13341 2011-01-02 01:12 jquery.autocomplete.js
-rwxr-xr-x 1 nagios nagios 1701 2011-01-02 01:12 jquery.bgiframe.pack.js
-rwxr-xr-x 1 nagios nagios 4110 2011-01-02 01:12 jquery.checkboxes.js
-rwxr-xr-x 1 nagios nagios 20216 2011-01-02 01:12 jquery.colorBlend.js
-rwxr-xr-x 1 nagios nagios 120619 2011-01-02 01:12 jquery-current.js
-rwxr-xr-x 1 nagios nagios 73690 2011-01-02 01:12 jquery-current.min.js
-rwxr-xr-x 1 nagios nagios 2239 2011-01-02 01:12 jquery.dimensions.pack.js
-rwxr-xr-x 1 nagios nagios 3703 2011-01-02 01:12 jquery.easydrag.js
-rwxr-xr-x 1 nagios nagios 5191 2011-01-02 01:12 jquery.maphilight.min.js
-rwxr-xr-x 1 nagios nagios 1292 2011-01-02 01:12 jquery.metadata.min.js
-rwxr-xr-x 1 nagios nagios 34908 2011-01-02 01:12 jquery.sparkline.js
-rwxr-xr-x 1 nagios nagios 23366 2011-01-02 01:12 jquery.tablesorter.js
-rwxr-xr-x 1 nagios nagios 3894 2011-01-02 01:12 jquery.tablesorter.pager.js
-rwxr-xr-x 1 nagios nagios 1405 2011-01-02 01:12 jquery.timer.js
-rwxr-xr-x 1 nagios nagios 3367 2011-01-02 01:12 jquery.timers-1.1.3.js
-rwxr-xr-x 1 nagios nagios 3481 2011-01-02 01:12 jquery.tooltip.pack.js
-rwxr-xr-x 1 nagios nagios 192628 2011-01-02 01:12 jquery-ui-1.7.2.custom.min.js

Any thoughts on this one?