Cacti / plugin_mactrack

Mactrack Plugin for Cacti
GNU General Public License v2.0
12 stars 25 forks source link

Uncaught TypeError: sizeof(): Argument #1 ($value) must be of type Countable|array #175

Closed chris-y closed 1 year ago

chris-y commented 1 year ago

Describe the bug mactrack plugin fails on scan (and disables itself) with error:

ERROR PHP ERROR in Plugin 'mactrack': Uncaught TypeError: sizeof(): Argument #1 ($value) must be of type Countable|array, 
null given in /usr/share/cacti/site/plugins/mactrack/mactrack_view_macs.php:1117 
Stack trace: 
  #0 /usr/share/cacti/site/plugins/mactrack/mactrack_view_macs.php(625): mactrack_mac_filter() 
  #1 /usr/share/cacti/site/plugins/mactrack/mactrack_view_macs.php(63): mactrack_view_macs()
  #2 {main} thrown in file: /usr/share/cacti/site/plugins/mactrack/mactrack_view_macs.php on line: 1117

To Reproduce Click mactrack and one of the rescan buttons

Expected behavior The plug should scan and not disable itself

Plugin (please complete the following information):

Desktop (please complete the following information):

Additional context This is on an install which has been upgraded to Cacti 1.2.22 (from 1.1.38) and latest dev mactrack. Ubuntu was upgraded from 18.04 to 22.04 at the same time. Due to similar issues with the thold plugin I updated Cacti manually rather than from the repo.

chris-y commented 1 year ago

A couple more errors in the log which I saw by re-enabling and clicking on view poller status:

ERROR PHP ERROR in Plugin 'mactrack': Uncaught TypeError: Cannot increment array 
in /usr/share/cacti/site/plugins/mactrack/lib/mactrack_cisco.php:388 
Stack trace: 
  #0 /usr/share/cacti/site/plugins/mactrack/mactrack_scanner.php(158): get_IOS_dot1dTpFdbEntry_ports() 
  #1 {main} thrown in file: /usr/share/cacti/site/plugins/mactrack/lib/mactrack_cisco.php on line: 388

CMDPHP PHP ERROR WARNING Backtrace: (
  /plugins/mactrack/mactrack_utilities.php[88]:mactrack_display_run_status(), 
  /plugins/mactrack/mactrack_utilities.php[192]:CactiErrorHandler()
)
ERROR PHP WARNING in Plugin 'mactrack': foreach() argument must be of type array|object, 
null given in file: 
  /usr/share/cacti/site/plugins/mactrack/mactrack_utilities.php on line: 192
TheWitness commented 1 year ago

Assuming you moved to PHP8. Keep logging. I'll get to this in a few days. Lots of things going on at the moment.

chris-y commented 1 year ago

Yes, PHP 8.1.

netniV commented 1 year ago

This should now be resolved.

chris-y commented 1 year ago

Confirmed working - thanks!