Commit Graph

762 Commits

Author SHA1 Message Date
Adrian Schmutzler 7ac73ebbdc map: filter inactive hoods
Hoods are only inserted into the database if they are active,
inactive hoods are ignored.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2021-07-07 23:31:29 +02:00
Adrian Schmutzler 3fb9315888 user: fix return for non-existent user
Fixes a 500 error.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2021-07-07 23:16:50 +02:00
Adrian Schmutzler 6c34f7c0de router.html: only show br-client on top of netif list
While we can have both br-client and br-mesh on top of the netif
list, we can only pre-load the data for one of them. This led to
the situation where br-mesh was shown as selected, but no data was
displayed.

Thus, let's just put the new br-client at that priviledged position,
and having br-mesh deselected by default. This should make the
situation more understandable.

Fixes: bd8d0280f6 ("treewide: add support for br-client")

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2021-02-26 17:34:56 +01:00
Adrian Schmutzler 543117cb00 router.html: add support for available memory
Add support for showing available memory if included in the alfred
dataset. This might be more helpful than free memory in several
cases.

While at it, tidy up and improve the JS code for the graph. It also
shows the latest values in the legend now.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2021-02-26 17:26:54 +01:00
Adrian Schmutzler bd8d0280f6 treewide: add support for br-client
br-mesh has been renamed to br-client in recent firmware.

Implement br-client parallel to br-mesh.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2021-02-22 20:22:50 +01:00
Adrian Schmutzler e4977356fc statistics.html: Use shorter keys for stats json
Like done recently for the router details page, also reduce the
amount of plain data by using short names for the keys in json
stats. While at it, also remove unused fields and improve the
formatting of the query.

This fixes the traffic graph on the statistics page, which was
broken due to the earlier change for the routers.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2021-01-13 14:27:10 +01:00
Adrian Schmutzler 386ffce1c5 calcglobalstats: Add missing MySQL commit
The commit was missing after the MySQL queries, leaving e.g. updated
V2 Hoods unchanged in the database.

Add commit for individual function and for the script to be sure
nothing else is overlooked.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2021-01-13 14:23:34 +01:00
Adrian Schmutzler 1ad0c7d532 db: fix string in hood setup script
The string was missing quotes, and thus python interpreted it as
a variable. Fix it.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2021-01-02 20:40:36 +01:00
Adrian Schmutzler 08602134d7 router.html: use shorter keys for included stats
Since part of the stats are just added to the html page, make
their keys shorter so the overall data transmitted per page is
reduced.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2021-01-02 20:31:02 +01:00
Adrian Schmutzler 547cbbed73 db: add and improve scripts for dealing with influx retention
init_influx.py: This should be run initially when the database is
                set up.

update_influx.py: This should be run when the retention policies
                  are changed.

status_influx.pw: This will print the current retention policies
                  from the database.

For the scripts to work, the dictionary with retention policies
needs to be set up in influconfig.py, like shown in the example
file. Furthermore, the hostname, port, and database need to be
set correctly there, too (but not the user/pw, see below).

Since typically the user for the monitoring itself would not be
an admin, but admin access is required for changing the policies,
the scripts would be started by specifying the proper user name
as argument, e.g.

  init_influx.py username

If auth_enabled = false, no user needs to be specified, and the
scripts may just be run without arguments.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2020-11-27 16:19:49 +01:00
Adrian Schmutzler fcccf3b9db db: update init scripts due to removed stats tables in MySQL
While at it, improve name to distinguish from influxdb.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2020-11-24 16:45:55 +01:00
Adrian Schmutzler 30de5a052e api/alfredX: remove remnants of netif dictionary
MySQL implementation of stats tables needed a dictionary of netifs.

This can be removed now.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2020-11-24 16:45:49 +01:00
Adrian Schmutzler 5e1d037b12 scripts/defragtables: remove stats tables
We don't use MySQL tables for stats anymore, so no need to keep
them here.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2020-11-24 16:45:42 +01:00
Adrian Schmutzler 73c1f0c2d0 db: Hide influxdb config and provide example file
The actual config needs to be located at ffmap/influconfig.py

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2020-11-24 16:45:37 +01:00
Adrian Schmutzler bd1aaaeeea api/alfredX: handle influxdb in batches
Previously, data was sent to influxdb individually for each router.

This is expected to be inefficient, so let's collect all additions
per retention policy now (the latter is required by influxdb).

The downside is that the whole bunch will fail if one dataset is
broken. However, this only applies to the data after parsing the
XML/JSON. If parsing fails, this will be handled as before.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2020-11-24 14:19:05 +01:00
Adrian Schmutzler 16e083d06c api/alfredX: remove chunked MySQL commit
So far, MySQL commits were triggered for each bunch of 500 devices.

