Cacti / plugin_mactrack

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

Mactrack no longer maps IP's to mac's #204

Closed jdcoats closed 2 months ago

jdcoats commented 8 months ago

My Mactrack has been broken since i updated develop on 8/25. I did a manual run from cli on individual switch 9/29 and got IP mapped but otherwise it does not work through normal runs. image

image

jdcoats commented 7 months ago

still leaving abended processes

# ps aux| grep mact
root      1457  0.0  0.0 134824 64608 ?        S    02:03   0:08 /usr/bin/php -q /var/www/localhost/htdocs/cacti/plugins/mactrack/mactrack_resolver.php
root      2055  0.0  0.0 134824 64892 ?        S    Dec02   0:49 /usr/bin/php -q /var/www/localhost/htdocs/cacti/plugins/mactrack/mactrack_resolver.php
root      3427  0.0  0.0 134824 64824 ?        S    Dec04   0:21 /usr/bin/php -q /var/www/localhost/htdocs/cacti/plugins/mactrack/mactrack_resolver.php
root      3453  0.0  0.0 134824 64804 ?        S    Dec05   0:13 /usr/bin/php -q /var/www/localhost/htdocs/cacti/plugins/mactrack/mactrack_resolver.php
root      4952  0.0  0.0 134824 64896 ?        S    Dec02   0:52 /usr/bin/php -q /var/www/localhost/htdocs/cacti/plugins/mactrack/mactrack_resolver.php
root      5824  0.0  0.0 134824 64960 ?        S    Dec03   0:33 /usr/bin/php -q /var/www/localhost/htdocs/cacti/plugins/mactrack/mactrack_resolver.php
root      6396  0.0  0.0 134824 64884 ?        S    Dec05   0:17 /usr/bin/php -q /var/www/localhost/htdocs/cacti/plugins/mactrack/mactrack_resolver.php
root      7437 25.6  0.0 122792 52592 ?        S    14:06  61:52 /usr/bin/php -q /var/www/localhost/htdocs/cacti/plugins/mactrack/poller_mactrack.php
root      8226  0.0  0.0 134824 62880 ?        S    14:06   0:02 /usr/bin/php -q /var/www/localhost/htdocs/cacti/plugins/mactrack/mactrack_resolver.php
root      8873  0.0  0.0 134824 64988 ?        S    Dec03   0:37 /usr/bin/php -q /var/www/localhost/htdocs/cacti/plugins/mactrack/mactrack_resolver.php
root     10676  0.0  0.0 134824 65040 ?        S    Dec02   0:54 /usr/bin/php -q /var/www/localhost/htdocs/cacti/plugins/mactrack/mactrack_resolver.php
root     12783  0.0  0.0 134824 64940 ?        S    Dec02   0:46 /usr/bin/php -q /var/www/localhost/htdocs/cacti/plugins/mactrack/mactrack_resolver.php
root     13181  0.0  0.0 134824 64960 ?        S    Dec04   0:28 /usr/bin/php -q /var/www/localhost/htdocs/cacti/plugins/mactrack/mactrack_resolver.php
root     13235  0.0  0.0 134824 64784 ?        S    Dec01   0:58 /usr/bin/php -q /var/www/localhost/htdocs/cacti/plugins/mactrack/mactrack_resolver.php
root     13504  0.0  0.0 134824 64748 ?        S    Dec04   0:26 /usr/bin/php -q /var/www/localhost/htdocs/cacti/plugins/mactrack/mactrack_resolver.php
root     15065  0.0  0.0 134824 64760 ?        S    Dec05   0:12 /usr/bin/php -q /var/www/localhost/htdocs/cacti/plugins/mactrack/mactrack_resolver.php
root     15874  0.0  0.0 134824 64828 ?        S    Dec03   0:43 /usr/bin/php -q /var/www/localhost/htdocs/cacti/plugins/mactrack/mactrack_resolver.php
root     16694  0.0  0.0 134824 64716 ?        S    Dec05   0:09 /usr/bin/php -q /var/www/localhost/htdocs/cacti/plugins/mactrack/mactrack_resolver.php
root     18680  0.0  0.0 134824 64596 ?        S    Dec05   0:15 /usr/bin/php -q /var/www/localhost/htdocs/cacti/plugins/mactrack/mactrack_resolver.php
root     19345  0.1  0.0 116392 45732 ?        S    18:06   0:00 /usr/bin/php -q /var/www/localhost/htdocs/cacti/plugins/mactrack/poller_mactrack.php
root     19707  0.0  0.0 134824 64880 ?        S    Dec02   0:50 /usr/bin/php -q /var/www/localhost/htdocs/cacti/plugins/mactrack/mactrack_resolver.php
root     21284  0.0  0.0   6716  2228 pts/6    S+   18:07   0:00 grep --colour=auto mact
root     22867  0.0  0.0 134824 64620 ?        S    06:04   0:06 /usr/bin/php -q /var/www/localhost/htdocs/cacti/plugins/mactrack/mactrack_resolver.php
root     24171  0.0  0.0 134824 63952 ?        S    10:05   0:04 /usr/bin/php -q /var/www/localhost/htdocs/cacti/plugins/mactrack/mactrack_resolver.php
root     24207  0.0  0.0 134824 64912 ?        S    Dec03   0:35 /usr/bin/php -q /var/www/localhost/htdocs/cacti/plugins/mactrack/mactrack_resolver.php
root     24483  0.0  0.0 134824 64844 ?        S    Dec04   0:24 /usr/bin/php -q /var/www/localhost/htdocs/cacti/plugins/mactrack/mactrack_resolver.php
root     24498  0.0  0.0 134824 64968 ?        S    Dec04   0:31 /usr/bin/php -q /var/www/localhost/htdocs/cacti/plugins/mactrack/mactrack_resolver.php
root     25009  0.0  0.0 134824 64936 ?        S    Dec04   0:18 /usr/bin/php -q /var/www/localhost/htdocs/cacti/plugins/mactrack/mactrack_resolver.php
root     25911  0.0  0.0 134824 64876 ?        S    Dec03   0:39 /usr/bin/php -q /var/www/localhost/htdocs/cacti/plugins/mactrack/mactrack_resolver.php
root     28284  0.0  0.0 134824 65012 ?        S    Dec02   0:57 /usr/bin/php -q /var/www/localhost/htdocs/cacti/plugins/mactrack/mactrack_resolver.php
root     30125  0.0  0.0 134824 64972 ?        S    Dec01   1:00 /usr/bin/php -q /var/www/localhost/htdocs/cacti/plugins/mactrack/mactrack_resolver.php
root     30943  0.0  0.0 134824 64996 ?        S    Dec03   0:44 /usr/bin/php -q /var/www/localhost/htdocs/cacti/plugins/mactrack/mactrack_resolver.php
root     31804  0.0  0.0 134824 64672 ?        S    Dec05   0:11 /usr/bin/php -q /var/www/localhost/htdocs/cacti/plugins/mactrack/mactrack_resolver.php

