Skip to content

thin-edge.io community plugin to support publishing inventory data using a simple script based interface

Notifications You must be signed in to change notification settings

thin-edge/tedge-inventory-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tedge-inventory-plugin

Plugin summary

Publish inventory data about a device on startup using a simply shell scripts.

The package includes some default inventory scripts, and allows users to add their own scripts into the folder for execution on device startup.

Inventory script which are in the folder below will be executed when the service starts, and the Standard Output will be parsed and the output converted to a MQTT message (one message per script).

/usr/share/tedge-inventory/scripts.d/

The name of the script is used to control the execution order, and the type where the digital twin information will be published under (keep reading for the example).

XX_<propertyName>

Where XX 2 digit 0-padded number between 00 and 99, to determine its execution order.

Example inventory script

An example script is shown below which adds multiple properties to the the info property on the digital twin

file: /usr/share/tedge-inventory/scripts.d/00_info

#!/bin/sh
printf 'mymetric="%s"\n' "some string value"
echo "another_value=1"
echo "nested={\"values\":\"ok\"}"

The above inventory script will result in the following MQTT message being published:

Topic (retained=True, qos=1)

te/device/main///twin/info

Payload

{"mymetric":"some string value","another_value":1,"nested":{"values":"ok"}}

Notes

  • For security reasons, scripts MUST have 0755 permissions otherwise they will be ignored.

Technical summary

The following details the technical aspects of the plugin to get an idea what systems it supports.

Languages shell (posix compatible)
CPU Architectures all/noarch. Not CPU specific
Supported init systems systemd and sysvinit
Required Dependencies -
Optional Dependencies (feature specific) -

How to do I get it?

The following linux package formats are provided on the releases page and also in the tedge-community repository:

Operating System Repository link
Debian/Raspbian (deb) Latest version of 'tedge-inventory-plugin' @ Cloudsmith
Alpine Linux (apk) Latest version of 'tedge-inventory-plugin' @ Cloudsmith
RHEL/CentOS/Fedora (rpm) Latest version of 'tedge-inventory-plugin' @ Cloudsmith

What will be deployed to the device?

  • The following service will be installed
    • tedge-inventory (service and timer) (triggered 30 seconds after boot up and then periodically every 60 mins)
    • Two inventory scripts to collect information about the hardware and operating system
    • Folder where custom inventory scripts can be added and included in the execution (see below for details)

Plugin Dependencies

The following packages are required to use the plugin:

  • tedge

Development

Start demo

  1. Start the demo

    just up && just bootstrap

The systemd tedge-inventory.timer task will trigger automatically on startup and periodically every hour (based on start time). It can be triggered asynchronously by exeucting:

systemctl start tedge-inventory.timer

Stop demo

just down