However, since data is provided _per hood_, we will never receive
chunks that big. Just commit once after each alfred batch.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2020-11-24 14:19:05 +01:00
Adrian Schmutzler f5135344c3 api/alfredX: force float for loadavg in stats
Force float as otherwise influxdb will complain about int/float
mismatch.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2020-11-24 14:17:47 +01:00
Adrian Schmutzler 718d207612 api/alfredX: Remove InfluxDB test code
This reverts commits:
ccb5bb020f ("api/alfredX: Update code for InfluxDB test")
396d5a251e ("api/alfredX: Add code for InfluxDB test")

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2020-11-24 12:40:01 +01:00
Adrian Schmutzler 6eda60f537 global: convert to InfluxDB
This converts the entire setup to use InfluxDB 1.x for stats tables
instead of MySQL.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2020-11-24 11:05:14 +01:00
Adrian Schmutzler 0169efa303 statistics.html: Increase firmware pie threshold to 1 %
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2020-11-24 10:42:52 +01:00
Adrian Schmutzler 9066fbada1 scripts/deletestats: increase chunk size and handling
This increases the chunk size for deletions and makes it possible
to change the value in one place.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2020-11-24 10:41:38 +01:00
Adrian Schmutzler 3d5f2776b2 scripts/calcglobalstats: only delete routers from main table
The previous implementation used an INNER JOIN for deletion.
This only works if there is an entry in all connected tables,
leaving a lot of devices undeleted after a certain timespan.

To really get all devices, this changes to just deleting from
the main table. The remnants in other tables can be dealt with
by another function to find orphaned entries later.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2020-11-24 10:38:56 +01:00
Adrian Schmutzler e80480883d map: reduce cache lifespan to 2m for routers
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2020-11-24 10:37:27 +01:00
Adrian Schmutzler bf55323f2f Global: remove net from hoodsv1 table
KeyXchange does not store the network anymore.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2020-11-24 10:36:45 +01:00
Fabian Bläse dfb335e1be tilestache: reduce log level
Reduce log level from info to warning to reduce log spam.

Signed-off-by: Fabian Bläse <fabian@blaese.de>
2020-03-11 14:14:26 +01:00
Fabian Bläse bc50a44d29 tilestache: use memcache instead of disk for tile storage
So far, tiles have been stored on disk which, in combination with
bad disk performance, made the map slow and laggy.

This patch switches to memcache, which will remove the dependency
on disk performance for loading cached tiles entirely.

Note that installing and configuring memcached will be required
manually like for the other dependencies.

Signed-off-by: Fabian Bläse <fabian@blaese.de>
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2020-03-11 14:13:56 +01:00
Adrian Schmutzler 40c803d71f README: remove section: When Updating
There should be no installations of the mongoDB-based Monitoring
left, so the upgrading instruction seem useless and might actually
be even misleading.

Remove them.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2020-03-10 19:10:36 +01:00
Adrian Schmutzler c1285bfbcb README: update repo URL
Update URL for clone of fff-monitoring repo.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2020-03-10 19:10:36 +01:00
Adrian Schmutzler 5084da09ba api: add ssidclient to display list of all AP SSIDs used
Based on a request, the URL /api/ssidclient will provide a plain-text,
new-line-separated list of all used AP SSIDs.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2020-03-10 19:10:36 +01:00
Adrian Schmutzler bbb3218db0 Update leaflet to 1.6.0
We are using an ancient release of the leaflet framework.
Therefore it is updated to the latest compatible version.

Signed-off-by: Fabian Bläse <fabian@blaese.de>
[resolve carriage return rebase issue]
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2020-03-10 18:35:42 +01:00
Fabian Bläse 62c552ab76 Update bootstrap to 3.4.1
We are using an ancient release of both the Bootstrap framework.
Therefore it is updated to the latest compatible version.

Signed-off-by: Fabian Bläse <fabian@blaese.de>
2020-03-10 18:25:40 +01:00
Adrian Schmutzler 6805baa352 scripts/deleteunlinked.py: Add old-stats tables and sleep
This adds the new old-stats tables to the script looking for lost
router-dependent entries.

While at it, add a short sleep between queries.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2019-10-11 19:40:03 +02:00
Adrian Schmutzler 6a401f8246 statistics.html: Define days displayed for GW statistics separately
Since we changed the number of days stored for gateway statistics,
it makes sense to also have a (reduced) separate display config
variable.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2019-10-11 19:20:46 +02:00
Adrian Schmutzler fc910c868e db/stats_gw: Remove accumulated gateway stats after 30 days
Accumulated gateway stats are much less accurate and helpful than
those for hoods or the global ones. Since they however account for
most of the global stats data, reduce their history in patch.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2019-10-11 19:20:04 +02:00
Adrian Schmutzler 0dc1d81064 db/router_stats_*: Dilute density of older router statistics
To reduce the amount of router stats, this introduces a new set
of router_stats_* tables that store data in 30-minutes-intervals.