and bailing out

2023/12/06 18:05:23 - CMDPHP ERROR: Device Tracking timed out during main script processing.
jdcoats commented 6 months ago

ive been adjusting timings trying to figure out what may or may not work and have noticed that when set to run every for hours the poller runs for 4 hours and then is killed when the next run starts. Likewise if i set it to 8hours the poller runs for 8hrs and is then killed when the next run starts. I get mapping of IP's to macs for roughly half of the switches but not all so its getting hung up somewhere and I have no idea how to find where.

xmacan commented 6 months ago

Please show result of SQL command: SELECT * FROM mac_track_processes

jdcoats commented 6 months ago
MariaDB [cacti]> SELECT * FROM mac_track_processes;
+-----------+------------+---------+---------------------+
| device_id | process_id | status  | start_date          |
+-----------+------------+---------+---------------------+
|         0 |      26586 | Running | 2023-12-18 10:42:20 |
+-----------+------------+---------+---------------------+
1 row in set (0.000 sec)
xmacan commented 6 months ago

SELECT count() FROM mac_track_temp_ports WHERE ip_address != '' AND (dns_hostname = '' OR dns_hostname IS NULL); SELECT count() FROM mac_track_temp_ports WHERE ip_address != '';

xmacan commented 6 months ago

try to run resolve manually and show at least few lines of output: php mactrack_resolver.php -d

