Beispiel #1
0
    mem_used = f"{get_size(svmem.used)}"
    mem_per = f"{svmem.percent}%"
    swap_total = f"{get_size(swap.total)}"
    swap_free = f"{get_size(swap.free)}"
    swap_used = f"{get_size(swap.used)}"
    swap_percentage = f"{svmem.percent}%"
    mqtt.publish("mem_info", mem_total)
    mqtt.publish("mem_info", mem_available)
    mqtt.publish("mem_info", mem_used)
    mqtt.publish("mem_info", mem_per)
    mqtt.publish("mem_info", swap_total)
    mqtt.publish("mem_info", swap_free)
    mqtt.publish("mem_info", swap_used)
    mqtt.publish("mem_info", swap_percentage)

    code = mySystem.Service("createMemoryCollection")
    params = {
        "item": {
            "memory_total": mem_total,
            "memory_available": mem_available,
            "memory_used": mem_used,
            "memory_percentage": mem_per,
            "swap_memory_total": swap_total,
            "swap_memory_free": swap_free,
            "swap_memory_used": swap_used,
            "swap_memory_percentage": swap_percentage
        }
    }
    code.execute(boren, params)
    time.sleep(1)
from clearblade.Messaging import Messaging
from paho.mqtt.client import Client, MQTT_ERR_QUEUE_SIZE
from clearblade.ClearBladeCore import System, Query, Developer
SystemKey = "d4bfc0890cc2f4d0e6fc8189b722"
SystemSecret = "D4BFC0890CC49DA6D69EA590D8D701"

mySystem = System(SystemKey, SystemSecret)
email = "*****@*****.**"
password = "******"

sidd = mySystem.User(email, password)

sidd = mySystem.Service("PCSystem")

params = {"Bluetooth": "Jabra"}

mqtt = mySystem.Messaging(sidd)


def on_connect(client, userdata, flags, rc):
    # When we connect to the broker, subscribe to the southernplayalisticadillacmuzik topic
    client.subscribe("PCSystems")


mqtt.on_connect = on_connect
mqtt.connect()

sidd2 = Developer(email, password)

sidd.execute(sidd2, params)