diff --git a/user/monitoring.rst b/user/monitoring.rst index 5e21846c..d3a49e16 100644 --- a/user/monitoring.rst +++ b/user/monitoring.rst @@ -88,7 +88,7 @@ This is the most common scenario: In this scenario, the OpenWISP application will not be able to reach the devices **unless a management tunnel** is used, for that reason having -a management VPN like OpenVPN, Wireguard or any other tunneling solution +a management VPN like OpenVPN, Wireguard, ZeroTier or any other tunneling solution is paramount, not only to allow OpenWISP to work properly, but also to be able to perform debugging and troubleshooting when needed. diff --git a/user/network-topology.rst b/user/network-topology.rst index 29b13b8c..7c1a6ccb 100644 --- a/user/network-topology.rst +++ b/user/network-topology.rst @@ -122,6 +122,92 @@ Sending data for topology with RECEIVE strategy or, alternatively, a non-admin visualizer page is also available at the URL ``/topology/topology//``. +Sending data for ZeroTier topology with RECEIVE strategy +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Follow the procedure described below to setup ZeroTier topology with RECEIVE strategy. + +**Note:** In this example, the **Shared systemwide (no organization)** +option is used for the ZeroTier topology organization. You are free to +opt for any organization, as long as both the topology and the device share +the same organization, assuming the `OpenWISP controller integration +<#integration-with-openwisp-controller-and-openwisp-monitoring>`_ feature is enabled. + +1. Create topology for ZeroTier +############################### + +1. Visit ``admin/topology/topology/add`` to add a new topology. + +2. We will set the **Label** of this topology to ``ZeroTier`` and + select the topology **Format** from the dropdown as ``ZeroTier``. + +3. Select the strategy as ``RECEIVE`` from the dropdown. + +.. image:: https://raw.githubusercontent.com/openwisp/openwisp-network-topology/docs/docs/zerotier-tutorial/topology-1.png + :alt: ZeroTier topology configuration example 1 + +4. Let use default **Expiration time** ``0`` and make sure **Published** option is checked. + +5. After clicking on the **Save and continue editing** button, a topology receive URL is generated. + Make sure you copy that URL for later use in the topology script. + +.. image:: https://raw.githubusercontent.com/openwisp/openwisp-network-topology/docs/docs/zerotier-tutorial/topology-2.png + :alt: ZeroTier topology configuration example 2 + +2. Create a script for sending ZeroTier topology data +##################################################### + +1. Now, create a script (e.g: ``/opt/send-zt-topology.sh``) that sends + the ZeroTier topology data using a POST request. In the example script below, + we are sending the ZeroTier self-hosted controller peers data: + +.. code-block:: shell + + #!/bin/bash + # command to fetch zerotier controller peers data in json format + COMMAND="zerotier-cli peers -j" + UUID="" + KEY="" + OPENWISP_URL="https://" + $COMMAND | + # Upload the topology data to OpenWISP + curl -X POST \ + --data-binary @- \ + --header "Content-Type: text/plain" \ + $OPENWISP_URL/api/v1/network-topology/topology/$UUID/receive/?key=$KEY + +2. Add the ``/opt/send-zt-topology.sh`` script created in the previous step + to the root crontab, here's an example which sends the topology data every **5 minutes**: + +.. code-block:: shell + + # flag script as executable + chmod +x /opt/send-zt-topology.sh + +.. code-block:: shell + + # open rootcrontab + sudo crontab -e + + ## Add the following line and save + + echo */5 * * * * /opt/send-zt-topology.sh + +**Note:** When using the **ZeroTier** topology, ensure that +you use ``sudo crontab -e`` to edit the **root crontab**. This step +is essential because the ``zerotier-cli peers -j`` command requires **root privileges** +for kernel interaction, without which the command will not function correctly. + +3. Once the steps above are completed, you should see nodes and links + being created automatically, you can see the network topology graph + from the admin page of the topology change page (you have to click on + the **View topology graph** button in the upper right part of the page) + or, alternatively, a non-admin visualizer page is also available at + the URL ``/topology/topology//``. + + .. image:: https://raw.githubusercontent.com/openwisp/openwisp-network-topology/docs/docs/zerotier-tutorial/topology-graph.png + :alt: ZeroTier topology graph example 1 + Find out more about OpenWISP Network Topology ---------------------------------------------