jdcoats commented 6 months ago
MariaDB [cacti]> SELECT count('') FROM mac_track_temp_ports WHERE ip_address != '' AND (dns_hostname = '' OR dns_hostname IS NULL);
+-----------+
| count('') |
+-----------+
|         0 |
+-----------+
1 row in set (0.005 sec)
 # php mactrack_resolver.php -d
2023/12/18 11:20:22 - MACTRACK DEBUG: No IP's require resolving this pass
2023/12/18 11:20:25 - MACTRACK DEBUG: No IP's require resolving this pass
2023/12/18 11:20:28 - MACTRACK DEBUG: No IP's require resolving this pass
2023/12/18 11:20:31 - MACTRACK DEBUG: No IP's require resolving this pass
2023/12/18 11:20:34 - MACTRACK DEBUG: No IP's require resolving this pass
2023/12/18 11:20:38 - MACTRACK DEBUG: No IP's require resolving this pass
2023/12/18 11:20:41 - MACTRACK DEBUG: No IP's require resolving this pass
# ps aux | grep php
root      1167  0.0  0.0 134824 64908 ?        S    Dec13   0:40 /usr/bin/php -q /var/www/localhost/htdocs/cacti/plugins/mactrack/mactrack_resolver.php
root      5462  0.0  0.0 134824 64872 ?        S    Dec17   0:11 /usr/bin/php -q /var/www/localhost/htdocs/cacti/plugins/mactrack/mactrack_resolver.php
root     10091  0.0  0.0 134824 64780 ?        S    Dec16   0:19 /usr/bin/php -q /var/www/localhost/htdocs/cacti/plugins/mactrack/mactrack_resolver.php
root     10570  0.0  0.0 134824 64860 ?        S    Dec15   0:22 /usr/bin/php -q /var/www/localhost/htdocs/cacti/plugins/mactrack/mactrack_resolver.php
root     11113  0.0  0.0 132776 62368 ?        S    02:41   0:03 /usr/bin/php -q /var/www/localhost/htdocs/cacti/plugins/mactrack/mactrack_resolver.php
root     13748  0.0  0.0 134824 65056 ?        S    Dec13   0:42 /usr/bin/php -q /var/www/localhost/htdocs/cacti/plugins/mactrack/mactrack_resolver.php
root     17593  0.0  0.0 134824 64848 ?        S    Dec16   0:14 /usr/bin/php -q /var/www/localhost/htdocs/cacti/plugins/mactrack/mactrack_resolver.php
root     17700  0.0  0.0 134824 64928 ?        S    Dec15   0:25 /usr/bin/php -q /var/www/localhost/htdocs/cacti/plugins/mactrack/mactrack_resolver.php
root     21724  0.0  0.0 132776 62344 ?        S    Dec17   0:05 /usr/bin/php -q /var/www/localhost/htdocs/cacti/plugins/mactrack/mactrack_resolver.php
root     23491  0.0  0.0 134824 64892 ?        S    Dec15   0:28 /usr/bin/php -q /var/www/localhost/htdocs/cacti/plugins/mactrack/mactrack_resolver.php
root     25283  0.0  0.0 134824 64856 ?        S    Dec16   0:17 /usr/bin/php -q /var/www/localhost/htdocs/cacti/plugins/mactrack/mactrack_resolver.php
root     25409  7.6  0.0 122792 52296 ?        R    10:42   1:15 /usr/bin/php -q /var/www/localhost/htdocs/cacti/plugins/mactrack/poller_mactrack.php
root     26586  0.0  0.0 134824 62924 ?        S    10:42   0:00 /usr/bin/php -q /var/www/localhost/htdocs/cacti/plugins/mactrack/mactrack_resolver.php
root     26971  0.0  0.0 134824 65080 ?        S    Dec14   0:32 /usr/bin/php -q /var/www/localhost/htdocs/cacti/plugins/mactrack/mactrack_resolver.php
root     29830  0.0  0.0 134824 64968 ?        S    Dec14   0:36 /usr/bin/php -q /var/www/localhost/htdocs/cacti/plugins/mactrack/mactrack_resolver.php
root     30782  0.0  0.0 134824 64328 ?        S    Dec17   0:08 /usr/bin/php -q /var/www/localhost/htdocs/cacti/plugins/mactrack/mactrack_resolver.php
root     32091  0.0  0.0 134824 64600 ?        S    Dec14   0:33 /usr/bin/php -q /var/www/localhost/htdocs/cacti/plugins/mactrack/mactrack_resolver.php
xmacan commented 6 months ago

