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.
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) | - |
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) | |
Alpine Linux (apk) | |
RHEL/CentOS/Fedora (rpm) |
- 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)
The following packages are required to use the plugin:
- tedge
-
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
just down