Cacti / plugin_webseer

Cacti Web Services Monitoring Plugin
GNU General Public License v2.0
8 stars 9 forks source link

Empty Needle in File #9

Closed terrytibbles closed 7 years ago

terrytibbles commented 7 years ago

Hello,

I'm getting the following error in the Cacti logs every 5 minutes. This suggests that it is to do with the core functionality of Webseer, as I am also getting behaviour from Webseer where it is not working as expected:

2017-04-28 02:30:07 - CMDPHP PHP ERROR WARNING Backtrace: (/plugins/webseer/webseer_process.php: 130 get)(/plugins/webseer/functions.php: 446 strpos)(CactiErrorHandler)(/lib/functions.php: 4296 cacti_debug_backtrace)
2017-04-28 02:30:07 - ERROR PHP WARNING in Plugin 'webseer': strpos(): Empty needle in file: /var/www/root/cacti/plugins/webseer/functions.php on line: 446
2017-04-28 02:30:07 - CMDPHP PHP ERROR WARNING Backtrace: (/plugins/webseer/webseer_process.php: 130 get)(/plugins/webseer/functions.php: 446 strpos)(CactiErrorHandler)(/lib/functions.php: 4296 cacti_debug_backtrace)
2017-04-28 02:30:07 - ERROR PHP WARNING in Plugin 'webseer': strpos(): Empty needle in file: /var/www/root/cacti/plugins/webseer/functions.php on line: 446
2017-04-28 02:30:06 - CMDPHP PHP ERROR WARNING Backtrace: (/plugins/webseer/webseer_process.php: 130 get)(/plugins/webseer/functions.php: 446 strpos)(CactiErrorHandler)(/lib/functions.php: 4296 cacti_debug_backtrace)
2017-04-28 02:30:06 - ERROR PHP WARNING in Plugin 'webseer': strpos(): Empty needle in file: /var/www/root/cacti/plugins/webseer/functions.php on line: 446
2017-04-28 02:30:06 - SYSTEM WEBSEER STATS: Total Time:0.021, Service Checks:1, Servers:0
2017-04-28 02:30:06 - SYSTEM THOLD STATS: Time:0.0104 Tholds:0 TotalDevices:2 DownDevices:0 NewDownDevices:0
2017-04-28 02:30:06 - SYSTEM STATS: Time:4.2451 Method:cmd.php Processes:1 Threads:N/A Hosts:2 HostsPerProcess:2 DataSources:6 RRDsProcessed:6 

The code in question is here:

/plugins/webseer/webseer_process.php: 130

        while ($x < 3) {
                debug('Service Check Number ' . $x);

                switch ($url['type']) {
                        case 'http':
                                $cc = new cURL();
                                $cc->host = $url;
                                $results = $cc->get($url['url']);
                                $results['data'] = $cc->data;
                                break;
                        case 'dns':
                                $results = plugin_webseer_check_dns($url);
                                break;
                }

                if ($results['result']) {
                        break;
                }

                $x++;

                usleep(10000);
        }

Line 130 is the following:

$results = $cc->get($url['url']);

/plugins/webseer/functions.php: 446

                // If we have set a failed search string, then ignore the normal searches and only alert on it
                if ($this->host['search_failed'] != '' && $errnum > 0) {
                        $this->debug('Processing search_failed');

                        if (strpos($data, $this->host['search_failed']) !== false) {
                                $this->results['error'] = 'Failure Search string found!';
                        } else {
                                $this->results['error'] = '';
                                $this->results['result'] = 1;
                        }
                }elseif ($errnum == 0) {
                        $this->debug('Processing search');

                        $found = (strpos($data, $this->host['search']) !== false);
                        if (!$found && $this->host['search_maint'] != '') {
                                $this->debug('Processing search maint');
                                $found = (strpos($data, $this->host['search_maint']) !== false);
                        }

                        if (!$found) {
                                $this->debug('Processing search not found');

                                $this->results['error'] = 'Search string not found';
                        } else {
                                $this->debug('Processing search found');

                                if ($this->host['requiresauth'] == '') {
                                        $this->debug('Processing requires authentication');

                                        $this->results['result'] = 1;
                                } else {
                                        $this->debug('Processing requires no authentication required');

                                        if ($this->results['options']['http_code'] == 401) {
                                                $this->results['result'] = 1;
                                        } else {
                                                $this->results['error'] = 'The requested URL returned error: ' . $this->results['options']['http_code'];
                                        }
                                }
                        }
                }

Line 446 is the following:

$found = (strpos($data, $this->host['search']) !== false);

This is a new install with the following software versions:

Apache: 2.4.25 PHP: 7.0.18 MariaDB: 10.1.22 Cacti: 1.1.5 Webseer: 1.0

Has anyone go any idea what could be causing this?

Thanks.

cigamit commented 7 years ago

Resolved.