Cacti / plugin_mactrack

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

Is MacTrack php 7.2 ready #72

Closed linecolumn closed 5 years ago

linecolumn commented 6 years ago

Hi guys,

Trying to make Juniper qfx5100 watched by latest (from git) MacTrack, and there is no go:

$ php mactrack_scanner.php -id=1 -d PHP Notice: Undefined variable: active_vlans in /usr/share/cacti/plugins/mactrack/lib/mactrack_juniper.php on line 82 PHP Warning: sizeof(): Parameter must be an array or an object that implements Countable in /usr/share/cacti/plugins/mactrack/lib/mactrack_juniper.php on line 82 INFO: HOST: fqdn.host, TYPE: Juniper Networks, Inc. qfx5100-96s-8q Et, No active devcies on this network device.

Also, whenever I edit same Device Type it gets duplicated, so after few edits, I have something like this:  Main switch Juniper Switch/Hub get_JEX_switch_ports get_cisco_dhcpsnooping_table get_cisco_dot1x_table %5100% .6.82.4.1.1.1.2636  Main switch Juniper Switch/Hub get_JEX_switch_ports get_cisco_dhcpsnooping_table get_cisco_dot1x_table 5100 %.6.82.4.1.1.1.2636  Main switch Juniper Switch/Hub get_JEX_switch_ports get_cisco_dhcpsnooping_table get_cisco_dot1x_table 5100 .1.3.6.1.4.1.2636  Main switch Juniper Switch/Hub get_JEX_switch_ports get_cisco_dhcpsnooping_table get_cisco_dot1x_table 5100 .6.82.4.1.1.1.2636  Main switch Juniper Switch/Hub get_JEX_switch_ports get_cisco_dhcpsnooping_table get_cisco_dot1x_table Juniper% .6.82.4.1.1.1.2636 

and yet if I want to erase just one of them, they got erased all.

Using latest, as of this moment cacti and php 7.2.3

netniV commented 6 years ago

This will be a bit tricky for me to test as I no longer have any juniper devices. However, I'll see what I can see in the code for the variable issues.

linecolumn commented 6 years ago

Please do use me for your gain :).

linecolumn commented 6 years ago

Here are errors from the cacti log:

04.03.2018 02:45:19 - CMDPHP PHP ERROR WARNING Backtrace: (/plugins/mactrack/mactrack_scanner.php: 168 get_JEX_switch_ports)(/plugins/mactrack/lib/mactrack_juniper.php: 82 sizeof)(CactiErrorHandler)(/lib/functions.php: 4586 cacti_debug_backtrace) 04.03.2018 02:45:19 - ERROR PHP WARNING in Plugin 'mactrack': sizeof(): Parameter must be an array or an object that implements Countable in file: /usr/share/cacti/plugins/mactrack/lib/mactrack_juniper.php on line: 82 04.03.2018 02:45:19 - CMDPHP PHP ERROR NOTICE Backtrace: (/plugins/mactrack/mactrack_scanner.php: 168 get_JEX_switch_ports)(/plugins/mactrack/lib/mactrack_juniper.php: 82 CactiErrorHandler)(/lib/functions.php: 4591 cacti_debug_backtrace) 04.03.2018 02:45:19 - ERROR PHP NOTICE in Plugin 'mactrack': Undefined variable: active_vlans in file: /usr/share/cacti/plugins/mactrack/lib/mactrack_juniper.php on line: 82

netniV commented 6 years ago

OK, so this error basically means that mactrack_juniper did not find any active vlans. Can you do an snmpwalk against 1.3.6.1.4.1.2636.3.40.1.5.1.5.1.5 (indexes) and 1.3.6.1.4.1.2636.3.40.1.5.1.5.1.2 (names) ?

linecolumn commented 6 years ago

I did full snmpwalk -v1 -c public IP to file, and did grep 1.3.6.1.4.1.2636, nothing inside.

The very same Juniper is properly graphed inside of Cacti.

jpobeda commented 6 years ago

Have you checked that your juniper actually supports that specific MIB? Are you actually getting OID not found?

Also, why are you setting dhcp snooping as your IP Scanning function, it's only supported on Cisco devices at the moment. Same for Dot1x function.

As per first comment logs.

netniV commented 6 years ago

@linecolumn As @jpobeda has mentioned, it would appear that your Juniper is not actually outputting the expect values. This may be because you have the incorrect SNMP settings (make sure your version, community and if applicable security credentials are correct), something is blocking access to the SNMP point (unlikely if you got other details), or that the OID's needed for your juniper model are different.

