### Install Downloaded Fledge Core and GUI Packages Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/quick_start/installing These commands demonstrate how to install the core Fledge system and its graphical user interface from locally downloaded `.deb` files. The filenames shown are examples and should be replaced with the actual names of your downloaded packages. ```bash sudo DEBIAN_FRONTEND=noninteractive apt -y install ./fledge_2.3.0_x86_64.deb ``` ```bash sudo apt -y install ./fledge-gui_2.3.0.deb ``` -------------------------------- ### Install Core Fledge, GUI, and South Plugin via APT Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/quick_start/installing This command installs multiple essential Fledge components in a single operation. It includes the core Fledge system, the graphical user interface (`fledge-gui`), and an example south plugin (`fledge-south-sinusoid`) for data acquisition. ```bash sudo DEBIAN_FRONTEND=noninteractive apt -y install fledge fledge-gui fledge-south-sinusoid ``` -------------------------------- ### Display Docker System Information Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/quick_start/installing This command provides comprehensive details about the Docker installation, including client and server versions, storage driver, and configured insecure registries, useful for verifying Docker setup. ```bash docker info ``` -------------------------------- ### Install Downloaded Fledge South Plugin (Sense HAT) Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/quick_start/installing This command illustrates installing a specific Fledge South plugin, such as the Sense HAT plugin, from a locally downloaded `.deb` file. This example is tailored for Raspberry Pi platforms due to hardware dependencies. Adjust the filename to match your downloaded plugin. ```bash sudo apt -y install ./fledge-south-sensehat_2.3.0_armv7l.deb ``` -------------------------------- ### Install Downloaded Fledge Package (Generic) Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/quick_start/installing This command installs a Fledge package from a locally downloaded `.deb` file. Replace `` with the full path and name of the `.deb` package you intend to install. This method is used when packages are not installed directly from a repository. ```bash sudo apt -y install ``` -------------------------------- ### Explore Fledge Installation Directory and Basic Commands Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/building_fledge/04_installation Shows the contents of the `/usr/local/fledge` directory after a successful installation, highlighting key subdirectories like `bin`, `data`, and `plugins`. It then demonstrates how to use the `fledge` command-line utility from the `bin` directory to view usage options, get detailed help, and start the Fledge services. ```bash $ cd /usr/local/fledge/ $ ls -l total 32 drwxr-xr-x 2 root root 4096 Apr 24 18:07 bin drwxr-xr-x 4 fledge fledge 4096 Apr 24 18:07 data drwxr-xr-x 4 root root 4096 Apr 24 18:07 extras drwxr-xr-x 4 root root 4096 Apr 24 18:07 plugins drwxr-xr-x 3 root root 4096 Apr 24 18:07 python drwxr-xr-x 6 root root 4096 Apr 24 18:07 scripts drwxr-xr-x 2 root root 4096 Apr 24 18:07 services -rwxr-xr-x 1 root root 37 Apr 24 18:07 VERSION $ $ bin/fledge Usage: fledge {start|start --safe-mode|stop|status|reset|kill|help|version} $ $ bin/fledge help Usage: fledge {start|start --safe-mode|stop|status|reset|kill|help|version} Fledge v1.3.1 admin script The script is used to start Fledge Arguments: start - Start Fledge core (core will start other services). start --safe-mode - Start in safe mode (only core and storage services will be started) stop - Stop all Fledge services and processes kill - Kill all Fledge services and processes status - Show the status for the Fledge services reset - Restore Fledge factory settings WARNING! This command will destroy all your data! version - Print Fledge version help - This text $ $ bin/fledge start Starting Fledge...... Fledge started. ``` -------------------------------- ### Install Single Fledge Package via APT Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/quick_start/installing This is a generic command to install a specific Fledge package using the APT package manager. Replace `*package*` with the actual name of the Fledge component you wish to install from the configured repositories. ```bash sudo apt -y install *package* ``` -------------------------------- ### Python-based Plugin: Package File Configuration Example Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/plugin_developers_guide/09_packaging Example `Package` file content for a Python-based plugin, defining packaging variables like plugin name, type, and installation directory, along with the start of runtime requirements definition. ```Shell $ cat Package # A set of variables that define how we package this repository # plugin_name=sinusoid plugin_type=south plugin_install_dirname=sinusoid # Now build up the runtime requirements list. This has 3 components # 1. Generic packages we depend on in all architectures and package managers # 2. Architecture specific packages we depend on ``` -------------------------------- ### Manually Add Fledge APT Repository for Raspberry Pi Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/quick_start/installing For Raspberry Pi systems lacking `add-apt-repository`, these commands guide you to manually edit the `/etc/apt/sources.list` file. You must add the specified `deb` line to include the Fledge repository for your specific Raspberry Pi OS version (e.g., bullseye). ```bash sudo vi /etc/apt/sources.list ``` ```bash deb http://archives.fledge-iot.org/latest/bullseye/armv7l/ / ``` -------------------------------- ### Check Fledge Package Installation on Linux Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/quick_start/installing This command lists all installed Debian packages and filters them to show only those related to 'fledge', useful for verifying successful installation on a Linux host system. ```bash dpkg -l | grep 'fledge' ``` -------------------------------- ### Update and Upgrade System Packages on Fledge Server Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/quick_start/installing Before proceeding with Fledge installation, it is crucial to ensure the operating system is fully updated. These commands refresh the package lists and upgrade all installed software to their latest versions, which helps in maintaining system security and compatibility. ```Shell sudo apt-get update sudo apt-get upgrade sudo apt-get update ``` -------------------------------- ### C-based Plugin: Package File Configuration Example Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/plugin_developers_guide/09_packaging Example `Package` file content for a C-based plugin, defining packaging variables such as plugin name, type, installation directory, package name, and runtime requirements that adapt based on architecture and package manager. ```Shell $ cat Package # A set of variables that define how we package this repository # plugin_name=modbus plugin_type=south plugin_install_dirname=ModbusC plugin_package_name=fledge-south-modbus additional_libs="usr/local/lib:/usr/local/lib/libsmod.so*" # Now build up the runtime requirements list. This has 3 components # 1. Generic packages we depend on in all architectures and package managers # 2. Architecture specific packages we depend on # 3. Package manager specific packages we depend on requirements="fledge" case "$arch" in x84_64) ;; armv7l) ;; aarch64) ;; esac case "$package_manager" in deb) requirements="${requirements},libmodbus-dev" ;; esac ``` -------------------------------- ### Start Fledge Service Manually Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/building_fledge/04_installation Initiates the Fledge service immediately using `systemctl start`. This command brings the Fledge application online. ```bash $ sudo systemctl start fledge.service ``` -------------------------------- ### Access Fledge Graphical User Interface (GUI) Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/quick_start/installing This URL is used to access the Fledge GUI in a web browser, assuming the Docker container's port 80 has been mapped to host port 8082. ```text http://localhost:8082 ``` -------------------------------- ### C-based Plugin: requirements.sh Script Example Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/plugin_developers_guide/09_packaging An example shell script for `requirements.sh`, demonstrating conditional installation of `libmodbus-dev` based on the detected package manager (apt or yum). ```Shell $ cat requirements.sh #!/usr/bin/env bash which apt >/dev/null 2>&1 if [ $? -eq 0 ]; then sudo apt install -y libmodbus-dev else which yum >/dev/null 2>&1 if [ $? -eq 0 ]; then sudo yum -y install epel-release libmodbus libmodbus-devel fi fi ``` -------------------------------- ### Add Fledge APT Repository for Mendel OS Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/quick_start/installing For Google Coral devices running Mendel OS, this content should be inserted into a new file named `/etc/apt/sources.list.d/fledge.list`. This manually adds the Fledge APT repository for aarch64 Mendel systems. ```bash deb http://archives.fledge-iot.org/latest/mendel/aarch64/ / ``` -------------------------------- ### Verify Fledge API Service Status Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/quick_start/installing This cURL command sends a silent GET request to the Fledge API's `/fledge/ping` endpoint on localhost:8081 to check if the Fledge service is active and responding. ```bash curl -sX GET http://localhost:8081/fledge/ping ``` -------------------------------- ### Python-based Plugin: Description File Content Example Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/plugin_developers_guide/09_packaging Example content for the `Description` file for a Python-based plugin, providing a brief overview. ```Text $ cat Description Fledge South Sinusoid plugin ``` -------------------------------- ### Update APT Package List Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/quick_start/installing After adding new repositories, this command updates the local package index. It fetches the latest information about available packages from all configured sources, including the newly added Fledge repository. ```bash sudo apt -y update ``` -------------------------------- ### Pull Fledge Docker Image for Ubuntu 20.04 Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/quick_start/installing This command downloads the latest Fledge Docker image specifically built for Ubuntu 20.04 from the designated private Docker registry. ```bash docker pull 54.204.128.201:5000/fledge:latest-ubuntu2004 ``` -------------------------------- ### C-based Plugin: Description File Content Example Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/plugin_developers_guide/09_packaging Example content for the `Description` file, providing a brief overview of the Fledge modbus plugin's capabilities. ```Text $ cat Description Fledge modbus plugin. Supports modbus RTU and modbus TCP. ``` -------------------------------- ### Restart Docker Service on Linux Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/quick_start/installing This command restarts the Docker daemon, applying any new configurations, such as changes made to `daemon.json`. It requires superuser privileges. ```bash sudo systemctl restart docker.service ``` -------------------------------- ### Add Fledge APT Repository for Ubuntu 20.04 (Intel/AMD) Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/quick_start/installing This command adds the Fledge APT repository specifically for Ubuntu 20.04 running on Intel or AMD (x86_64) systems. It uses `add-apt-repository` to configure the package source automatically. ```bash sudo add-apt-repository "deb http://archives.fledge-iot.org/latest/ubuntu2004/x86_64/ / " ``` -------------------------------- ### Add Fledge APT Repository GPG Key Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/quick_start/installing This command adds the GPG key for the Dianomic Systems archive server to your system's APT configuration. The key is used to verify the authenticity of packages downloaded from the Fledge repository, ensuring secure installations. ```bash wget -q -O - http://archives.fledge-iot.org/KEY.gpg | sudo apt-key add - ``` -------------------------------- ### Install Fledge Data Source Plugin via APT Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/quick_start/datasources This command installs a Fledge data source plugin using the `apt` package manager on a Linux system. This step is a prerequisite for adding new data sources through the Fledge GUI. ```bash sudo apt -y install PackageName ``` -------------------------------- ### Add Fledge APT Repository for Ubuntu 18.04 (Intel/AMD) Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/quick_start/installing This command adds the Fledge APT repository specifically for Ubuntu 18.04 running on Intel or AMD (x86_64) systems. It uses `add-apt-repository` to configure the package source automatically. ```bash sudo add-apt-repository "deb http://archives.fledge-iot.org/latest/ubuntu1804/x86_64/ / " ``` -------------------------------- ### C-based Plugin: fledge.version File Content Example Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/plugin_developers_guide/09_packaging Example content for the `fledge.version` file, indicating the minimum required Fledge version for the plugin. ```Text $ cat fledge.version fledge_version>=1.9 ``` -------------------------------- ### Start Nginx Service for Fledge GUI Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/plugin_developers_guide/11_WSL2 Executes the command to start the Nginx web server, which is essential for hosting the Fledge GUI. This service needs to be manually started at each system boot. ```Bash sudo service nginx start ``` -------------------------------- ### Run Fledge Docker Container with Port Mappings Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/quick_start/installing This command starts the Fledge Docker container in detached mode (`-d`), assigns it the name 'fledge', and maps several host ports (8081, 1995, 8082) to corresponding container ports (8081, 1995, 80) for API, internal communication, and GUI access respectively. ```bash docker run -d --name fledge -p 8081:8081 -p 1995:1995 -p 8082:80 54.204.128.201:5000/fledge:latest-ubuntu2004 ``` -------------------------------- ### Enable Fledge Service for Boot Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/building_fledge/04_installation Enables the Fledge service to start automatically on system boot using `systemctl enable`. This command integrates the service with the system's startup process. ```bash $ sudo systemctl enable fledge.service fledge.service is not a native service, redirecting to systemd-sysv-install Executing /lib/systemd/systemd-sysv-install enable fledge ``` -------------------------------- ### C-based Plugin: VERSION File Content Example Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/plugin_developers_guide/09_packaging Example content for the `VERSION` file, specifying the plugin's version number. ```Text $ cat VERSION 1.9.2 ``` -------------------------------- ### Install Fledge from Build using make install Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/building_fledge/04_installation Demonstrates the output of the `sudo make install` command, showing the creation of directories, Fledge version installation, database schema check, and the build process using CMake and make. This command requires superuser privileges to install Fledge into the default system location. ```bash $ sudo make install mkdir -p /usr/local/fledge Installing Fledge version 1.8.0, DB schema 2 -- Fledge DB schema check OK: Info: /usr/local/fledge is empty right now. Skipping DB schema check. cp VERSION /usr/local/fledge cd cmake_build ; cmake /home/fledge/Fledge/ -- Boost version: 1.58.0 -- Found the following Boost libraries: -- system -- thread -- chrono -- date_time -- atomic -- Found SQLite version 3.11.0: /usr/lib/x86_64-linux-gnu/libsqlite3.so -- Boost version: 1.58.0 -- Found the following Boost libraries: -- system -- thread -- chrono -- date_time -- atomic -- Configuring done -- Generating done -- Build files have been written to: /home/fledge/Fledge/cmake_build cd cmake_build ; make make[1]: Entering directory '/home/fledge/Fledge/cmake_build' ... ``` -------------------------------- ### Add Fledge APT Repository for Ubuntu 18.04 (Arm) Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/quick_start/installing This command adds the Fledge APT repository specifically for Ubuntu 18.04 running on Arm (aarch64) systems, such as Odroid boards. It uses `add-apt-repository` to configure the package source automatically. ```bash sudo add-apt-repository "deb http://archives.fledge-iot.org/latest/ubuntu1804/aarch64/ / " ``` -------------------------------- ### Access Fledge Docker Container Shell Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/quick_start/installing This command provides an interactive terminal session (`-it`) into the running 'fledge' Docker container, allowing users to execute commands directly within the container's environment. ```bash docker exec -it fledge bash ``` -------------------------------- ### Configure Fledge Storage Plugin to PostgreSQL via API Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/quick_start/installing This cURL command sends a PUT request to the Fledge API to change the active storage plugin to PostgreSQL. It demonstrates how to interact with the Fledge configuration API programmatically. The response shows the updated configuration details. ```bash curl -sX PUT localhost:8081/fledge/category/Storage/plugin -d '{"value": "postgres"}' { "description": "The main storage plugin to load", "type": "string", "order": "1", "displayName": "Storage Plugin", "default": "sqlite", "value": "postgres" } ``` -------------------------------- ### C-based Plugin: service_notification.version File Content Example Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/plugin_developers_guide/09_packaging Example content for the `service_notification.version` file, specifying the required version for service notifications. ```Text $ cat service_notification.version service_notification_version>=1.9.2 ``` -------------------------------- ### Configure Docker Daemon for Insecure Registry Access Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/quick_start/installing This JSON snippet is used in the `/etc/docker/daemon.json` file to allow Docker to pull images from a specified insecure registry, which is necessary for accessing private Fledge Docker image repositories without authentication. ```json { "insecure-registries":["54.204.128.201:5000"] } ``` -------------------------------- ### Install Fledge Debian Package using apt Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/building_fledge/04_installation This comprehensive snippet outlines the process of preparing the system and installing the Fledge Debian package. It includes updating and upgrading apt packages, copying the downloaded Fledge package to the apt cache directory, and finally installing it using `sudo apt install`. The output shows the detailed installation process, including service registration and certificate generation. ```bash $ sudo apt update Hit:1 http://gb.archive.ubuntu.com/ubuntu xenial InRelease ... $ sudo apt upgrade ... $ sudo apt update ... $ sudo cp fledge-1.8.0-x86_64.deb /var/cache/apt/archives/. ... $ sudo apt install /var/cache/apt/archives/fledge-1.8.0-x86_64.deb Reading package lists... Done Building dependency tree Reading state information... Done Note, selecting 'fledge' instead of '/var/cache/apt/archives/fledge-1.8.0-x86_64.deb' The following packages were automatically installed and are no longer required: ... Unpacking fledge (1.8.0) ... Setting up fledge (1.8.0) ... Resolving data directory Data directory does not exist. Using new data directory Installing service script Generating certificate files Certificate files do not exist. Generating new certificate files. Creating a self signed SSL certificate ... Certificates created successfully, and placed in data/etc/certs Generating auth certificate files CA Certificate file does not exist. Generating new CA certificate file. Creating ca SSL certificate ... ca certificate created successfully, and placed in data/etc/certs Admin Certificate file does not exist. Generating new admin certificate file. Creating user SSL certificate ... user certificate created successfully for admin, and placed in data/etc/certs User Certificate file does not exist. Generating new user certificate file. Creating user SSL certificate ... user certificate created successfully for user, and placed in data/etc/certs Setting ownership of Fledge files Calling Fledge package update script Linking update task Changing setuid of update_task.apt Removing task/update Create link file Copying sudoers file Setting setuid bit of cmdutil Enabling Fledge service fledge.service is not a native service, redirecting to systemd-sysv-install. Executing: /lib/systemd/systemd-sysv-install enable fledge Starting Fledge service $ ``` -------------------------------- ### C-based Plugin: Package File Requirements Update Example Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/plugin_developers_guide/09_packaging An example demonstrating how to add Fledge-managed common libraries, such as `fledge-s2opcua`, to the `requirements` variable within the `Package` file. ```Shell requirements="fledge,fledge-s2opcua" ``` -------------------------------- ### Install Windows Subsystem for Linux 2 (WSL2) Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/plugin_developers_guide/11_WSL2 This command initiates the installation of WSL2 on Windows, including the default Ubuntu distribution. It handles all necessary steps automatically, simplifying the setup process for users. ```shell wsl --install ``` -------------------------------- ### Implement Fledge C/C++ Plugin Initialization Entry Point Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/plugin_developers_guide/04_north_plugins Illustrates a common implementation of the `plugin_init` entry point for Fledge C/C++ plugins. This function receives a `ConfigCategory` object containing the plugin's merged configuration and typically instantiates the main plugin class, passing the configuration for internal setup and returning a handle to the new instance. ```C/C++ PLUGIN_HANDLE plugin_init(ConfigCategory *configData) { return (PLUGIN_HANDLE)(new myNorthPlugin(configData)); } ``` -------------------------------- ### Check Fledge Service Status (Post-Enable) Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/building_fledge/04_installation Verifies the Fledge service status after enabling it. At this point, the service is loaded but still inactive, awaiting a manual start or system reboot. ```bash $ sudo systemctl status fledge.service ● fledge.service - LSB: Fledge Loaded: loaded (/etc/init.d/fledge; bad; vendor preset: enabled) Active: inactive (dead) Docs: man:systemd-sysv-generator(8) ``` -------------------------------- ### Check Fledge Service Status (Pre-Enable) Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/building_fledge/04_installation Checks the initial status of the Fledge service using `systemctl`. This command typically shows that the service is not found or inactive before it has been properly enabled and started. ```bash $ sudo systemctl status fledge.service ● fledge.service Loaded: not-found (Reason: No such file or directory) Active: inactive (dead) ``` -------------------------------- ### Raspberry Pi Installation Reboot Notes Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/plugin_developers_guide/09_packaging This snippet provides critical post-installation instructions for Raspberry Pi devices, emphasizing the necessity of a system reboot to ensure all changes are applied correctly. ```text It is required to reboot the RPi, please do the following steps: 1) sudo reboot ``` -------------------------------- ### Install Fledge Notification Service using make install Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/services/fledge-service-notification/index This command installs the compiled notification service binary into the Fledge installation directory. It is typically used when Fledge itself was installed using 'make install' and should be run from the build directory of the notification service. ```bash $ make install ``` -------------------------------- ### Python-based Plugin Core File Definitions Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/plugin_developers_guide/09_packaging Defines the purpose and structure of essential configuration files required for Python-based Fledge plugins, including versioning, installation notes, and pip dependencies. ```APIDOC VERSION.{PLUGIN_TYPE}.{PLUGIN_NAME}: Description: Contains the packaged version of the plugin and the minimum Fledge version required. install_notes.txt (Optional): Description: A simple text file for specific installation instructions, which will be displayed at the end of the package installation. extras_install.sh (Optional): Description: A shell script added to the package to allow for extra commands to be executed as part of the package installation. requirements-{PLUGIN_NAME}.txt (Optional): Description: A simple text file for pip dependencies, which must be placed inside the 'python' directory. ``` -------------------------------- ### Run fogbench with Missing Template Argument Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/building_fledge/06_testing This example demonstrates invoking the 'fogbench' tool from its default installation path without providing the required template file argument. The output shows the tool's usage syntax and an error message indicating that the '-t/--template' argument is mandatory for execution. ```Shell $ /usr/local/fledge/bin/fogbench >>> Make sure south CoAP plugin service is running & listening on specified host and port usage: fogbench [-h] [-v] [-k {y,yes,n,no}] -t TEMPLATE [-o OUTPUT] [-I ITERATIONS] [-O OCCURRENCES] [-H HOST] [-P PORT] [-i INTERVAL] [-S {total}] fogbench: error: the following arguments are required: -t/--template $ ``` -------------------------------- ### Install Fledge OpenWeather South Plugin via APT Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/plugin_developers_guide/01_Fledge_plugins This shell script demonstrates the process of installing a Fledge South plugin (OpenWeather) from a .deb package. It first verifies the Fledge service status, then copies the plugin package to the APT cache, installs it using `sudo apt install`, and finally checks the Fledge status again to confirm the new plugin service is active. This method is suitable for package-based plugin installations. ```bash $ sudo systemctl status fledge.service ● fledge.service - LSB: Fledge Loaded: loaded (/etc/init.d/fledge; bad; vendor preset: enabled) Active: active (running) since Wed 2018-05-16 01:32:25 BST; 4min 1s ago Docs: man:systemd-sysv-generator(8) CGroup: /system.slice/fledge.service ├─13741 python3 -m fledge.services.core └─13746 /usr/local/fledge/services/storage --address=0.0.0.0 --port=40138 May 16 01:36:09 ubuntu python3[13741]: Fledge[13741] INFO: scheduler: fledge.services.core.scheduler.scheduler: Process started: Schedule 'stats collection' process 'stats coll ['tasks/statistics', '--port=40138', '--address=127.0.0.1', '--name=stats collector'] ... Fledge v1.3.1 running. Fledge Uptime: 266 seconds. Fledge records: 0 read, 0 sent, 0 purged. Fledge does not require authentication. === Fledge services: fledge.services.core === Fledge tasks: $ $ sudo cp fledge-south-openweathermap-1.2-x86_64.deb /var/cache/apt/archives/. $ sudo apt install /var/cache/apt/archives/fledge-south-openweathermap-1.2-x86_64.deb Reading package lists... Done Building dependency tree Reading state information... Done Note, selecting 'fledge-south-openweathermap' instead of '/var/cache/apt/archives/fledge-south-openweathermap-1.2-x86_64.deb' The following packages were automatically installed and are no longer required: linux-headers-4.4.0-109 linux-headers-4.4.0-109-generic linux-headers-4.4.0-119 linux-headers-4.4.0-119-generic linux-headers-4.4.0-121 linux-headers-4.4.0-121-generic linux-image-4.4.0-109-generic linux-image-4.4.0-119-generic linux-image-4.4.0-121-generic linux-image-extra-4.4.0-109-generic linux-image-extra-4.4.0-119-generic linux-image-extra-4.4.0-121-generic Use 'sudo apt autoremove' to remove them. The following NEW packages will be installed fledge-south-openweathermap 0 to upgrade, 1 to newly install, 0 to remove and 0 not to upgrade. Need to get 0 B/3,404 B of archives. After this operation, 0 B of additional disk space will be used. Selecting previously unselected package fledge-south-openweathermap. (Reading database ... 211747 files and directories currently installed.) Preparing to unpack .../fledge-south-openweathermap-1.2-x86_64.deb ... Unpacking fledge-south-openweathermap (1.2) ... Setting up fledge-south-openweathermap (1.2) ... openweathermap plugin installed. $ $ fledge status Fledge v1.3.1 running. Fledge Uptime: 271 seconds. Fledge records: 36 read, 0 sent, 0 purged. Fledge does not require authentication. === Fledge services: fledge.services.core fledge.services.south --port=42066 --address=127.0.0.1 --name=openweathermap === Fledge tasks: $ ``` -------------------------------- ### Start Fledge from Build Environment Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/building_fledge/building_fledge This snippet demonstrates the initial steps to run Fledge after building it. It involves navigating to the Fledge project directory, setting the FLEDGE_ROOT environment variable to the current path, and then executing the fledge start command to launch the service. ```bash $ pwd /home/ubuntu/fledge $ export FLEDGE_ROOT=/home/ubuntu/fledge $ ./scripts/fledge start Starting Fledge vX.X..... Fledge started. $ ``` -------------------------------- ### Example: Retrieve Fledge Statistics with cURL Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/rest_api_guide/03_RESTstatistics Demonstrates how to use the `curl` command-line tool to make a GET request to the `/fledge/statistics` endpoint. The example shows the command to execute and a truncated sample of the JSON response payload, illustrating the structure of the returned statistical data. ```bash $ curl -s http://localhost:8081/fledge/statistics [ { "key": "BUFFERED", "description": "Readings currently in the Fledge buffer", "value": 0 }, ... { "key": "UNSNPURGED", "description": "Readings that were purged from the buffer before being sent", "value": 0 }, ... ] $ ``` -------------------------------- ### Example: Retrieve Fledge Statistics History with cURL Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/rest_api_guide/03_RESTstatistics Demonstrates how to use cURL to call the GET /fledge/statistics/history endpoint, requesting the 2 most recent entries. The example shows the full cURL command and the expected JSON response format, including historical timestamps and various statistic counts. ```Shell $ curl -s http://localhost:8081/fledge/statistics/history?limit=2 { "interval": 15, "statistics": [ { "history_ts": "2020-06-01 11:21:04.357", "READINGS": 0, "BUFFERED": 0, "UNSENT": 0, "PURGED": 0, "UNSNPURGED": 0, "DISCARDED": 0, "Readings Sent": 0 }, { "history_ts": "2020-06-01 11:20:48.740", "READINGS": 0, "BUFFERED": 0, "UNSENT": 0, "PURGED": 0, "UNSNPURGED": 0, "DISCARDED": 0, "Readings Sent": 0 } ] } $ ``` -------------------------------- ### Starting Fledge Core Services Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/building_fledge/04_utilities The `fledge start` command initiates the Fledge platform. It performs comprehensive checks for existing Fledge instances, environment variables (`FLEDGE_ROOT`, `FLEDGE_DATA`, `PYTHONPATH`), storage layer status, plugin availability, and metadata structure, creating it if necessary, before starting the core microservice. ```Shell fledge start ``` -------------------------------- ### Example: Retrieve Fledge Statistics Rates with cURL Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/rest_api_guide/03_RESTstatistics Demonstrates how to use cURL to call the GET /fledge/statistics/rate endpoint, requesting rates for 'READINGS' and 'Readings Sent' over 1, 5, 15, 30, and 60 minute periods. The example shows the full cURL command and the expected JSON response format with calculated rates. ```Shell $ curl -sX GET http://localhost:8081/fledge/statistics/rate?statistics=READINGS,Readings%20Sent\&periods=1,5,15,30,60 { "rates": { "READINGS": { "1": 2561.0, "5": 512.2, "15": 170.73333333333332, "30": 85.36666666666666, "60": 42.68333333333333 }, "Readings Sent": { "1": 2225.0, "5": 445.0, "15": 148.33333333333334, "30": 74.16666666666667, "60": 37.083333333333336 } } } ``` -------------------------------- ### Start Fledge System via Command Line Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/quick_start/starting This command initiates the Fledge IoT system. It is executed from the command line using the `fledge` utility located in `/usr/local/fledge/bin`. This specific command does not require authentication. ```Shell /usr/local/fledge/bin/fledge start ``` -------------------------------- ### Example: Retrieve Fledge Configuration Item (GET) Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/rest_api_guide/03_RESTadmin Illustrates how to use the 'curl' command-line tool to make a GET request to retrieve a Fledge configuration item. The example shows the request to 'httpsPort' within the 'rest_api' category and the expected JSON response payload. ```bash $ curl -X GET http://localhost:8081/fledge/category/rest_api/httpsPort { "description": "Port to accept HTTPS connections on", "type": "integer", "default": "1995", "displayName": "HTTPS Port", "order": "3", "validity": "enableHttp==\"false\"", "value": "1995" } ``` -------------------------------- ### Launch Fledge Service in GDB Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/plugin_developers_guide/10_testing These commands demonstrate how to prepare and launch a Fledge service within the GDB debugger. First, navigate to the FLEDGE_ROOT directory, then start GDB with the service executable, and finally execute the service with all necessary arguments, including the obtained startup token. ```bash cd $FLEDGE_ROOT gdb services/fledge.services.south ``` ```gdb run --port=39821 --address=127.0.0.1 --name=ServiceName -d --token=startupToken ``` -------------------------------- ### Example Implementation of Fledge South Plugin Write Entry Point Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/plugin_developers_guide/03_south_plugins This Python example provides a basic implementation of the `plugin_write` entry point for Fledge south plugins. It demonstrates logging the received `name` and `value` parameters and always returns `True`, indicating a successful write operation for demonstration purposes. ```Python def plugin_write(handle, name, value): """ Setpoint write operation Args: handle: handle returned by the plugin initialisation call name: Name of parameter to write value: Value to be written to that parameter Returns: bool: Result of the write operation """ _LOGGER.info("plugin_write(): name={}, value={}".format(name, value)) return True ``` -------------------------------- ### fogbench Command Line Arguments and Usage Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/building_fledge/06_testing This section provides the detailed command-line interface (CLI) documentation for the 'fogbench' tool, obtained by running it with the '--help' argument. It lists all available optional arguments, their short and long forms, descriptions, and default values, serving as a comprehensive reference for configuring 'fogbench' operations. ```APIDOC usage: fogbench [-h] [-v] [-k {y,yes,n,no}] -t TEMPLATE [-o OUTPUT] [-I ITERATIONS] [-O OCCURRENCES] [-H HOST] [-P PORT] [-i INTERVAL] [-S {total}] fogbench -- a Python script used to test Fledge (simulate payloads) optional arguments: -h, --help show this help message and exit -v, --version show program's version number and exit -k {y,yes,n,no}, --keep {y,yes,n,no} Do not delete the running sample (default: no) -t TEMPLATE, --template TEMPLATE Set the template file, json extension -o OUTPUT, --output OUTPUT Set the statistics output file -I ITERATIONS, --iterations ITERATIONS The number of iterations of the test (default: 1) -O OCCURRENCES, --occurrences OCCURRENCES The number of occurrences of the template (default: 1) -H HOST, --host HOST CoAP server host address (default: localhost) -P PORT, --port PORT The Fledge port. (default: 5683) -i INTERVAL, --interval INTERVAL The interval in seconds for each iteration (default: 0) -S {total}, --statistics {total} The type of statistics to collect (default: total) The initial version of fogbench is meant to test the sensor/device interface of Fledge using CoAP $ ``` -------------------------------- ### Example: Retrieve Fledge Audit Trail Entries with cURL Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/rest_api_guide/03_RESTadmin Provides cURL examples demonstrating how to query the `GET /fledge/audit` endpoint. Examples include limiting results and filtering by source, showing the expected JSON response. ```Shell $ curl -s http://localhost:8081/fledge/audit?limit=2 { "totalCount" : 24, "audit" : [ { "timestamp" : "2018-02-25 18:58:07.748", "source" : "SRVRG", "details" : { "name" : "COAP" }, "severity" : "INFORMATION" }, { "timestamp" : "2018-02-25 18:58:07.742", "source" : "SRVRG", "details" : { "name" : "HTTP_SOUTH" }, "severity" : "INFORMATION" }, { "timestamp" : "2018-02-25 18:58:07.390", "source" : "START", "details" : {}, "severity" : "INFORMATION" } ] } $ curl -s http://localhost:8081/fledge/audit?source=SRVUN&limit=1 { "totalCount" : 4, "audit" : [ { "timestamp" : "2018-02-25 05:22:11.053", "source" : "SRVUN", "details" : { "name": "COAP" }, "severity" : "INFORMATION" } ] } $ ``` -------------------------------- ### API Reference: GET /fledge/statistics Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/rest_api_guide/03_RESTstatistics Documents the Fledge REST API endpoint for retrieving general statistics. This endpoint returns a JSON array of objects, where each object contains a 'key', 'description', and 'value' representing an absolute count since Fledge started. It also details the various fixed and dynamic statistics keys that can be expected in the response. ```APIDOC GET /fledge/statistics Description: Return a general set of statistics. Response Payload: A JSON document with statistical information (all numerical), these statistics are absolute counts since Fledge started. The response is a JSON array of objects, each with: - "key": string (e.g., "BUFFERED", "READINGS") - "description": string (description of the statistic) - "value": number (absolute count since Fledge started) Known Statistics Keys: - BUFFERED: Readings currently in the Fledge buffer - DISCARDED: Readings discarded by the South Service before being placed in the buffer. This may be due to an error in the readings themselves. - PURGED: Readings removed from the buffer by the purge process - READINGS: Readings received by Fledge - UNSENT: Readings filtered out in the send process - UNSNPURGED: Readings that were purged from the buffer before being sent - One statistic per north service or task that is named the same as the service or task name. This will count the number of readings sent out on that service. - One statistic per asset that is named the same as the asset. This will be the number of readings that have been ingested for that asset. - One statistics per south service, that is named with the service name and '-Ingest' appended. This is the count of readings read in for that service. ``` -------------------------------- ### Copy Fledge Service Script to Init.d Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/building_fledge/04_installation Copies the `fledge.service` script from the Fledge installation directory to `/etc/init.d/fledge`, preparing it for system service management. This step is necessary to register Fledge as a Linux service. ```bash $ sudo cp /usr/local/fledge/extras/scripts/fledge.service /etc/init.d/fledge ``` -------------------------------- ### Install a New Fledge Service Type from Repository Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/rest_api_guide/03_RESTservices This API call uses a POST request to initiate the installation of a specified service type from the Fledge package repository. The `action=install` parameter and a JSON payload with `format` and `name` are required. A configured and accessible package repository is a prerequisite for successful installation. ```shell $ curl -X POST http://localhost:8081/fledge/service?action=install -d'{"format":"repository", "name": "fledge-service-notification"}' ``` -------------------------------- ### Fledge Ping Endpoint JSON Response Example Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/rest_api_guide/06_GrafanaExamples This JSON payload is an example of the response returned by the 'GET /fledge/ping' endpoint. It provides key metrics and status indicators for the Fledge instance, including data counters, service name, hostname, IP addresses, and health status. ```JSON { "uptime": 13203, "dataRead": 2045868, "dataSent": 6700, "dataPurged": 1293723, "authenticationOptional": true, "serviceName": "Fledge", "hostName": "foglamp-18, "ipAddresses": [ "192.168.0.172" ], "health": "green", "safeMode": false, "version": "1.9.2" } ``` -------------------------------- ### Fledge Package Building Workflow Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/plugin_developers_guide/09_packaging This snippet outlines the command-line steps required to build a Fledge package. It involves navigating to the plugins directory, executing a `make_deb` script with specified branch and repository names, and then listing the contents of the 'archive' directory where the generated package will reside. ```bash cd plugins ./make_deb -b if everything goes well with above command then you can find your package inside archive directory. ls archive ``` -------------------------------- ### Install Adafruit DHT Library for Fledge DHT11 Plugin Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/plugin_developers_guide/03_south_plugins Instructions to install the Adafruit DHT Python library, a prerequisite for the Fledge DHT11 sensor plugin. This involves cloning the repository, installing build dependencies, and running the setup script. Ensure Fledge has appropriate access to /dev/gpiomem. ```bash git clone https://github.com/adafruit/Adafruit_Python_DHT.git cd Adafruit_Python_DHT sudo apt-get install build-essential python-dev sudo python setup.py install ``` -------------------------------- ### Curl Examples: Get Single Asset Reading Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/rest_api_guide/04_RESTuser Practical examples demonstrating how to use `curl` to fetch single asset readings from the Fledge IoT API, including basic retrieval and applying a limit to the number of results. ```bash $ curl -sX GET http://localhost:8081/fledge/asset/asset_2/lux [ {"timestamp": "2023-04-14 12:04:34.603937", "lux": 47705.68}, {"timestamp": "2023-04-14 12:02:39.150106", "lux": 97967.9}, {"timestamp": "2023-04-14 12:02:26.616200", "lux": 28788.154}, {"timestamp": "2023-04-14 12:02:11.171319", "lux": 57992.674}, {"timestamp": "2023-04-14 12:01:56.979407", "lux": 10373.945} ] $ ``` ```bash $ curl -sX GET http://localhost:8081/fledge/asset/asset_2/lux?limit=3 [ {"timestamp": "2023-04-14 11:25:05.672528", "lux": 75723.923}, {"timestamp": "2023-04-14 11:24:49.767983", "lux": 50475.99}, {"timestamp": "2023-04-14 11:23:15.672528", "lux": 75723.923} ] $ ``` -------------------------------- ### Verify Fledge Plugin Installation via API Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/plugin_developers_guide/10_testing This snippet demonstrates how to use the Fledge API to list all installed plugins. It includes the `curl` command to query the `/fledge/plugins/installed` endpoint and the expected JSON response structure, which details each plugin's name, type, description, version, and package information. The `jq` utility is used to format the JSON output for readability. ```Shell $ curl http://localhost:8081/fledge/plugins/installed | jq ``` ```APIDOC { "plugins": [ { "name": "http_north", "type": "north", "description": "HTTP North Plugin", "version": "2.2.0", "installedDirectory": "north/http_north", "packageName": "fledge-north-http-north" }, { "name": "Kafka", "type": "north", "description": "Simple plugin to send data to Kafka topic", "version": "2.2.0", "installedDirectory": "north/Kafka", "packageName": "fledge-north-kafka" }, ... } ``` -------------------------------- ### Install and Configure PostgreSQL 13 on Red Hat Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/storage Details the process of installing PostgreSQL 13 on Red Hat or yum-based distributions. This includes adding the official PostgreSQL YUM repository, searching for available packages, installing the server, initializing the database, and managing the service to start on boot and verify its status. ```bash sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-x86_64/pgdg-redhat-repo-latest.noarch.rpm ``` ```bash sudo yum search -y postgresql13 ``` ```bash sudo yum install -y postgresql13 postgresql13-server ``` ```bash sudo /usr/pgsql-13/bin/postgresql-13-setup initdb ``` ```bash sudo systemctl enable --now postgresql-13 ``` ```bash sudo systemctl status postgresql-13 ``` -------------------------------- ### Prepare Build Directory and Run CMake Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/plugin_developers_guide/03_south_C_plugins Navigates into the cloned 'fledge-south-dht' repository, creates a 'build' directory, changes into it, and then runs 'cmake ..' to configure the build system for the plugin. This prepares the project for compilation based on the system's environment. ```bash cd ~/fledge-south-dht mkdir build cd build cmake .. ``` -------------------------------- ### Remove Fledge Installation Directory Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/quick_start/uninstalling After uninstalling the Fledge package, the installation directory, typically `/usr/local/fledge`, might remain if it contains data. This command forcibly removes the entire directory and its contents, ensuring a complete cleanup of Fledge files. ```bash rm -rf /usr/local/fledge ``` -------------------------------- ### Example Fledge IoT Plugin Operation Entry Point Implementation Source: https://fledge-iot.readthedocs.io/en/latest/introduction.html/plugin_developers_guide/03_south_C_plugins Illustrates a basic C/C++ implementation of the `plugin_operation` entry point. It demonstrates casting the `PLUGIN_HANDLE` to a custom class instance (`Random`) and delegating the actual operation logic to a method within that class, showcasing a common design pattern for plugin writers. ```C++ bool plugin_operation(PLUGIN_HANDLE *handle, string& operation, int count, PLUGIN_PARAMETER **params) { Random *random = (Random *)handle; return random->operation(operation, count, params); } ```