Commit 6e0fb623 authored by Eric - kg6wxc's avatar Eric - kg6wxc
Browse files

BugFixs/Enhancements/Additions

Can change the non mesh markers info without having to recreate now.

The polling script can now find the info for some nodes that it could
not before, such as firmware 3.15.1.0b4, this was a pleasant side effect
of trying to remove some of the bunk entries i nthe database.

The polling script will now also try to check and "fix" the database,
this is due to changes in the newer AREDN firmwares (anything beyond
3.17RC1)
Some of those changes were made by me, just for the map. :)
These DB "fixes" also include removing some columns that were no longer
and were making the DB much larger than it needs to be, this will also
help cut down on the memory footprint when loading the webpage.

The numbers at the bottom of the map reflecting nodes and link, should
be more accurate now (I hope).

The Map legend has been change to use pure HTML5/CSS, the only images
are the small circle icons, this may cause issues with very old
browsers...

Removed some files that were no longer needed or forgetten about.
parent 7723b474
...@@ -4,3 +4,5 @@ ...@@ -4,3 +4,5 @@
**/meshmap-settings.ini **/meshmap-settings.ini
**/meshmap.css **/meshmap.css
**/admin.css **/admin.css
**/leaflet-custom-control-vertical-center.css
**/map-legend.css
...@@ -32,7 +32,8 @@ Donations / Beer accepted! :) (paypal possibly coming soon, email: kg6wxc@gmail. ...@@ -32,7 +32,8 @@ Donations / Beer accepted! :) (paypal possibly coming soon, email: kg6wxc@gmail.
<li><strong>openssl PHP extension</strong><br/> <li><strong>openssl PHP extension</strong><br/>
(you may only need mysqlnd, it should be safe to enable both for now)<br/> (you may only need mysqlnd, it should be safe to enable both for now)<br/>
(One or more of these extensions may need to be enabled in php.ini)<br/> (One or more of these extensions may need to be enabled in php.ini)<br/>
(if you do not already have mysqlnd, you might need to install it, <code>apt-get install php[5 or 7]-mysqlnd</code>)</li> (if you do not already have mysqlnd, you might need to install it, <code>apt-get install php[5 or 7]-mysqlnd</code>)<br/>
(<em>the requirement for the mysqlnd extension will be removed in the near future</em>)</li>
<li><strong>MySQL/MariaDB</strong><br/> <li><strong>MySQL/MariaDB</strong><br/>
(Other database systems are up to you)</li> (Other database systems are up to you)</li>
<li><strong>An AREDN Mesh node available over the local network</strong><br/> <li><strong>An AREDN Mesh node available over the local network</strong><br/>
...@@ -40,7 +41,9 @@ Donations / Beer accepted! :) (paypal possibly coming soon, email: kg6wxc@gmail. ...@@ -40,7 +41,9 @@ Donations / Beer accepted! :) (paypal possibly coming soon, email: kg6wxc@gmail.
<li><strong>Map Tiles</strong><br/> <li><strong>Map Tiles</strong><br/>
(Either in a static directory or available via some tile server&hellip;)</li> (Either in a static directory or available via some tile server&hellip;)</li>
<li><strong>RPi3 or better</strong><br/> <li><strong>RPi3 or better</strong><br/>
(The DB access can be pretty slow on an RPi1, you can move the DB to another system though&hellip;)</li> (The DB access can be pretty slow on an RPi1, you can move the DB to another system though&hellip;)<br/>
(If your local mesh network grows to become very large, with tunnels opened to the entire planet,<br/>
you might find even an RPi3+ to become inadequate, it&rsquo;ll still work, it just might be slow)</li>
<li><strong>Patience</strong><br/> <li><strong>Patience</strong><br/>
(Perhaps a lot!)</li> (Perhaps a lot!)</li>
<li><strong>Familiarity with Linux/Apache/SQL</strong><br/> <li><strong>Familiarity with Linux/Apache/SQL</strong><br/>
...@@ -50,7 +53,7 @@ Donations / Beer accepted! :) (paypal possibly coming soon, email: kg6wxc@gmail. ...@@ -50,7 +53,7 @@ Donations / Beer accepted! :) (paypal possibly coming soon, email: kg6wxc@gmail.
<blockquote style="background: #d3d3d3; margin-right: 30%;">In theory, this <em>should</em> run on a Windows system as well.<br/> <blockquote style="background: #d3d3d3; margin-right: 30%;">In theory, this <em>should</em> run on a Windows system as well.<br/>
It does not require anything specific to Linux (<em>Perhaps with the exception of the cron task</em>).<br/> It does not require anything specific to Linux (<em>Perhaps with the exception of the cron task</em>).<br/>
There is no reason that part could not be adapted to run from a Windows scheduled task though.<br/> There is no reason that cronjob could not be adapted to run from a Windows scheduled task though.<br/>
PHP is PHP after all.</blockquote> PHP is PHP after all.</blockquote>
...@@ -109,6 +112,7 @@ Choose your own password!</p> ...@@ -109,6 +112,7 @@ Choose your own password!</p>
<li><p><strong>4: Copy scripts/user-settings.ini-default to scripts/user-settings.ini and edit the user-settings.ini file</strong></p> <li><p><strong>4: Copy scripts/user-settings.ini-default to scripts/user-settings.ini and edit the user-settings.ini file</strong></p>
<ul> <ul>
<li>You <strong>must</strong> do this or the <strong><em>entire system</em></strong> will refuse to run!</li>
<li>The file scripts/user-settings.ini is the most important to get right.<br/> <li>The file scripts/user-settings.ini is the most important to get right.<br/>
It is <strong>very important</strong> to make sure your SQL username and password are correct in scripts/user-settings.ini!!</li> It is <strong>very important</strong> to make sure your SQL username and password are correct in scripts/user-settings.ini!!</li>
<li>Also important is, if the system that this is running on cannot resolve &ldquo;localnode.local.mesh&rdquo; you can change that in the user-settings.ini file.</li> <li>Also important is, if the system that this is running on cannot resolve &ldquo;localnode.local.mesh&rdquo; you can change that in the user-settings.ini file.</li>
...@@ -210,22 +214,25 @@ You can add the &ldquo;Non Mesh&rdquo; Markers, fire stations, police stations, ...@@ -210,22 +214,25 @@ You can add the &ldquo;Non Mesh&rdquo; Markers, fire stations, police stations,
The admin pages also allow for some maintenance of the database, more feedback is encouraged on this!</p> The admin pages also allow for some maintenance of the database, more feedback is encouraged on this!</p>
<p>You can change the way the page looks by copying webpage/css/meshmap-default.css to webpage/css/meshmap.css.<br/> <p>You can change the way the page looks by copying webpage/css/meshmap-default.css to webpage/css/meshmap.css.<br/>
The meshmap.css file will be used in place of the -default.css file.<br/> The meshmap.css file will override the -default.css file.<br/>
(This also applies to other *-default.css files)</p> (This also applies to other *-default.css files, there are a few, please look at them if you wish to customize the layout of the map)</p>
<h2>ToDo List</h2> <h2>ToDo List</h2>
<hr /> <hr />
<p>(In no particular order)<br/> <p>(In no particular order)<br/>
- [x] Finally finish my admin page idea.<br/> - [x] Finally finish my admin page idea (mostly).<br/>
- [x] Add new MeshMap Logo.<br/> - [x] Add new MeshMap Logo.<br/>
- [x] Change the user editable files to be distributed with &ldquo;-default&rdquo; added to the extension, no more tar.gz file.<br/> - [x] User css files will override the defaults.<br/>
- [x] Use a cookie instead of _POST for the internet check (No more stupid dialog box on refresh).<br/> - [x] Polling script checks the DB before it runs and makes changes if needed.<br/>
- [ ] Make &ldquo;Parallel Threads&rdquo; work again in get-map-info script, with limits on how many can be run at once (this will greatly speed up network polling).<br/> - [ ] Make &ldquo;Parallel Threads&rdquo; work again in get-map-info script, with limits on how many can be run at once.<br/>
- [x] Changes so sbarc.org can have the new version too!<br/> (this will greatly speed up network polling)<br/>
- [x] Catch more nodes information now, like 3.15.1.0b04 and hopefully some other pesky ones!<br/>
(this will probably cause some warnings during node polling, but it is getting the info it needs)<br/>
(also helps clean up the database and was a nice side effect of that)<br/>
- [ ] Change css file for the &ldquo;?&rdquo; slide-out menu.<br/> - [ ] Change css file for the &ldquo;?&rdquo; slide-out menu.<br/>
- [x] Fix a typo in the attribution bar so the pop-up for the links is only for the links number.<br/> - [x] Make the numbers for stations and links in the attribution bar a bit more accurate I hope.<br/>
- [ ] Implement N2MH&rsquo;s &ldquo;Link aging&rdquo; idea(s).<br/> - [ ] Implement N2MH&rsquo;s &ldquo;Link aging&rdquo; idea(s).<br/>
- [ ] The &ldquo;Planning&rdquo; Tab.<br/> - [ ] The &ldquo;Planning&rdquo; Tab.<br/>
- [ ] Make it so other networks can export their data for use on a &ldquo;Mega Map&rdquo; type page. :)</p> - [ ] Make it so other networks can export their data for use on a &ldquo;Mega Map&rdquo; type page. :)</p>
...@@ -238,4 +245,4 @@ The meshmap.css file will be used in place of the -default.css file.<br/> ...@@ -238,4 +245,4 @@ The meshmap.css file will be used in place of the -default.css file.<br/>
I can&rsquo;t think of <em>everything</em>!<br/> I can&rsquo;t think of <em>everything</em>!<br/>
If you find an improvement, typo, or whatever, please, send an email to kg6wxc@gmail.com and we can get you setup with write access if you&rsquo;d like!</p> If you find an improvement, typo, or whatever, please, send an email to kg6wxc@gmail.com and we can get you setup with write access if you&rsquo;d like!</p>
<p>This README file last updated: May 2018</p> <p>This README file last updated: July 2018</p>
...@@ -26,14 +26,17 @@ Donations / Beer accepted! :) (paypal possibly coming soon, email: kg6wxc@gmail. ...@@ -26,14 +26,17 @@ Donations / Beer accepted! :) (paypal possibly coming soon, email: kg6wxc@gmail.
(you may only need mysqlnd, it should be safe to enable both for now) (you may only need mysqlnd, it should be safe to enable both for now)
(One or more of these extensions may need to be enabled in php.ini) (One or more of these extensions may need to be enabled in php.ini)
(if you do not already have mysqlnd, you might need to install it, `apt-get install php[5 or 7]-mysqlnd`) (if you do not already have mysqlnd, you might need to install it, `apt-get install php[5 or 7]-mysqlnd`)
(<em>the requirement for the mysqlnd extension will be removed in the near future</em>)
- **MySQL/MariaDB** - **MySQL/MariaDB**
(Other database systems are up to you) (Other database systems are up to you)
- **An AREDN Mesh node available over the local network** - **An AREDN Mesh node available over the local network**
(Preferably connected to an AREDN network...) (Preferably connected to an AREDN network...)
- **Map Tiles** - **Map Tiles**
(Either in a static directory or available via some tile server...) (Either in a static directory or available via some tile server...)
- **RPi3 or better** - **RPi3 or better**
(The DB access can be pretty slow on an RPi1, you can move the DB to another system though...) (The DB access can be pretty slow on an RPi1, you can move the DB to another system though...)
(If your local mesh network grows to become very large, with tunnels opened to the entire planet,<br/>
you might find even an RPi3+ to become inadequate, it'll still work, it just might be slow)
- **Patience** - **Patience**
(Perhaps a lot!) (Perhaps a lot!)
- **Familiarity with Linux/Apache/SQL** - **Familiarity with Linux/Apache/SQL**
...@@ -41,7 +44,7 @@ Donations / Beer accepted! :) (paypal possibly coming soon, email: kg6wxc@gmail. ...@@ -41,7 +44,7 @@ Donations / Beer accepted! :) (paypal possibly coming soon, email: kg6wxc@gmail.
<blockquote style="background: #d3d3d3; margin-right: 30%;">In theory, this <em>should</em> run on a Windows system as well.<br/> <blockquote style="background: #d3d3d3; margin-right: 30%;">In theory, this <em>should</em> run on a Windows system as well.<br/>
It does not require anything specific to Linux (<em>Perhaps with the exception of the cron task</em>).<br/> It does not require anything specific to Linux (<em>Perhaps with the exception of the cron task</em>).<br/>
There is no reason that part could not be adapted to run from a Windows scheduled task though.<br/> There is no reason that cronjob could not be adapted to run from a Windows scheduled task though.<br/>
PHP is PHP after all.</blockquote> PHP is PHP after all.</blockquote>
### Map Tile Server info ### Map Tile Server info
...@@ -88,8 +91,9 @@ Choose your own password! ...@@ -88,8 +91,9 @@ Choose your own password!
> `FLUSH PRIVILEGES;` > `FLUSH PRIVILEGES;`
- **4: Copy scripts/user-settings.ini-default to scripts/user-settings.ini and edit the user-settings.ini file** - **4: Copy scripts/user-settings.ini-default to scripts/user-settings.ini and edit the user-settings.ini file**
* You **must** do this or the **<em>entire system</em>** will refuse to run!
* The file scripts/user-settings.ini is the most important to get right. * The file scripts/user-settings.ini is the most important to get right.
It is **very important** to make sure your SQL username and password are correct in scripts/user-settings.ini!! It is **very important** to make sure your SQL username and password are correct in scripts/user-settings.ini!!
* Also important is, if the system that this is running on cannot resolve "localnode.local.mesh" you can change that in the user-settings.ini file. * Also important is, if the system that this is running on cannot resolve "localnode.local.mesh" you can change that in the user-settings.ini file.
* Once you save to the user-settings.ini file any changes you make will not be overwritten by future updates. * Once you save to the user-settings.ini file any changes you make will not be overwritten by future updates.
The "-default" files *will probably* change though and you will need to update your personal files when this happens. The "-default" files *will probably* change though and you will need to update your personal files when this happens.
...@@ -168,20 +172,23 @@ You can add the "Non Mesh" Markers, fire stations, police stations, EOC's , etc ...@@ -168,20 +172,23 @@ You can add the "Non Mesh" Markers, fire stations, police stations, EOC's , etc
The admin pages also allow for some maintenance of the database, more feedback is encouraged on this! The admin pages also allow for some maintenance of the database, more feedback is encouraged on this!
You can change the way the page looks by copying webpage/css/meshmap-default.css to webpage/css/meshmap.css. You can change the way the page looks by copying webpage/css/meshmap-default.css to webpage/css/meshmap.css.
The meshmap.css file will be used in place of the -default.css file. The meshmap.css file will override the -default.css file.
(This also applies to other *-default.css files) (This also applies to other *-default.css files, there are a few, please look at them if you wish to customize the layout of the map)
## ToDo List ## ToDo List
---------- ----------
(In no particular order) (In no particular order)
- [x] Finally finish my admin page idea. - [x] Finally finish my admin page idea (mostly).
- [x] Add new MeshMap Logo. - [x] Add new MeshMap Logo.
- [x] Change the user editable files to be distributed with "-default" added to the extension, no more tar.gz file. - [x] User css files will override the defaults.
- [x] Use a cookie instead of _POST for the internet check (No more stupid dialog box on refresh). - [x] Polling script checks the DB before it runs and makes changes if needed.
- [ ] Make "Parallel Threads" work again in get-map-info script, with limits on how many can be run at once (this will greatly speed up network polling). - [ ] Make "Parallel Threads" work again in get-map-info script, with limits on how many can be run at once.
- [x] Changes so sbarc.org can have the new version too! (this will greatly speed up network polling)
- [x] Catch more nodes information now, like 3.15.1.0b04 and hopefully some other pesky ones!
(this will probably cause some warnings during node polling, but it is getting the info it needs)
(also helps clean up the database and was a nice side effect of that)
- [ ] Change css file for the "?" slide-out menu. - [ ] Change css file for the "?" slide-out menu.
- [x] Fix a typo in the attribution bar so the pop-up for the links is only for the links number. - [x] Make the numbers for stations and links in the attribution bar a bit more accurate I hope.
- [ ] Implement N2MH's "Link aging" idea(s). - [ ] Implement N2MH's "Link aging" idea(s).
- [ ] The "Planning" Tab. - [ ] The "Planning" Tab.
- [ ] Make it so other networks can export their data for use on a "Mega Map" type page. :) - [ ] Make it so other networks can export their data for use on a "Mega Map" type page. :)
...@@ -192,4 +199,4 @@ The meshmap.css file will be used in place of the -default.css file. ...@@ -192,4 +199,4 @@ The meshmap.css file will be used in place of the -default.css file.
I can't think of *everything*! I can't think of *everything*!
If you find an improvement, typo, or whatever, please, send an email to kg6wxc@gmail.com and we can get you setup with write access if you'd like! If you find an improvement, typo, or whatever, please, send an email to kg6wxc@gmail.com and we can get you setup with write access if you'd like!
This README file last updated: May 2018 This README file last updated: July 2018
-- -------------------------------------------------------- -- --------------------------------------------------------
-- Host: 192.168.81.222 -- Host: 192.168.81.222
-- Server version: 10.2.14-MariaDB-log - MariaDB Server -- Server version: 10.3.7-MariaDB-log - MariaDB Server
-- Server OS: Linux -- Server OS: Linux
-- HeidiSQL Version: 9.4.0.5125 -- HeidiSQL Version: 9.4.0.5125
-- -------------------------------------------------------- -- --------------------------------------------------------
...@@ -19,7 +19,7 @@ USE `node_map`; ...@@ -19,7 +19,7 @@ USE `node_map`;
-- Dumping structure for table node_map.hosts_ignore -- Dumping structure for table node_map.hosts_ignore
CREATE TABLE IF NOT EXISTS `hosts_ignore` ( CREATE TABLE IF NOT EXISTS `hosts_ignore` (
`ip` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `ip` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`name` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'The name of the host, no domain', `name` varchar(70) COLLATE utf8_unicode_ci DEFAULT NULL,
`reason` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `reason` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`timestamp` datetime DEFAULT NULL, `timestamp` datetime DEFAULT NULL,
UNIQUE KEY `name_2` (`name`), UNIQUE KEY `name_2` (`name`),
...@@ -43,7 +43,7 @@ CREATE TABLE IF NOT EXISTS `map_info` ( ...@@ -43,7 +43,7 @@ CREATE TABLE IF NOT EXISTS `map_info` (
-- Dumping structure for table node_map.marker_info -- Dumping structure for table node_map.marker_info
CREATE TABLE IF NOT EXISTS `marker_info` ( CREATE TABLE IF NOT EXISTS `marker_info` (
`id` int(11) NOT NULL AUTO_INCREMENT, `id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) COLLATE utf8_unicode_ci NOT NULL, `name` varchar(128) COLLATE utf8_unicode_ci DEFAULT NULL,
`description` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `description` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`type` varchar(20) COLLATE utf8_unicode_ci NOT NULL, `type` varchar(20) COLLATE utf8_unicode_ci NOT NULL,
`lat` double NOT NULL, `lat` double NOT NULL,
...@@ -55,9 +55,11 @@ CREATE TABLE IF NOT EXISTS `marker_info` ( ...@@ -55,9 +55,11 @@ CREATE TABLE IF NOT EXISTS `marker_info` (
-- Data exporting was unselected. -- Data exporting was unselected.
-- Dumping structure for table node_map.node_info -- Dumping structure for table node_map.node_info
CREATE TABLE IF NOT EXISTS `node_info` ( CREATE TABLE IF NOT EXISTS `node_info` (
`node` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `node` varchar(70) COLLATE utf8_unicode_ci DEFAULT NULL,
`wlan_ip` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `wlan_ip` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`last_seen` datetime DEFAULT NULL, `last_seen` datetime DEFAULT NULL,
`uptime` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`loadavg` varchar(128) COLLATE utf8_unicode_ci DEFAULT NULL,
`model` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `model` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`firmware_version` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `firmware_version` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`ssid` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `ssid` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
...@@ -73,7 +75,7 @@ CREATE TABLE IF NOT EXISTS `node_info` ( ...@@ -73,7 +75,7 @@ CREATE TABLE IF NOT EXISTS `node_info` (
`firmware_mfg` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `firmware_mfg` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`grid_square` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `grid_square` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`lan_ip` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `lan_ip` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`sysinfo_json` mediumblob DEFAULT NULL, `services` varchar(2048) COLLATE utf8_unicode_ci DEFAULT NULL,
`location_fix` int(11) DEFAULT 0, `location_fix` int(11) DEFAULT 0,
UNIQUE KEY `node` (`node`) UNIQUE KEY `node` (`node`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Information about the nodes\r\ntaken from sysinfo.json that is on every node.'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Information about the nodes\r\ntaken from sysinfo.json that is on every node.';
...@@ -81,9 +83,11 @@ CREATE TABLE IF NOT EXISTS `node_info` ( ...@@ -81,9 +83,11 @@ CREATE TABLE IF NOT EXISTS `node_info` (
-- Data exporting was unselected. -- Data exporting was unselected.
-- Dumping structure for table node_map.removed_nodes -- Dumping structure for table node_map.removed_nodes
CREATE TABLE IF NOT EXISTS `removed_nodes` ( CREATE TABLE IF NOT EXISTS `removed_nodes` (
`node` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `node` varchar(70) COLLATE utf8_unicode_ci DEFAULT NULL,
`wlan_ip` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `wlan_ip` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`last_seen` datetime DEFAULT NULL, `last_seen` datetime DEFAULT NULL,
`uptime` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`loadavg` varchar(128) COLLATE utf8_unicode_ci DEFAULT NULL,
`model` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `model` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`firmware_version` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `firmware_version` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`ssid` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `ssid` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
...@@ -99,7 +103,7 @@ CREATE TABLE IF NOT EXISTS `removed_nodes` ( ...@@ -99,7 +103,7 @@ CREATE TABLE IF NOT EXISTS `removed_nodes` (
`firmware_mfg` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `firmware_mfg` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`grid_square` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `grid_square` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`lan_ip` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `lan_ip` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`sysinfo_json` mediumblob DEFAULT NULL, `services` varchar(2048) COLLATE utf8_unicode_ci DEFAULT NULL,
`time_removed` datetime DEFAULT NULL, `time_removed` datetime DEFAULT NULL,
UNIQUE KEY `node` (`node`) UNIQUE KEY `node` (`node`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='A place to put old nodes'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='A place to put old nodes';
...@@ -107,10 +111,10 @@ CREATE TABLE IF NOT EXISTS `removed_nodes` ( ...@@ -107,10 +111,10 @@ CREATE TABLE IF NOT EXISTS `removed_nodes` (
-- Data exporting was unselected. -- Data exporting was unselected.
-- Dumping structure for table node_map.topology -- Dumping structure for table node_map.topology
CREATE TABLE IF NOT EXISTS `topology` ( CREATE TABLE IF NOT EXISTS `topology` (
`node` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `node` varchar(70) COLLATE utf8_unicode_ci DEFAULT NULL,
`nodelat` double DEFAULT NULL, `nodelat` double DEFAULT NULL,
`nodelon` double DEFAULT NULL, `nodelon` double DEFAULT NULL,
`linkto` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `linkto` varchar(70) COLLATE utf8_unicode_ci DEFAULT NULL,
`linklat` double DEFAULT NULL, `linklat` double DEFAULT NULL,
`linklon` double DEFAULT NULL, `linklon` double DEFAULT NULL,
`cost` double DEFAULT NULL, `cost` double DEFAULT NULL,
...@@ -128,7 +132,7 @@ CREATE TABLE IF NOT EXISTS `users` ( ...@@ -128,7 +132,7 @@ CREATE TABLE IF NOT EXISTS `users` (
`passwd` varchar(256) COLLATE utf8_unicode_ci DEFAULT NULL, `passwd` varchar(256) COLLATE utf8_unicode_ci DEFAULT NULL,
`last_login` datetime DEFAULT NULL, `last_login` datetime DEFAULT NULL,
KEY `id` (`id`) KEY `id` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='a place to put users for the admin page(s)'; ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='a place to put users for the admin page(s)';
-- Data exporting was unselected. -- Data exporting was unselected.
-- Dumping structure for trigger node_map.node_info_after_insert -- Dumping structure for trigger node_map.node_info_after_insert
......
...@@ -72,13 +72,12 @@ ini_set('memory_limit', '128M'); ...@@ -72,13 +72,12 @@ ini_set('memory_limit', '128M');
$INCLUDE_DIR = ".."; $INCLUDE_DIR = "..";
//check for users user-settings.ini file and use it if it exists //check for users user-settings.ini file and use it if it exists
//use the default one if it does not //inform the user and exit if the file does not exist
global $USER_SETTINGS; global $USER_SETTINGS;
if (file_exists($INCLUDE_DIR . "/scripts/user-settings.ini")) { if (file_exists($INCLUDE_DIR . "/scripts/user-settings.ini")) {
$USER_SETTINGS = parse_ini_file($INCLUDE_DIR . "/scripts/user-settings.ini"); $USER_SETTINGS = parse_ini_file($INCLUDE_DIR . "/scripts/user-settings.ini");
}else { }else {
echo "\n\nYou **must** copy the user-settings.ini-default file to user-settings.ini and edit it!!\n\n"; exit("\n\nYou **must** copy the user-settings.ini-default file to user-settings.ini and edit it!!\n\n");
//$USER_SETTINGS = parse_ini_file($INCLUDE_DIR . "/scripts/user-settings.ini-default");
} }
//kg6wxc's functions. (ALWAYS REQUIRED!, change path if you moved it!) //kg6wxc's functions. (ALWAYS REQUIRED!, change path if you moved it!)
...@@ -148,13 +147,17 @@ wxc_checkConfigs(); ...@@ -148,13 +147,17 @@ wxc_checkConfigs();
date_default_timezone_set($USER_SETTINGS['localTimeZone']); date_default_timezone_set($USER_SETTINGS['localTimeZone']);
$currentTime = wxc_getCurrentDateTime(); $currentTime = wxc_getCurrentDateTime();
//what do we want to use in the sql server
$sql_db_tbl = $USER_SETTINGS['sql_db_tbl']; $sql_db_tbl = $USER_SETTINGS['sql_db_tbl'];
$sql_db_tbl_node = $USER_SETTINGS['sql_db_tbl_node']; $sql_db_tbl_node = $USER_SETTINGS['sql_db_tbl_node'];
$sql_db_tbl_topo = $USER_SETTINGS['sql_db_tbl_topo']; $sql_db_tbl_topo = $USER_SETTINGS['sql_db_tbl_topo'];
if ($do_sql) { if ($do_sql) {
//an sql connection that we can reuse... //an sql connection that we can reuse...
$sql_connection = wxc_connectToMySQL(); //$sql_connection = wxc_connectToMySQL();
wxc_connectToMySQL();
//check for new or changed database items (tables, columns,etc)
wxc_checkDB();
}else { }else {
if ($TEST_MODE_NO_SQL) { if ($TEST_MODE_NO_SQL) {
wxc_echoWithColor("SQL Server access disabled!", "red"); wxc_echoWithColor("SQL Server access disabled!", "red");
...@@ -162,34 +165,19 @@ if ($do_sql) { ...@@ -162,34 +165,19 @@ if ($do_sql) {
//echo "\033[31mSQL Server access disabled!\033[0m\n\n"; //echo "\033[31mSQL Server access disabled!\033[0m\n\n";
} }
} }
//check if we are ready to run
//(not quite done yet)
//wxc_checkConfigs(); //if ($do_sql) {
// wxc_checkDB();
//}
//This controls when certain parts of the script run. //This controls when certain parts of the script run.
//We check the DB for the time we last checked and only run if we need to. //We check the DB for the time we last checked and only run if we need to.
//intervals are now controled via the ini file now. //intervals are now controled via the ini file.
//thanks K6GSE! //thanks K6GSE!
if ($do_sql) { if ($do_sql) {
//if $do_sql is set to 1, check when we last got link info, if it was 5 minutes or more set the variable to 1 //if $do_sql is set to 1, check when we last polled all the known nodes, if it was more than the interval set the variable to 1
$lastRunGetLinkInfo = wxc_scriptGetLastDateTime("LINKINFO", "topology");
if($lastRunGetLinkInfo) {
if ($USER_SETTINGS['link_update_interval'] > 0) {
$intervalLINK = date_diff($lastRunGetLinkInfo, $currentTime);
//if ($intervalLINK->i >= 5) {
if ($intervalLINK->i >= intval($USER_SETTINGS['link_update_interval'])) {
if ($TEST_MODE_WITH_SQL) {
echo "It has been " . $USER_SETTINGS['link_update_interval'] . " or more minutes since this script got the link info\n";
echo "Setting getLinkInfo to TRUE.\n";
}
$getLinkInfo = 1;
}
}
}else {
//probably never run before, let's get some data!
$getLinkInfo = 1;
}
//if $do_sql is set to 1, check when we last polled all the known nodes, if it was 1 hour or more set the variable to 1
$lastRunGetNodeInfo = wxc_scriptGetLastDateTime("NODEINFO", "node_info"); $lastRunGetNodeInfo = wxc_scriptGetLastDateTime("NODEINFO", "node_info");
if ($lastRunGetNodeInfo) { if ($lastRunGetNodeInfo) {
if ($USER_SETTINGS['node_polling_interval'] > 0) { if ($USER_SETTINGS['node_polling_interval'] > 0) {
...@@ -197,29 +185,48 @@ if ($do_sql) { ...@@ -197,29 +185,48 @@ if ($do_sql) {
$intervalNodeInMinutes = $intervalNODE->days * 24 * 60; $intervalNodeInMinutes = $intervalNODE->days * 24 * 60;
$intervalNodeInMinutes += $intervalNODE->h * 60; $intervalNodeInMinutes += $intervalNODE->h * 60;
$intervalNodeInMinutes += $intervalNODE->i; $intervalNodeInMinutes += $intervalNODE->i;
//if ($intervalNODE->h >= 1) {
//if ($intervalNODE->i >= intval($USER_SETTINGS['node_polling_interval'])) {
if ($intervalNodeInMinutes >= intval($USER_SETTINGS['node_polling_interval'])) { if ($intervalNodeInMinutes >= intval($USER_SETTINGS['node_polling_interval'])) {
if ($TEST_MODE_WITH_SQL) { if ($TEST_MODE_WITH_SQL) {
echo "It has been " . $USER_SETTINGS['node_polling_interval'] . " or more minutes since this script polled all the nodes\n"; echo "It has been " . $USER_SETTINGS['node_polling_interval'] . " or more minutes since this script polled all the nodes\n";
echo "Setting getNodeInfo to TRUE.\n"; echo "Set to poll nodes.\n";
} }
$getNodeInfo = 1; $getNodeInfo = 1;
} }
} }
}else { }else {
//probably never run before, lets get some data!! //probably never run before, lets get some data!!
echo "Set to poll nodes.\n";
$getNodeInfo = 1; $getNodeInfo = 1;
} }
//if $do_sql is set to 1, check when we last got link info, if it was more than the interval set the variable to 1
$lastRunGetLinkInfo = wxc_scriptGetLastDateTime("LINKINFO", "topology");
if($lastRunGetLinkInfo) {
if ($USER_SETTINGS['link_update_interval'] > 0) {
$intervalLINK = date_diff($lastRunGetLinkInfo, $currentTime);
if ($intervalLINK->i >= intval($USER_SETTINGS['link_update_interval'])) {
if ($TEST_MODE_WITH_SQL) {
echo "It has been " . $USER_SETTINGS['link_update_interval'] . " or more minutes since this script got the link info\n";
echo "Set to get network linking info.\n\n";
}
$getLinkInfo = 1;
}
}
}else {
//probably never run before, let's get some data!
echo "Set to get network linking info.\n\n";
$getLinkInfo = 1;
}
} }
//check the database to see if we are already polling nodes //check the database to see if we are already polling nodes
//this trys to prevent 2 polling runs at once
//it does nothing in "--test-mode-no-sql"
if ($do_sql) { if ($do_sql) {
$currently_polling_nodes = wxc_getMySql("SELECT script_last_run, currently_running from map_info WHERE id = 'NODEINFO'"); $currently_polling_nodes = wxc_getMySql("SELECT script_last_run, currently_running from map_info WHERE id = 'NODEINFO'");
if (is_null($currently_polling_nodes['currently_running'])) { if (is_null($currently_polling_nodes['currently_running'])) {
$currently_polling_nodes['currently_running'] = 0; $currently_polling_nodes['currently_running'] = 0;
$getNodeInfo = 1; $getNodeInfo = 1;
}elseif ($currently_polling_nodes['currently_running'] == 1) { }elseif ($currently_polling_nodes['currently_running'] == 1) {
//if ($currently_polling_nodes['script_last_run'])
$getNodeInfo = 0; $getNodeInfo = 0;
} }
//hopefully catch a stalled polling run after 3 * node_polling_interval has expired. //hopefully catch a stalled polling run after 3 * node_polling_interval has expired.
...@@ -227,13 +234,14 @@ if ($do_sql) { ...@@ -227,13 +234,14 @@ if ($do_sql) {
//to unset the "currently_running" bit in the DB, //to unset the "currently_running" bit in the DB,
//this *should* catch that and and just run the node polling again //this *should* catch that and and just run the node polling again
if ($currently_polling_nodes['currently_running'] == 1 && $intervalNodeInMinutes >= intval($USER_SETTINGS['node_polling_interval']) * 3) { if ($currently_polling_nodes['currently_running'] == 1 && $intervalNodeInMinutes >= intval($USER_SETTINGS['node_polling_interval']) * 3) {
$getNodeInfo = 1; $currently_polling_nodes['currently_running'] = 0;
$getNodeInfo = 1;
} }
} }
//check for old outdated node info (intervals will be set in the ini file) //check for old outdated node info (intervals will be set in the ini file)
$no_expire = $USER_SETTINGS['expire_old_nodes']; $do_expire = $USER_SETTINGS['expire_old_nodes'];
if ($do_sql && $no_expire) { if ($do_sql && $do_expire) {
wxc_checkOldNodes(); wxc_checkOldNodes();
} }
if ($do_sql) { if ($do_sql) {
...@@ -253,10 +261,12 @@ if ($getNodeInfo) { ...@@ -253,10 +261,12 @@ if ($getNodeInfo) {
if ($do_sql && $currently_polling_nodes['currently_running'] == 0) { if ($do_sql && $currently_polling_nodes['currently_running'] == 0) {
wxc_putMySql("INSERT INTO map_info (id, table_or_script_name, script_last_run, currently_running) VALUES ('NODEINFO', 'node_info', NOW(), '1') ON DUPLICATE KEY UPDATE table_or_script_name = 'node_info', script_last_run = NOW(), currently_running = '1'"); wxc_putMySql("INSERT INTO map_info (id, table_or_script_name, script_last_run, currently_running) VALUES ('NODEINFO', 'node_info', NOW(), '1') ON DUPLICATE KEY UPDATE table_or_script_name = 'node_info', script_last_run = NOW(), currently_running = '1'");
} }
$meshNodes = wxc_netcat($USER_SETTINGS['localnode'], "2004", null, "ipOnly"); //get a new list of IP's //get a new list of IP's to poll
$meshNodes = wxc_netcat($USER_SETTINGS['localnode'], "2004", null, "ipOnly");
if ($meshNodes) { if ($meshNodes) {
/* TESTING IDEA */
/* TESTING IDEA */
/*
$ipAddrArray = explode("\n", $meshNodes); $ipAddrArray = explode("\n", $meshNodes);
$ipAddrArrayChunks = array_chunk($ipAddrArray, $USER_SETTINGS['numParallelThreads']); $ipAddrArrayChunks = array_chunk($ipAddrArray, $USER_SETTINGS['numParallelThreads']);
foreach($ipAddrArrayChunks as $chunk => $ipList) { foreach($ipAddrArrayChunks as $chunk => $ipList) {
...@@ -267,14 +277,16 @@ if ($getNodeInfo) { ...@@ -267,14 +277,16 @@ if ($getNodeInfo) {
foreach($ipAddrArray as $ipAddr) { foreach($ipAddrArray as $ipAddr) {
//echo ""; //echo "";
} }
*/
/* END TESTING */ /* END TESTING */
foreach (preg_split("/((\r?\n)|(\r\r?))/", $meshNodes) as $line) { foreach (preg_split("/((\r?\n)|(\r\r?))/", $meshNodes) as $line) {
list ($ipAddr) = explode("\n", $line); list ($ipAddr) = explode("\n", $line);
//check for nodes that we know will not have the info we are going to request and skip them //check for nodes that we know will not have the info we are going to request and skip them
if ($do_sql) { if ($do_sql) {
if (wxc_getMySql("SELECT ip, reason FROM hosts_ignore WHERE ip = '$ipAddr'")) { if (wxc_getMySql("SELECT ip FROM hosts_ignore WHERE ip = '$ipAddr'")) {
continue; continue;
} }
} }
...@@ -285,24 +297,23 @@ if ($getNodeInfo) { ...@@ -285,24 +297,23 @@ if ($getNodeInfo) {
//for($count = 1; $count <= 20; $count++) { //for($count = 1; $count <= 20; $count++) {
// $ipAddrList .= $ipAddr . "\n"; // $ipAddrList .= $ipAddr . "\n";
//} //}
$parallel_pids = array(); // $parallel_pids = array();
//$parallel_pids[] = trim(shell_exec("php $INCLUDE_DIR/scripts/parallel_node_polling.php $ipAddr $do_sql 0 > /dev/null 2>/dev/null & echo $!")); //$parallel_pids[] = trim(shell_exec("php $INCLUDE_DIR/scripts/parallel_node_polling.php $ipAddr $do_sql 0 > /dev/null 2>/dev/null & echo $!"));
$parallel_pids[] = trim(shell_exec("php $INCLUDE_DIR/scripts/parallel_node_polling.php $ipAddr $do_sql 0 > /dev/null 2>/dev/null & echo $!")); // $parallel_pids[] = trim(shell_exec("php $INCLUDE_DIR/scripts/parallel_node_polling.php $ipAddr $do_sql 0 > /dev/null 2>/dev/null & echo $!"));
//$parallel_pids[] = shell_exec("php $INCLUDE_DIR/scripts/parallel_node_polling.php $ipAddr $do_sql 0 > /dev/null & echo $!"); //$parallel_pids[] = shell_exec("php $INCLUDE_DIR/scripts/parallel_node_polling.php $ipAddr $do_sql 0 > /dev/null & echo $!");
//var_dump($parallel_pids); //var_dump($parallel_pids);