linecolumn commented 6 years ago

Thank you guys for address this issue. Let me respond with following, these is the current setup (non working one):

  1. Device
SNMP Information
System: Juniper Networks, Inc. qfx5100-96s-8q Ethernet Switch, kernel JUNOS 14.1X53-D46.7, Build date: 2017-11-23 22:21:57 UTC Copyright (c) 1996-2017 Juniper Networks, Inc.
Hostname: qfx5100
ObjectID: .1.3.6.1.4.1.2636.1.1.1.4.82.6
  1. Device type
Description: Juniper qfx5100-96s-8q
Vendor: Juniper
Device type: Switch/Hub
System Description Match: 5100
Vendor SNMP Object ID Match: .1.3.6.1.4.1.2636
MAC Address Scanning Function: get_JEX_switch_ports
IP Address Scanning Function: get_extreme_arp_table
802.1x Scanning Function: None
  1. Device type was recognized and properly inserted into Devices

The business is as usual, but, when starting poller, there are following errors when testing from command line:

$ php mactrack_scanner.php -d -id=1
PHP Notice:  Undefined variable: active_vlans in /usr/share/cacti/plugins/mactrack/lib/mactrack_juniper.php on line 82
PHP Warning:  sizeof(): Parameter must be an array or an object that implements Countable in /usr/share/cacti/plugins/mactrack/lib/mactrack_juniper.php on line 82
INFO: HOST: censored.hostname, TYPE: Juniper Networks, Inc. qfx5100-96s-8q Et, No active devcies on this network device.

Here is the cacti log errors from the same command execution:

05.03.2018 11:37:04 - CMDPHP PHP ERROR WARNING Backtrace: (/plugins/mactrack/mactrack_scanner.php: 168 get_JEX_switch_ports)(/plugins/mactrack/lib/mactrack_juniper.php: 82 sizeof)(CactiErrorHandler)(/lib/functions.php: 4586 cacti_debug_backtrace)
05.03.2018 11:37:04 - ERROR PHP WARNING in Plugin 'mactrack': sizeof(): Parameter must be an array or an object that implements Countable in file: /usr/share/cacti/plugins/mactrack/lib/mactrack_juniper.php on line: 82
05.03.2018 11:37:04 - CMDPHP PHP ERROR NOTICE Backtrace: (/plugins/mactrack/mactrack_scanner.php: 168 get_JEX_switch_ports)(/plugins/mactrack/lib/mactrack_juniper.php: 82 CactiErrorHandler)(/lib/functions.php: 4591 cacti_debug_backtrace)
05.03.2018 11:37:04 - ERROR PHP NOTICE in Plugin 'mactrack': Undefined variable: active_vlans in file: /usr/share/cacti/plugins/mactrack/lib/mactrack_juniper.php on line: 82

Thanks!

netniV commented 6 years ago

Your SNMP walk suggests to me that your switch is offering just the standard MIBS. You have no entries in that walk that refer to jnxExVlan which is the partial name I'd expect to find using MIB names. I would change your device type away from the Juniper one because it won't work for the switch you have (unless there's something extra you have to enable for that switch to see that SNMP data).

http://oidref.com/1.3.6.1.4.1.2636.3.40.1.5.1.5.1.5

linecolumn commented 6 years ago

Switching to "get_generic_switch_ports" and got result!

INFO: HOST: hostname, TYPE: Juniper Networks, Inc. qfx5100-96s-8q Et, TOTAL PORTS: 266, OPER PORTS: 105

no MACs found (both for extreme and standard arp table) tho

Thank you

jpobeda commented 6 years ago

I guess we could chuck some info about this on the wiki. Something like scanning function supported MIBs.

So people can figure out which functions will give them results depending on the platform. Just a thought tho

linecolumn commented 6 years ago

There are some extra fields in snmpwalk when Juniper mibs are placed:

https://www.juniper.net/documentation/en_US/release-independent/junos/mibs/mibs.html

netniV commented 6 years ago

@jpobeda I think that would be a good thing. Something you could do?

As for the original php 7.2 question, there are known compatibility issues with lots of software and PHP 7.2 as that now requires any variable passed to sizeof() to implement the Countable interface. A false value returned from something like a failed database query doesn't work. Therefore, a full 7.2 test would be needed.

cigamit commented 5 years ago

Latest update now works on php7.x.