Skip to main content

Thingsboard Device

Upload von Systeminformationen zu einem Thingsboard IoT Device:

 

#!/bin/bash
# This script monitors CPU and memory usage

thingsboardAccessToken='kG..........Lj'

while :
do
  # Get the current usage of CPU and memory
  cpuUsage=$(top -bn1 | awk '/Cpu/ { print $2}')
  memUsage=$(free -m | awk '/Mem/{print $3}')

  # Print the usage
  echo "CPU Usage: $cpuUsage%"
  echo "Memory Usage: $memUsage MB"

  curl -v -X POST -d "{\"Memory\": $memUsage}" https://thingsboard.cloud/api/v1/$thingsboardAccessToken/telemetry --header "Content-Type:application/json"
  curl -v -X POST -d "{\"CPU\": $cpuUsage}" https://thingsboard.cloud/api/v1/$thingsboardAccessToken/telemetry --header "Content-Type:application/json"
  
  sleep 10
done