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 @@
**/meshmap-settings.ini
**/meshmap.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.
<li><strong>openssl PHP extension</strong><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/>
(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/>
(Other database systems are up to you)</li>
<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.
<li><strong>Map Tiles</strong><br/>
(Either in a static directory or available via some tile server&hellip;)</li>
<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/>
(Perhaps a lot!)</li>
<li><strong>Familiarity with Linux/Apache/SQL</strong><br/>
......@@ -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/>
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>
......@@ -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>
<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/>
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>
......@@ -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>
<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/>
(This also applies to other *-default.css files)</p>
The meshmap.css file will override the -default.css file.<br/>
(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>
<hr />
<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] Change the user editable files to be distributed with &ldquo;-default&rdquo; added to the extension, no more tar.gz file.<br/>
- [x] Use a cookie instead of _POST for the internet check (No more stupid dialog box on refresh).<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/>
- [x] Changes so sbarc.org can have the new version too!<br/>
- [x] User css files will override the defaults.<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.<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/>
- [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/>
- [ ] 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>
......@@ -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/>
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.
(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)
(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**
(Other database systems are up to you)
(Other database systems are up to you)
- **An AREDN Mesh node available over the local network**
(Preferably connected to an AREDN network...)
- **Map Tiles**
(Either in a static directory or available via some tile server...)
- **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**
(Perhaps a lot!)
- **Familiarity with Linux/Apache/SQL**
......@@ -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/>
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>
### Map Tile Server info
......@@ -88,8 +91,9 @@ Choose your own password!
> `FLUSH PRIVILEGES;`
- **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.
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.
* 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.
......@@ -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!
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.
(This also applies to other *-default.css files)
The meshmap.css file will override the -default.css file.
(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
----------
(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] Change the user editable files to be distributed with "-default" added to the extension, no more tar.gz file.
- [x] Use a cookie instead of _POST for the internet check (No more stupid dialog box on refresh).
- [ ] 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).
- [x] Changes so sbarc.org can have the new version too!
- [x] User css files will override the defaults.
- [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)
- [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.
- [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).
- [ ] The "Planning" Tab.
- [ ] 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.
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!
This README file last updated: May 2018
This README file last updated: July 2018
-- --------------------------------------------------------
-- 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
-- HeidiSQL Version: 9.4.0.5125
-- --------------------------------------------------------
......@@ -19,7 +19,7 @@ USE `node_map`;
-- Dumping structure for table node_map.hosts_ignore
CREATE TABLE IF NOT EXISTS `hosts_ignore` (
`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,
`timestamp` datetime DEFAULT NULL,
UNIQUE KEY `name_2` (`name`),
......@@ -43,7 +43,7 @@ CREATE TABLE IF NOT EXISTS `map_info` (
-- Dumping structure for table node_map.marker_info
CREATE TABLE IF NOT EXISTS `marker_info` (
`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,
`type` varchar(20) COLLATE utf8_unicode_ci NOT NULL,
`lat` double NOT NULL,
......@@ -55,9 +55,11 @@ CREATE TABLE IF NOT EXISTS `marker_info` (
-- Data exporting was unselected.
-- Dumping structure for table node_map.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,
`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,
`firmware_version` 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` (
`firmware_mfg` 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,
`sysinfo_json` mediumblob DEFAULT NULL,
`services` varchar(2048) COLLATE utf8_unicode_ci DEFAULT NULL,
`location_fix` int(11) DEFAULT 0,
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.';
......@@ -81,9 +83,11 @@ CREATE TABLE IF NOT EXISTS `node_info` (
-- Data exporting was unselected.
-- Dumping structure for table node_map.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,
`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,
`firmware_version` 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` (
`firmware_mfg` 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,
`sysinfo_json` mediumblob DEFAULT NULL,
`services` varchar(2048) COLLATE utf8_unicode_ci DEFAULT NULL,
`time_removed` datetime DEFAULT NULL,
UNIQUE KEY `node` (`node`)
) 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` (
-- Data exporting was unselected.
-- Dumping structure for table node_map.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,
`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,
`linklon` double DEFAULT NULL,
`cost` double DEFAULT NULL,
......@@ -128,7 +132,7 @@ CREATE TABLE IF NOT EXISTS `users` (
`passwd` varchar(256) COLLATE utf8_unicode_ci DEFAULT NULL,
`last_login` datetime DEFAULT NULL,
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.
-- Dumping structure for trigger node_map.node_info_after_insert
......
......@@ -72,13 +72,12 @@ ini_set('memory_limit', '128M');
$INCLUDE_DIR = "..";
//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;
if (file_exists($INCLUDE_DIR . "/scripts/user-settings.ini")) {
$USER_SETTINGS = parse_ini_file($INCLUDE_DIR . "/scripts/user-settings.ini");
}else {
echo "\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");
exit("\n\nYou **must** copy the user-settings.ini-default file to user-settings.ini and edit it!!\n\n");
}
//kg6wxc's functions. (ALWAYS REQUIRED!, change path if you moved it!)
......@@ -148,13 +147,17 @@ wxc_checkConfigs();
date_default_timezone_set($USER_SETTINGS['localTimeZone']);
$currentTime = wxc_getCurrentDateTime();
//what do we want to use in the sql server
$sql_db_tbl = $USER_SETTINGS['sql_db_tbl'];
$sql_db_tbl_node = $USER_SETTINGS['sql_db_tbl_node'];
$sql_db_tbl_topo = $USER_SETTINGS['sql_db_tbl_topo'];
if ($do_sql) {
//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 {
if ($TEST_MODE_NO_SQL) {
wxc_echoWithColor("SQL Server access disabled!", "red");
......@@ -162,34 +165,19 @@ if ($do_sql) {
//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.
//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!
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
$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
//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
$lastRunGetNodeInfo = wxc_scriptGetLastDateTime("NODEINFO", "node_info");
if ($lastRunGetNodeInfo) {
if ($USER_SETTINGS['node_polling_interval'] > 0) {
......@@ -197,29 +185,48 @@ if ($do_sql) {
$intervalNodeInMinutes = $intervalNODE->days * 24 * 60;
$intervalNodeInMinutes += $intervalNODE->h * 60;
$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 ($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 "Setting getNodeInfo to TRUE.\n";
echo "Set to poll nodes.\n";
}
$getNodeInfo = 1;
}
}
}else {
//probably never run before, lets get some data!!
echo "Set to poll nodes.\n";
$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
//this trys to prevent 2 polling runs at once
//it does nothing in "--test-mode-no-sql"
if ($do_sql) {
$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'])) {
$currently_polling_nodes['currently_running'] = 0;
$getNodeInfo = 1;
}elseif ($currently_polling_nodes['currently_running'] == 1) {
//if ($currently_polling_nodes['script_last_run'])
$getNodeInfo = 0;
}
//hopefully catch a stalled polling run after 3 * node_polling_interval has expired.
......@@ -227,13 +234,14 @@ if ($do_sql) {
//to unset the "currently_running" bit in the DB,
//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) {
$getNodeInfo = 1;
$currently_polling_nodes['currently_running'] = 0;
$getNodeInfo = 1;
}
}
//check for old outdated node info (intervals will be set in the ini file)
$no_expire = $USER_SETTINGS['expire_old_nodes'];
if ($do_sql && $no_expire) {
$do_expire = $USER_SETTINGS['expire_old_nodes'];
if ($do_sql && $do_expire) {
wxc_checkOldNodes();
}
if ($do_sql) {
......@@ -253,10 +261,12 @@ if ($getNodeInfo) {
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'");
}
$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) {
/* TESTING IDEA */
/* TESTING IDEA */
/*
$ipAddrArray = explode("\n", $meshNodes);
$ipAddrArrayChunks = array_chunk($ipAddrArray, $USER_SETTINGS['numParallelThreads']);
foreach($ipAddrArrayChunks as $chunk => $ipList) {
......@@ -267,14 +277,16 @@ if ($getNodeInfo) {
foreach($ipAddrArray as $ipAddr) {
//echo "";
}
*/
/* END TESTING */
foreach (preg_split("/((\r?\n)|(\r\r?))/", $meshNodes) as $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
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;
}
}
......@@ -285,24 +297,23 @@ if ($getNodeInfo) {
//for($count = 1; $count <= 20; $count++) {
// $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[] = shell_exec("php $INCLUDE_DIR/scripts/parallel_node_polling.php $ipAddr $do_sql 0 > /dev/null & echo $!");
//var_dump($parallel_pids);
}else {
//get the sysinfo.json file from the node being polled.
$sysinfoJson = @file_get_contents("http://$ipAddr:8080/cgi-bin/sysinfo.json"); //get the .json file
$sysinfoJson = @file_get_contents("http://$ipAddr:8080/cgi-bin/sysinfo.json?services_local=1"); //get the .json file
$jsonFetchSuccess = 1;
//check if we got anything back, if not, try to tell why.
if($sysinfoJson === FALSE) {
$jsonFetchSuccess = 0;
$error = error_get_last();
wxc_checkErrorMessage($error, $nodeName);
//just skip the next IP
//just skip to the next IP since there was an error
continue;
}else {
//node is there, get all the info we can
......@@ -310,7 +321,7 @@ if ($getNodeInfo) {
$result = json_decode($sysinfoJson,true);
//if there's nothing really there just skip to the next IP
if (!$result) {
if (!$result || empty($result)) {
continue;
}
//first let's see what node we are dealing with
......@@ -324,46 +335,28 @@ if ($getNodeInfo) {
//kg6wxc is *not* guilty of such things... :)
//
//just a few checks for nothing usually catches it.
if ($node && $result['lat'] == "" && $result['lon'] == "" && $result['ssid'] == ""
if ($result['node'] && $result['lat'] == "" && $result['lon'] == "" && $result['ssid'] == ""
&& $result['model'] == "" && $result['firmware_mfg'] == ""
&& $result['api_version'] == "") {
continue;
}
//gather lots of other information from OLSRD about the node being polled (we hopefully can use this later)
//this requires a second connection to the node. no way around that.
//but only if we have a firmware version >= than 3.16.0 (or "develop-16")
$firmware_version = $result['firmware_version'];
$olsrdInfo = 0;
//changed again to exclude some nodes 10-21-2017
/************
* REMOVED due to issues
* DO NOT UNCOMMENT FOR NOW
************/
//if (version_compare($result['firmware_version'], "3.16.0.0", ">") || strpos($result['firmware_version'], "evelop-16") || $result['firmware_version'] === "linux" || $result['firmware_version'] === "Linux") {
// $olsrdInfo = wxc_netcat("$ipAddr");
// $noPort9090 = 1;
//}
//maybe in the future we'll be able to get this info remotely too and use it for something
//$olsrdDotDrawInfo = wxc_netcat("$nodeName.local.mesh","2004", null, null); //save the polled nodes local dot_draw info (never know we may want it for something)
//save json data to some variables
//probably don't really need to do this, but it is what it is for now...
$model = $result['model'];
$firmware_version = $result['firmware_version'];
$model = $result['model'];
//this only seems to affect some nodes.
//if lat || log is blank, make it "0"
//if lat || lon is blank, make it "0"
//this was sometimes screwing up the SQL writing function
//but not always of course.
if ($result['lat'] == "") {
$lat = "0";
$lat = 0.0;
}else {
$lat = $result['lat'];
}
if ($result['lon'] == "") {
$lon = "0";
$lon = 0.0;
}else {
$lon = $result['lon'];
}
......@@ -377,12 +370,28 @@ if ($getNodeInfo) {
$channel = $result['channel'];
$firmware_mfg = $result['firmware_mfg'];
//had to screen scrape the status page for this info before (or use the evil port 9090!)
//now it is here! :)
$uptime = "NotAvailable";
$loadavg = "NotAvailable";
if (version_compare($api_version, "1.2", ">=")) {
$uptime = $result['sysinfo']['uptime'];
$loadavg = serialize($result['sysinfo']['loads']); // <-- this is an array that has been serialized!!
}
//local service listing are now in the json file!! yay!
//this required evil port 9090 before
$services = "NotAvailable";
if (version_compare($api_version, "1.3", ">=")) {
$services = serialize($result['services_local']); // <-- this is an array that has been serialized!
}
//this only seems to affect some nodes.
//if grid_square is blank, make it NULL
//if grid_square is blank, make it "none"
//this was sometimes screwing up the SQL writing function
//but not always of course.
if ($result['grid_square'] == "") {
$grid_square = NULL;
$grid_square = "none";
}else {
$grid_square = $result['grid_square'];
}
......@@ -390,31 +399,53 @@ if ($getNodeInfo) {
//W6BI requested this info to be added, so here it is now. :)
//current ip/mac address info
if ($result['interfaces']) {
foreach($result['interfaces'] as $interface) {
foreach($result['interfaces'] as $interface => $infInfo) {
$eth = "eth0";
if ($result['model'] == "Ubiquiti Nanostation M XW" || $result['model'] == "AirRouter " || $result['model'] == "NanoStation M5 XW ") {
//"AirRouter " model name bug caught and fixed by Mark, N2MH 13 March 2017.
$eth = "eth0.0";
}
if ($interface['name'] == $eth) { // error with KK9DS on $name (undefined index)
$lan_ip = $interface['ip']; //error with ke6upi here on $ip (undefinded index)
//
// This should catch some of those pesky ones
// what a fricken nightmare... jeez
//
if ($result['api_version'] == "1.0" && $infInfo['name'] == $eth && $interface !== $eth) {
$lan_ip = $infInfo['ip'];
}
if ($interface['name'] == "wlan0") {
$wlan_ip = $interface['ip'];
$wifi_mac_address = $interface['mac']; //added to fix MAC address issue, caught by Mark, N2MH 14 March 2017.
//elseif ($result['api_version'] == "1.0" && $infInfo['name'] == "eth0.0") {
// $lan_ip = $infInfo['ip'];
//}
elseif ($result['api_version'] == "1.0" && $infInfo['name'] == "wlan0" && $interface !== "wlan0") {
$wlan_ip = $infInfo['ip'];
$wifi_mac_address = $infInfo['mac'];
}elseif ($result['api_version'] == "1.0" && $interface == $eth) {
$lan_ip = $infInfo['ip'];
}
//elseif ($result['api_version'] == "1.0" && $interface == "eth0.0") {
// $lan_ip = $infInfo['ip'];
//}
elseif ($result['api_version'] == "1.0" && $interface == "wlan0") {
$wlan_ip = $infInfo['ip'];
$wifi_mac_address = $infInfo['mac'];
}elseif (version_compare($result['api_version'], "1.0", ">")) {
if ($infInfo['name'] == $eth) { // error with KK9DS on $name (undefined index)
if (isset($infInfo['ip'])) {
if ($infInfo['ip'] == "none") {
$lan_ip = "NotAvailable";
}else {
$lan_ip = $infInfo['ip']; //error with ke6upi here on $ip (undefinded index)
}
}elseif (!isset($infInfo['ip'])) {
$lan_ip = "NotAvailable";
}
}
if ($infInfo['name'] == "wlan0") {
$wlan_ip = $infInfo['ip'];
$wifi_mac_address = $infInfo['mac']; //added to fix MAC address issue, caught by Mark, N2MH 14 March 2017.
}
}
}
}
//**change node locations via admin page now!!**
// if ($wxc_custom) {
// if($do_sql) {
// $nodesToFixLocations = fixLocations($node, $lat, $lon);
// list ($node, $lat, $lon) = explode(" ", $nodesToFixLocations);
// $node = $node;
// $lat = $lat;
// $lon = $lon;
// }
// }
if ($testNodePolling) {
echo "Name: "; wxc_echoWithColor($result['node'], "purple"); echo "\n";
......@@ -440,7 +471,14 @@ if ($getNodeInfo) {
//echo "Firmware Version: " . $firmware_version . "\n";
echo "Firmware: \033[32m" . $result['firmware_mfg'] . " " . $result['firmware_version'] . "\033[0m\n";
}
echo "LAN ip: " . $lan_ip . " WLAN ip: " . $wlan_ip . "\n";
echo "LAN ip: ";
if ($lan_ip == "NotAvailable") {
wxc_echoWithColor($lan_ip, "orange");