Closed Chardonneaur closed 1 year ago
The format is here https://github.com/jbrule/matomoplugin-CampusGeoIP/blob/4.x-dev/docs/index.md This was the format our IPAM exported as and it needs to be loaded over http as implemented. With a little work it could support loading a local file.
@jbrule thank you but what is the file format of your file? .txt, .csv?
just plain text bar/pipe character "|" delimited
strange so my error is then somewhere else because I am getting a file format error.
Are you using a valid URL? The checks/messages can be seen here https://github.com/jbrule/matomoplugin-CampusGeoIP/blob/26602a1a3773be8796363afaccd6712cbc535dce/CampusGeoIP.php#L102
Yes, I am using it locally and can download the file from the url http://localhost/myfile I am getting a "File format is invalid" as an error message.
That message is return when the header row of the file doesn't exactly match what is expected. Look at COLUMN_TEMPLATE in CampusGeoIP.php file.
Were you able to get this working?
Josh
Nope, but I am going to try harder in the coming weeks. Thanks for the follow up.
@jbrule ok, just to give you an idea of my project. I am currently writing a book about Matomo which include an introduction to all plugins from the marketplace. I only have 4 left that I didn't write about and Campus Geo IP is one of them. My question is then the following one, could I somehow, thanks to your plugin, use a local file in order to say hey, this is my home IP address, and the exact location is this one latitude = something, longitude = something else. Because if i can do so, I guess I can explain the all concept of the plugin.
The intent of the plugin is to support Geo-location for RFC1819 networks but there is no reason it can't work with public ones. For a home network you could define "locations" for the house, shed, treehouse, lake home (p2p VPN) with geo-coordinates like so https://github.com/jbrule/matomoplugin-CampusGeoIP/blob/4.x-dev/docs/index.md and have a network cidr, in this case probably something like 192.168.10.0/24 for house, 192.168.11.0/24 for lakehouse as networks.
campusgeoip_locations table (This would be entered into MySQL table) | id | name | city | campus | region | country | org | provider | latitude | longitude | ts_created | ts_last_edit |
---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | Main House | Baltimore | MH | MD | US | HomeNOC | NAT | 39.2546526 | -76.7109614 | null | null | |
2 | Tree House | Baltimore | TH | MD | US | HomeNOC | NAT | 39.2546530 | -76.7109620 | null | null | |
3 | Lake House | Baltimore | LH | MD | US | HomeNOC | NAT | 39.4270459 | -76.8832297 | null | null |
Networks Data File (This would be populated by ./console campusgeoip:update-networks http://localhost/home.txt) home.txt
NetworkFirstAsInteger|NetworkLastAsInteger|NetworkAsInteger|NetworkWithCIDR|NetworkAddress|NetworkCIDR|NetworkMask|NetworkHostCount|NetworkComment|Region|CampusCode|BuildingCode|FloorCode|Use|Disabled
|||192.168.10.0/24|||||Main House|MD|MH|H|Main||false
|||192.168.12.0/24|||||Tree House|MD|TH|H|Main||false
|||192.168.11.0/24|||||Lake House|MD|LH|H|Main||false
Thank you so much, I am giving it a try over the next days.
@jbrule : ok I made some progress here, but when I execute the command line, here is the error I am getting: ERROR [2022-11-20 15:04:09] 44912 Uncaught exception: Error: Undefined constant "Piwik\Plugins\CampusGeoIP\FILTER_FLAG_SCHEME_REQUIRED" in /var/www/html/matomoeni/matomo/plugins/CampusGeoIP/CampusGeoIP.php:131 Stack trace:
Uncaught exception in /var/www/html/matomoeni/matomo/plugins/CampusGeoIP/CampusGeoIP.php line 131: Undefined constant "Piwik\Plugins\CampusGeoIP\FILTER_FLAG_SCHEME_REQUIRED"
Given the error I assume you are not providing a url with scheme (http/https). It doesn't support a file syst path currently but I have some time Wednesday and will work on file path support. It should be simple to add.
I just pushed v4.1.0 with local network data file support
Thank you @jbrule definitely there is some progress here, though I am still getting some errors:
ERROR [2022-11-24 17:44:23] 133449 Uncaught exception: /var/www/html/matomocamp/matomo/core/Db.php(846): Found bound parameter (index = 0) is Date instance which will not work correctly in following SQL: UPDATE matomo_campusgeoip_networks SET ts_removed = ? WHERE ts_last_edit < ? AND ts_removed IS NULL [Query: , CLI mode: 1]
[Exception]
Found bound parameter (index = 0) is Date instance which will not work correctly in following SQL: UPDATE matomo_campusgeoip_networks SET ts_removed = ? WHERE ts_last_edit < ? AND
ts_removed IS NULL
yes, it throws the exact same error
Please try version 4.1.3 it will print out additional debug information when an error occurs. I am unable to duplicate this error with the networks-example.txt file
@Chardonneaur Were you able to get any error output?
Hi Josh, yes, here is the error: Found bound parameter (index = 0) is Date instance which will not work correctly in following SQL: UPDATE matomo_campusgeoip_networks SET ts_removed = ? WHERE ts_last_edit < ? AND ts_removed IS NULL [Query: , CLI mode: 1]
[Exception]
Found bound parameter (index = 0) is Date instance which will not work corr
ectly in following SQL: UPDATE matomo_campusgeoip_networks SET ts_removed =
? WHERE ts_last_edit < ? AND ts_removed IS NULL
@Chardonneaur That is with v4.1.3?
yes
@Chardonneaur Please give 4.1.4 a try.
Victory, it works @jbrule
Hello, I tried to install the plugin and in fact, I got blocked when performing (according to the documentation): ./console CampusGeoIP:update-networks http://
in fact it is:
./console campusgeoip:update-networks http://
then there is another error message which will be, no file format specified, and I have no idea in which file format http:// should be.
Any ideas?