Merge pull request #59 from ffnord/feature-ffmap-d3-jq
Added jq filter to convert new format to old format
This commit is contained in:
commit
b53a94ec0a
15
README.md
15
README.md
|
@ -79,6 +79,21 @@ will prefix `sudo` where necessary.
|
||||||
- online
|
- online
|
||||||
- gateway
|
- gateway
|
||||||
|
|
||||||
|
## Old data format
|
||||||
|
|
||||||
|
If you want to still use the old [ffmap-d3](https://github.com/ffnord/ffmap-d3)
|
||||||
|
front end, you can use the file `ffmap-d3.jq` to convert the new output to the
|
||||||
|
old one:
|
||||||
|
|
||||||
|
```
|
||||||
|
jq -n -f ffmap-d3.jq \
|
||||||
|
--argfile nodes nodedb/nodes.json \
|
||||||
|
--argfile graph nodedb/graph.json \
|
||||||
|
> nodedb/ffmap-d3.json
|
||||||
|
```
|
||||||
|
|
||||||
|
Then point your ffmap-d3 instance to the `ffmap-d3.json` file.
|
||||||
|
|
||||||
# Removing owner information
|
# Removing owner information
|
||||||
|
|
||||||
If you'd like to redact information about the node owner from `nodes.json`,
|
If you'd like to redact information about the node owner from `nodes.json`,
|
||||||
|
|
52
ffmap-d3.jq
Normal file
52
ffmap-d3.jq
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
{
|
||||||
|
"meta": {
|
||||||
|
"timestamp": $nodes.timestamp
|
||||||
|
},
|
||||||
|
"nodes": (
|
||||||
|
$graph.batadv.nodes
|
||||||
|
| map(
|
||||||
|
if has("node_id") and .node_id
|
||||||
|
then (
|
||||||
|
$nodes.nodes[.node_id] as $node
|
||||||
|
| {
|
||||||
|
"id": .id,
|
||||||
|
"uptime": $node.statistics.uptime,
|
||||||
|
"flags": ($node.flags + {"client": false}),
|
||||||
|
"name": $node.nodeinfo.hostname,
|
||||||
|
"clientcount": (if $node.statistics.clients >= 0 then $node.statistics.clients else 0 end),
|
||||||
|
"hardware": $node.nodeinfo.hardware.model,
|
||||||
|
"firmware": $node.nodeinfo.software.firmware.release,
|
||||||
|
"geo": (if $node.nodeinfo.location then [$node.nodeinfo.location.latitude, $node.nodeinfo.location.longitude] else null end),
|
||||||
|
#"lastseen": $node.lastseen,
|
||||||
|
"network": $node.nodeinfo.network
|
||||||
|
}
|
||||||
|
)
|
||||||
|
else
|
||||||
|
{
|
||||||
|
"flags": {},
|
||||||
|
"id": .id,
|
||||||
|
"geo": null,
|
||||||
|
"clientcount": 0
|
||||||
|
}
|
||||||
|
end
|
||||||
|
)
|
||||||
|
),
|
||||||
|
"links": (
|
||||||
|
$graph.batadv.links
|
||||||
|
| map(
|
||||||
|
$graph.batadv.nodes[.source].node_id as $source_id
|
||||||
|
| $graph.batadv.nodes[.target].node_id as $target_id
|
||||||
|
| select(
|
||||||
|
$source_id and $target_id and
|
||||||
|
($nodes.nodes | (has($source_id) and has($target_id)))
|
||||||
|
)
|
||||||
|
| {
|
||||||
|
"target": .target,
|
||||||
|
"source": .source,
|
||||||
|
"quality": "\(.tq), \(.tq)",
|
||||||
|
"id": ($source_id + "-" + $target_id),
|
||||||
|
"type": (if .vpn then "vpn" else null end)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
Loading…
Reference in a new issue