for now workaround - in file mactrack_resolver.php around line 154 is mactrack_debug('No IP\'s require resolving this pass'); sleep(3);

change second line to $break = true;

Let me know if it helps.

For my perspective - mactrack has a lot of unfinished work. I am not quickly able to tell if this is a bug or a feature. I will return here maybe in january.

jdcoats commented 6 months ago

okay i think I have figured out what part broken. It's only mapping IP's for devices in site id 2 but none of the other sites that have their own routers and mac tables work anymore. But yes the process control for the resolver is worked around :)

TheWitness commented 6 months ago

If I remember correctly, we were going to work on that as a new feature.

TheWitness commented 6 months ago

https://github.com/Cacti/plugin_mactrack/issues/151

jdcoats commented 6 months ago

The feature request was based on being able to say I'm in site A but my router is in site B and to be able to set that. In this case its always worked that Site A's router is in Site A and Site B's router is in site B. This normal functionality is only working for 1 site (first site ID) and none of the others.

jdcoats commented 4 months ago

205 is fixed Thanks! We still have the situation where mactrack's IP to port mapping logic is no longer aware of which site it is in.

xmacan commented 3 months ago

@jdcoats could you explain to me, where is problem with ip to port mapping logic?

jdcoats commented 3 months ago

I have many remote sites where the router and switch are both in the remote site. This means the Sites mac's and IP are seen in that site. Well the port mac addresses are shown in mactrack but no IP's or DNS names for those remote sites work. remote site example with no IP's: image main site works/has IP's: image

jdcoats commented 3 months ago

my example remote site, mactrack see's the IP's but does not corelate the data. image

xmacan commented 3 months ago

So this is still true? My Mactrack has been broken since i updated develop on 8/25. I did a manual run from cli on individual switch 9/29 and got IP mapped but otherwise it does not work through normal runs.

Maybe it isn't problem with data gathering but with cleaning/retention

jdcoats commented 2 months ago

Yes, see all of the IP's in all of the different sites? image but here there are no IP's image which results in no IP's for the sites image

xmacan commented 2 months ago

I will revise last code changes from that time

Did you change PHP version from 7 to 8 or upgrade SQL server at that time?

jdcoats commented 2 months ago

Yes I did, updated system, Cacti and plugins

 * dev-db/mariadb-10.6.14
        Emerged at: Fri Aug 25 14:40:22 2023
        Build time: 9 minutes, and 11 seconds
 * dev-lang/php-8.1.20-r1
        Emerged at: Fri Aug 25 14:59:24 2023
        Build time: 14 minutes
jdcoats commented 2 months ago

Sad that I don't know the date of the develop i had prior it could have been March or April so no way to be sure which changes broke it.

xmacan commented 2 months ago

did you update php from php7 to php8?

jdcoats commented 2 months ago

I have both installed and i think that I was already switched to 8 by then, cant be sure it was a year ago :)

xmacan commented 2 months ago

It seems that I broke it one year ago. @jdcoats please try comment or delete in file mactrack_scanner.php these lines: if ($device['site_id'] != 0) { $scan_date = date('Y-m-d H:i:s'); } else { $scan_date = read_config_option('mt_scan_date'); }

And wait for matrack poller. It was added here: https://github.com/Cacti/plugin_mactrack/commit/212e823815dbc13dd8a80b85faf9263d98a09998 It seems that I fixed here manual run but broke automatic.

jdcoats commented 2 months ago

next run is in about 20min I'll let you know :) Thanks!

jdcoats commented 2 months ago

I have IP's in the other sites now. Thank You! I've missed this feature for the last year. 👍

xmacan commented 2 months ago

thank you for testing. Closing