This repository provides a comprehensive solution for the monitoring of IoT devices. With this software, users can integrate sensors and monitor the status, performance, and any anomalies. The system continuously collects data from the connected devices and analyzes it to determine if they are functioning correctly or if potential problems might arise. Upon detecting unusual activities or when device parameters fall outside the established normal range, alarms are immediately triggered. These alerts can be relayed through various channels such as email, or alerting through the DEC112 ESInet. The repository includes both the code for data collection and analysis, as well as a user-friendly interface for configuring monitoring settings and alarm conditions. The aim of this project is to provide a robust and scalable solution to ensure the efficiency and security of IoT networks.
Content:
- Project description: https://www.netidee.at/dec4iot
- Semantic Container: https://github.com/OwnYourData/semcon
- Blogpost on Monitoring (in German): https://www.netidee.at/dec4iot/system-monitoring-fuer-dec4iot
A pre-built Docker image oydeu/dc-iot
is available on Dockerhub and can be started locally with the following command:
docker run -d --name iot -p 8080:3000 oydeu/dc-iot:latest
YAML files for deployment on kubernetes are available here.
To provide certificates necessary for connecting to the NG112 alerting you can use the following commands (assuming credentials available in creds/
:
kubectl create configmap fullchain-config --from-file=creds/fullchain.pem
kubectl create configmap privkey-config --from-file=creds/privkey.pem
Data container backend:
DC_DB
: type of database; available options:local
for internal SQLite,postgres
for connection to local PostgreSQL instance,kubernetes
for high-availability PostgreSQL clusterDB_HOST
: hostname of DBDB_NAME
: name of databaseDB_USER
: user for connecting to databasePOSTGRES_PASSWORD
: password for connecting to database
Sending emails:
SMTP_HOST
: hostname or IP address of the SMTP server used for sending emailSMTP_DOMAIN
: domain name used for identifying the sending domain during email transmission via the SMTP serverSMTP_USER
: username required for authenticating with the SMTP server when sending emailSMTP_PASSWORD
: password required for authenticating with the SMTP server when sending emailFROM_MAIL
: mail address to be shown as sender
trigger NG112 alerts:
PSAP_URL
: address to send NG112 alerts to (example: `https://app.test.dec112.eu:8081/api/v1/update/dec4iot-test)FULLCHAIN
: full chain of certificates, including the server certificate followed by any intermediate certificates, required to establish a secure connection to a servicePRIVKEY
: private key associated with the server certificate, used to securely connect to and authenticate with a service
The following code assumes a deployed and configured instance of oydeu/dc-iot
on https://dec4iot.data-container.net.
- Manage sensors on
HOST/sensors
https://dec4iot.data-container.net/sensors - Create new sensors on
HOST/sensors/new
https://dec4iot.data-container.net/sensors/new - Enter sensor data:
- Identifier: default is record ID, max. 4 characters
example:
1
- Service endpoint: information for the sensor about where data should be sent, max. 15 characters
example:
dec112.at/iot
(forwards to: https://dec4iot.data-container.net/api/data) - Additional information: additional information that can be used when triggering events (e.g., floor), format: JSON
example:
{ "info": "Bangle.js 9075", "target": "police", "location": { "city": "Bad Vöslau", "zip": "2540", "street": "Michael Scherz-Straße", "number": "14" } }
- Identifier: default is record ID, max. 4 characters
example:
- Link sensor: scan QR-code to initialize and link sensor example: https://dec4iot.data-container.net/sensors/37
Assumptions:
- sensor with
identifier: 5
configured (record) - monitoring for low battery alarm configured
https://dec4iot.data-container.net/api/data?id=49071{ "base": "batt$", "base_name": "batt", "title": "Batterie Warnung", "attribute": "v", "operator": "<=", "value": "20", "trigger": "email", "trigger-options": { "to": "christoph.fabianek@gmail.com", "body": "{{n}} ist unter 20% (aktuell: {{v}})", "title": "E-Mail zu niedrigem Batteriestand", "subject": "Niedriger Batteriestand" } }
Command to create a new monitoring record
echo '{"title":"titel",
"base":"batt$",
"base_name":"batt",
"attribute":"v",
"operator": "<=",
"value":"20",
"trigger":"email",
"trigger-options": {
"title":"Low battery warning email",
"to":"user@host.com",
"subject":"Low battery",
"body":"{{n}} ist unter 20% (aktuell: {{v}})"},
"meta": {"schema":"IoT_Monitoring",
"processed":true}}' | \
curl -H 'Content-Type: application/json' -d @- \
-X POST https://dec4iot.data-container.net/api/data
SOyA structure for IoT_Monitoring
: https://soya.ownyourdata.eu/IoT_Monitoring/yaml
Sequence:
-
Sensor sends record
relevant:{"n":"batt","u":"%EL","v":19}
Command
echo '[{"n":"identifier","v":5,"bn":"urn:dev:mac:fb518cffff5b9075","bt":1685286440},{"n":"batt","u":"%EL","v":19},{"n":"heading","v":183.53101568878},{"n":"temperature","v":33.05662536621},{"n":"pressure","u":"hPa","v":973.95376105848},{"n":"altitude","u":"m","v":332.42848559087},{"n":"steps","u":"counter","v":21},{"n":"manually_triggered","vb":true}]' | \ curl -H "Content-Type: application/json" -d @- \ -X POST https://dec4iot.data-container.net/api/data
-
Record is stored
https://dec4iot.data-container.net/api/data?id=57377 -
Data (SenML encoded) is split up into components:
(meta data referencessource-id
)- Sensor Identifier (
v:5
): https://dec4iot.data-container.net/api/data?id=57378 - Battery: https://dec4iot.data-container.net/api/data?id=57379
- Heading: https://dec4iot.data-container.net/api/data?id=57381
- Temperature: https://dec4iot.data-container.net/api/data?id=57382
- Pressure: https://dec4iot.data-container.net/api/data?id=57383
- Altitude: https://dec4iot.data-container.net/api/data?id=57384
- Steps: https://dec4iot.data-container.net/api/data?id=57385
- Button pressed: https://dec4iot.data-container.net/api/data?id=57386
- Sensor Identifier (
-
Monitoring generates an event record for falling below the battery threshold value and sends email
https://dec4iot.data-container.net/api/data?id=57380
Assumptions:
- sensor with
identifier: 5
configured (record) - Monitoring configured for "press button"
https://dec4iot.data-container.net/api/data?id=49071{ "base": "manually_triggered$", "base_name": "manually_triggered", "title": "Notruftaste", "attribute": "vb", "value": "true", "operator": "==", "trigger": "dec112sdk", "trigger-options": { "title": "DEC112 Notruf via SDK", "target": "{{#if sensor.target}}{{sensor.target}}{{else}}ambulance{{/if}}", "callId": "{{meta.dri}}", "sensorId": "{{n}}", "language": "de-at", "category": "{{#if sensor.category}}{{sensor.category}}{{else}}health{{/if}}", "event": "Notruftaste auf IoT Sensor", "contact": "Demosetup OwnYourData, Tel: 0677 617 53 112", "web": "https://www.ownyourdata.eu/de/impressum/", "headline": "Notruf durch IoT Sensor", "locations": [{ "type": "Manual", "civic": { "street": "Michael Scherz-Straße", "houseNumber": "14", "floor": "", "postalCode": "2540", "city": "Bad Vöslau" } }] } }
Sequence:
-
Sensor sends record
relevant:{"n":"manually_triggered","vb":true}
Command - Sensor 5
echo '[{"n":"identifier","v":5,"bn":"urn:dev:mac:fb518cffff5b9075","bt":1685286440},{"n":"batt","u":"%EL","v":19},{"n":"heading","v":183.53101568878},{"n":"temperature","v":33.05662536621},{"n":"pressure","u":"hPa","v":973.95376105848},{"n":"altitude","u":"m","v":332.42848559087},{"n":"steps","u":"counter","v":21},{"n":"manually_triggered","vb":true}]' | \ curl -H "Content-Type: application/json" -d @- \ -X POST https://dec4iot.data-container.net/api/data
Command - Sensor 6
echo '[{"n":"identifier","v":6,"bn":"urn:dev:mac:fb518cffff5b9075","bt":1696077022},{"n":"batt","u":"%EL","v":39},{"n":"heading","v":129.52263127117},{"n":"temperature","v":33.32276407877},{"n":"pressure","u":"hPa","v":981.2715188464},{"n":"altitude","u":"m","v":269.71078897221},{"n":"steps","u":"counter","v":0},{"n":"manually_triggered","vb":true}]' | \ curl -H "Content-Type: application/json" -d @- \ -X POST https://dec4iot.data-container.net/api/data
-
Record is stored
https://dec4iot.data-container.net/api/data?id=57377 -
Data (SenML encoded) is split up into components:
(meta data referencessource-id
)- Button pressed: https://dec4iot.data-container.net/api/data?id=57386
-
Monitoring generates an event record
https://dec4iot.data-container.net/api/data?id=57387 -
Validate on DEC112 webclient: URL: https://psap.test.dec112.eu/ Server:
wss://psap.test.dec112.eu:8091/api/v1
Please report bugs and suggestions for new features using the GitHub Issue-Tracker and follow the Contributor Guidelines.
If you want to contribute, please follow these steps:
- Fork it!
- Create a feature branch:
git checkout -b my-new-feature
- Commit changes:
git commit -am 'Add some feature'
- Push into branch:
git push origin my-new-feature
- Send a Pull Request
This project has received funding from Netidee Call 17.