Closed thomasbuesser closed 9 years ago
Have you tried running it in debug mode (with a -d)?
What version of PHP are you using?
What OS/version are you on?
When you run it in debug, does it happen immediately or on a particular host (assuming you have multiple hosts in your cacti instance)?
Before line 282, put in:
dpdiscover_debug("Check host description: ".$host['description']."\n");
And do a manual run with -d, which will verify that there's something there that works as an index. If it comes up blank, then there's either some odd bug in the code that I'm not seeing or you have a device with no description or a blank description (which is bad).
Also, if you could look at your raw database, doing something like:
SELECT id, description, hostname FROM host;
and ensure that each field actually does have something in it, that would help.
Any odd characters in your descriptions?
Without more information, I'm inclined to blame my lack of checking for valid data.
Thing is, looking more at it, I would wonder how $dphost would qualify as a valid index if $host['description'] does not. Very odd.
In any event, the main thing I'd like to see first off is if we can identify the description it's bugging out on, or if it bugs immediately, look at what version of PHP you're using vs my systems.
see the Outputs below
Debug-Output
php findhosts.php -d Discovery Polling is set to disabled. Checking to determine if it's time to run. 2015-11-05 10:00:00 1446714000 Checking if user changed the start time The next run time has been determined to be NOW 11/05/2015 10:54:23 AM - POLLER: Poller[0] DP Discover is now running Community Names : public:nagios:cacti:private Seeding array: Warning: Illegal string offset 'SGS001002' in /usr/local/cluster/apache/cacti/plugins/dpdiscover/findhosts.php on line 282 SGS001002 Warning: Illegal string offset 'WIN001003' in /usr/local/cluster/apache/cacti/plugins/dpdiscover/findhosts.php on line 282 WIN001003 Warning: Illegal string offset 'WAT001004' in /usr/local/cluster/apache/cacti/plugins/dpdiscover/findhosts.php on line 282 WAT001004 Warning: Illegal string offset 'BUC001005' in /usr/local/cluster/apache/cacti/plugins/dpdiscover/findhosts.php on line 282 BUC001005 Warning: Illegal string offset 'RHK001006' in /usr/local/cluster/apache/cacti/plugins/dpdiscover/findhosts.php on line 282 ...
PHP PHP 5.4.23 (cli) (built: Jul 7 2014 08:18:30) Copyright (c) 1997-2013 The PHP Group Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
OS FreeBSD asterix.saknet.local 9.1-STABLE FreeBSD 9.1-STABLE #0: Tue Feb 19 12:40:24 CET 2013 root@asterix.saknet.local:/usr/obj/usr/src/sys/SAKNET amd64
Output after adding Debug-Output php findhosts.php -d Discovery Polling is set to disabled. Checking to determine if it's time to run. 2015-11-05 10:00:00 1446714000 Checking if user changed the start time The next run time has been determined to be NOW 11/05/2015 10:57:08 AM - POLLER: Poller[0] DP Discover is now running Community Names : public:nagios:cacti:private Seeding array: Check host description: SGS001002
Warning: Illegal string offset 'SGS001002' in /usr/local/cluster/apache/cacti/plugins/dpdiscover/findhosts.php on line 286 SGS001002 Check host description: WIN001003
Warning: Illegal string offset 'WIN001003' in /usr/local/cluster/apache/cacti/plugins/dpdiscover/findhosts.php on line 286 WIN001003 Check host description: WAT001004 ...
MySQL-Dump mysql> SELECT id, description, hostname FROM host; +-----+----------------------------------+---------------+ | id | description | hostname | +-----+----------------------------------+---------------+ | 82 | SGS001002 | 10.156.129.2 | | 84 | WIN001003 | 10.156.129.3 | | 86 | WAT001004 | 10.156.129.4 | | 88 | BUC001005 | 10.156.129.5 | | 90 | RHK001006 | 10.156.129.6 | | 92 | GAI001007 | 10.156.129.7 | | 94 | HRI002008 | 10.156.129.8 | ...
hope this helps...
This could very well be a PHP version issue. http://stackoverflow.com/questions/23525957/php-invalid-string-index-causes-error-on-some-servers-but-not-on-others
I'll have to study this a bit and see if I can come up with a solution that doesn't require downgrading your PHP version ...
Heh. Looking through the code, here's a few things I've figured out:
I'm going to do some testing without it. If successful, I'll update the git repo release a new version. I suggest you comment out the line for now and let me know if something doesn't work as expected.
It took me a while (and some googling) for me to realize what the error was saying. And it's dead on.
EDIT: The git repo is updated with the line commented out. Either use that, or comment out the line yourself. In any event, the issue will stay open either until you let me know that that seems to fix it, or I get tired of waiting to hear from you (about a week I would guess).
Marking as closed.
New release should be available in the usual locations that resolves this issue to my knowledge.
Hi all together
when I install the DPDiscover plugin and do a manual findhost.php run (php findhost.php) I get an error of an invalid String index on line 282.
The $host['description'] is poppulated with the name of the switch.
Can you have a look at that
thanks Thomas