The original tables remain, but the data in those will be kept for
a shorter time.

Thus, we have more dense data for recent stats and less dense data
for older stats. By reducing the density from every 5 to every 30
minutes, we reduce size of the "old" data to a sixth of the initial
amount. This should speed up I/O substantially.

Having two tables per category is superior to trimming the data in
one table: Remove data by e.g. modulo queries is slow and will
cause strong fragmentation of the table. By having two tables, we
introduce same data overlap, but on the other hand effectively
provide table partitioning making individual tables smaller.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2019-10-11 17:55:08 +02:00
Adrian Schmutzler e5dbff909e api/alfred and api/gwinfo: Fix response definition
So far, response was defined in try block, but also used in except
block. This resulted in variable-not-set errors when exception was
raised before the response was set.

This sets response before try block to have it defined in any case.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2019-10-11 17:40:08 +02:00
Adrian Schmutzler 849ca0f81c api/alfred: Fix mistake during adding babel_version
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2019-10-03 00:41:43 +02:00
Adrian Schmutzler 86b134e12b api/alfred: Add debug output to investigate yellow routers
This logs cases where the netif is not found in table and thus
AUTO_INCREMENT in netifs table will be raised.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2019-09-30 15:13:45 +02:00
Adrian Schmutzler 7f012979ad apidoc.html: Add babel_version to alfred example XML
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2019-09-30 14:54:48 +02:00
Adrian Schmutzler 01b5223b5a api/alfred: Prevent division-by-zero if uptime not set
This fixes errors like the following:

{2019-07-01 19:40:01} - Warning: Exception occurred when saving xxxx: division by zero
__Traceback (most recent call last):
__ File "/usr/local/lib/python3.5/dist-packages/ffmap/routertools.py", line 160, in import_nodewatcher_xml
__ calculate_network_io(mysql, router_id, uptime, router_update)
__ File "/usr/local/lib/python3.5/dist-packages/ffmap/routertools.py", line 669, in calculate_network_io
__ netif_update["traffic"]["rx"] = int(netif_update["traffic"]["rx_bytes"] / router_update["sys_uptime"])
__ZeroDivisionError: division by zero
__

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2019-09-30 14:54:42 +02:00
Adrian Schmutzler 6a93573f91 router.html: Display babel version
This adds the babel version to the router database and displays
it in router.html.

While at it, have both babel version and BATMAN version appear only
if data is present.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2019-09-30 14:54:34 +02:00
Fabian Bläse 9e1fcdaa77 Use RRZE servers instead of OSMs for default tiles
Openstreemaps tile servers do not support IPv6.
They are also quite slow sometimes.

Therefore the default tile source is changed to RRZE servers
which do support IPv6 and are way faster.

Signed-off-by: Fabian Bläse <fabian@blaese.de>
2019-09-30 14:54:26 +02:00
Fabian Bläse 2c65fcea66 Replace proprietary Thunderforest tiles with Wikimedia tiles
Thunderforest Maps are proprietary and require an api key.

As I quite like the Wikimedia map style as it has a very low
contrast which makes nodes and connections between them stand out
way more.

URLs for the Thunderforest Map will point to Wikimedia now.

Signed-off-by: Fabian Bläse <fabian@blaese.de>
[Do not introduce new id to source URL parameter]
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2019-09-30 14:54:16 +02:00
Fabian Bläse 37b185afd1 Reduce popup borders for a more modern look
Signed-off-by: Fabian Bläse <fabian@blaese.de>
2019-09-30 14:53:20 +02:00
Adrian Schmutzler ccb5bb020f api/alfredX: Update code for InfluxDB test
This changes mechanism for legacy alfred to remove the 64 array
already in Monitoring and send to the same script as for alfred2.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2019-09-30 13:11:05 +02:00
Adrian Schmutzler 6dd5a163d7 statistics.html: Reduce displayed history to 60 days
This introduces a new config variable global_stat_show_days that
will limit the displayed number of days on statistics.html.

The saved amount of data will be untouched.

This should speed up loading that page significantly.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2019-09-02 16:13:12 +02:00
Adrian Schmutzler 396d5a251e api/alfredX: Add code for InfluxDB test
This sends alfred/alfred2 data to Christian's test scripts to
check for performance of a Grafana/InfluxDB setup.

This will be removed after testing.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2019-09-02 16:00:46 +02:00
Adrian Schmutzler c0384ee959 uwsgi: Use new syntax to call executable
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2019-07-19 19:06:39 +02:00
Adrian Schmutzler e6bb3b9ce0 Tilestache: Use official repository again
With newer tilestache in official repo, we do not need our local
version any more.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2019-07-19 19:05:27 +02:00
Adrian Schmutzler 50793e5d90 api/alfred2: Return Exception message for failed JSON parsing
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2019-06-03 00:23:29 +02:00