# create a System object encapsulating the particulars of a IoT System
        # argument is the name of this IoT System
        edge_system = Dell5KEdgeSystem(config['EdgeSystemName'])

        # resister the IoT System with the graphite instance
        # this call creates a representation (a Resource) in graphite for this IoT System with the name given
        reg_edge_system = graphite.register(edge_system)

        # Operational metrics of EdgeSystem
        cpu_utilization_metric = Metric(name="windmill.CPU_Utilization",
                                        unit=None,
                                        interval=10,
                                        aggregation_size=2,
                                        sampling_function=read_cpu_utilization)
        reg_cpu_utilization_metric = graphite.register(cpu_utilization_metric)
        graphite.create_relationship(reg_edge_system,
                                     reg_cpu_utilization_metric)
        # call to start collecting values from the device or system and sending to the data center component
        reg_cpu_utilization_metric.start_collecting()

        cpu_procs_metric = Metric(name="windmill.CPU_Process",
                                  unit=None,
                                  interval=6,
                                  aggregation_size=8,
                                  sampling_function=read_cpu_procs)
        reg_cpu_procs_metric = graphite.register(cpu_procs_metric)
        graphite.create_relationship(reg_edge_system, reg_cpu_procs_metric)
        reg_cpu_procs_metric.start_collecting()

        mem_free_metric = Metric(name="windmill.Memory_Free",
                                 unit=None,
                                 interval=10,
            name="Swap Memory Free",
            unit=None,
            interval=8,
            aggregation_size=5,
            sampling_function=read_swap_mem_free
        )
        reg_swap_mem_free_metric = iotcc.register(swap_mem_free_metric)
        iotcc.create_relationship(reg_ram_device, reg_swap_mem_free_metric)
        reg_swap_mem_free_metric.start_collecting()

    except RegistrationFailure:
        print "Registration to IOTCC failed"

    # Multiple DCC support
    # Sending data to an alternate data center component (e.g. data lake for analytics)
    # Graphite is a data center component
    # Socket is the transport which the agent uses to connect to the graphite instance
    graphite = Graphite(SocketDccComms(ip=config['GraphiteIP'],
                               port=config['GraphitePort']))
    graphite_reg_edge_system = graphite.register(edge_system)
    simulated_metric = Metric(
        name="edge.simulated.metric",
        unit=None,
        interval=10,
        aggregation_size=5,
        sampling_function=simulated_value
    )
    reg_simulated_metric = graphite.register(simulated_metric)
    graphite.create_relationship(graphite_reg_edge_system, reg_simulated_metric)
    reg_simulated_metric.start_collecting()
示例#3
0
    return round((100 - cpu_pcts['idle']), 2)

# ---------------------------------------------------------------------------
# In this example, we demonstrate how a Dell5000 Gateway metric (e.g.,
# CPU utilization) can be directed to graphite data center component
# using Liota. The program illustrates the ease of use Liota brings
# to IoT application developers.

if __name__ == '__main__':

    edge_system = Dell5KEdgeSystem(config['EdgeSystemName'])

    # Sending data to Graphite data center component
    # Socket is the underlying transport used to connect to the Graphite
    # instance
    graphite = Graphite(SocketDccComms(ip=config['GraphiteIP'],
                               port=config['GraphitePort']))
    graphite_reg_edge_system = graphite.register(edge_system)

    metric_name = config['MetricName']
    cpu_utilization = Metric(
        name=metric_name,
        unit=None,
        interval=10,
        aggregation_size=2,
        sampling_function=read_cpu_utilization
    )
    reg_cpu_utilization = graphite.register(cpu_utilization)
    graphite.create_relationship(graphite_reg_edge_system, reg_cpu_utilization)
    reg_cpu_utilization.start_collecting()
示例#4
0

def udm1():
    return comms_channel.get(block=True)


#---------------------------------------------------------------------------
# In this example, we demonstrate how an event stream of data can be directed to graphite
# data center component using Liota by setting sampling_interval_sec parameter to zero.

if __name__ == '__main__':

    edge_system = Dk300EdgeSystem(config['EdgeSystemName'])

    # Sending data to Graphite data center component
    # Socket is the underlying transport used to connect to the Graphite
    # instance
    graphite = Graphite(
        SocketDccComms(ip=config['GraphiteIP'], port=config['GraphitePort']))
    graphite_reg_edge_system = graphite.register(edge_system)

    metric_name = config['MetricName']
    content_metric = Metric(name=metric_name,
                            unit=None,
                            interval=0,
                            aggregation_size=6,
                            sampling_function=udm1)
    reg_content_metric = graphite.register(content_metric)
    graphite.create_relationship(graphite_reg_edge_system, reg_content_metric)
    reg_content_metric.start_collecting()
示例#5
0
# In this example, we demonstrate how data from a simulated device generating
# random physical variables can be directed to graphite data center component
# using Liota.

if __name__ == '__main__':

    edge_system = Dell5KEdgeSystem(config['EdgeSystemName'])

    # initialize and run the physical model (simulated device)
    thermistor_model = ThermistorSimulated(name=config['DeviceName'], ureg=ureg)

    # Sending data to a data center component
    # Graphite is a data center component
    # Socket is the transport which the agent uses to connect to the graphite
    # instance
    graphite = Graphite(SocketDccComms(ip=config['GraphiteIP'],
                               port=config['GraphitePort']))

    graphite_reg_dev = graphite.register(thermistor_model)

    metric_name = "model.thermistor.temperature"
    thermistor_temper = Metric(
        name=metric_name,
        unit=ureg.degC,
        interval=5,
        sampling_function=get_thermistor_temperature
    )
    reg_thermistor_temper = graphite.register(thermistor_temper)
    graphite.create_relationship(graphite_reg_dev, reg_thermistor_temper)
    reg_thermistor_temper.start_collecting()
    return round((100 - cpu_pcts['idle']), 2)

# ---------------------------------------------------------------------------
# In this example, we demonstrate how a Dell5000 Gateway metric (e.g.,
# CPU utilization) can be directed to graphite data center component
# using Liota. The program illustrates the ease of use Liota brings
# to IoT application developers.

if __name__ == '__main__':

    edge_system = Dell5KEdgeSystem(config['EdgeSystemName'])

    # Sending data to Graphite data center component
    # Socket is the underlying transport used to connect to the Graphite
    # instance
    graphite = Graphite(SocketDccComms(ip=config['GraphiteIP'],
                               port=config['GraphitePort']))
    graphite_reg_edge_system = graphite.register(edge_system)

    metric_name = config['MetricName']
    cpu_utilization = Metric(
        name=metric_name,
        unit=None,
        interval=10,
        aggregation_size=2,
        sampling_function=read_cpu_utilization
    )
    reg_cpu_utilization = graphite.register(cpu_utilization)
    graphite.create_relationship(graphite_reg_edge_system, reg_cpu_utilization)
    reg_cpu_utilization.start_collecting()
# In this example, we demonstrate how data from a simulated device generating
# random physical variables can be directed to graphite data center component
# using Liota.

if __name__ == '__main__':

    edge_system = Dell5KEdgeSystem(config['EdgeSystemName'])

    # initialize and run the physical model (simulated device)
    thermistor_model = ThermistorSimulated(name=config['DeviceName'], ureg=ureg)

    # Sending data to a data center component
    # Graphite is a data center component
    # Socket is the transport which the agent uses to connect to the graphite
    # instance
    graphite = Graphite(SocketDccComms(ip=config['GraphiteIP'],
                               port=config['GraphitePort']))

    graphite_reg_dev = graphite.register(thermistor_model)

    metric_name = "model.thermistor.temperature"
    thermistor_temper = Metric(
        name=metric_name,
        unit=ureg.degC,
        interval=5,
        sampling_function=get_thermistor_temperature
    )
    reg_thermistor_temper = graphite.register(thermistor_temper)
    graphite.create_relationship(graphite_reg_dev, reg_thermistor_temper)
    reg_thermistor_temper.start_collecting()
示例#8
0
    edge_system = Dell5KEdgeSystem(config['EdgeSystemName'])

    # initialize and run the physical model (simulated device)
    bike_model = BikeSimulated(name=config['DeviceName'], ureg=ureg)

    # Sending data to Graphite data center component
    # Socket is the underlying transport used to connect to the Graphite
    # instance
    graphite = Graphite(
        SocketDccComms(ip=config['GraphiteIP'], port=config['GraphitePort']))
    graphite_reg_dev = graphite.register(bike_model)

    metric_name = "model.bike.speed"
    bike_speed = Metric(name=metric_name,
                        unit=(ureg.m / ureg.sec),
                        interval=5,
                        sampling_function=get_bike_speed)
    reg_bike_speed = graphite.register(bike_speed)
    graphite.create_relationship(graphite_reg_dev, reg_bike_speed)
    reg_bike_speed.start_collecting()

    metric_name = "model.bike.power"
    bike_power = Metric(name=metric_name,
                        unit=ureg.watt,
                        interval=5,
                        sampling_function=get_bike_power)
    reg_bike_power = graphite.register(bike_power)
    graphite.create_relationship(graphite_reg_dev, reg_bike_power)
    reg_bike_power.start_collecting()
    edge_system = SimulatedEdgeSystem(config['EdgeSystemName'])

    # Sending data to Graphite data center component
    # Socket is the underlying transport used to connect to the Graphite
    # instance
    graphite = Graphite(Socket(ip=config['GraphiteIP'],
                               port=config['GraphitePort']))
    graphite_reg_edge_system = graphite.register(edge_system)

    # A simple simulated metric which generates metric value every 10 seconds
    simple_metric_name = config['MetricName']
    simple_metric = Metric(name=simple_metric_name, interval=10,
                              sampling_function=simulated_value_sampling_function)
    reg_simple_metric = graphite.register(simple_metric)
    graphite.create_relationship(graphite_reg_edge_system, reg_simple_metric)
    reg_simple_metric.start_collecting()

    # A simulated metric producing sample value along with timestamp when the sample was generated
    metric_with_own_ts_name = config['MetricWithOwnTsName']
    metric_with_own_ts = Metric(name=metric_with_own_ts_name, interval=10,
                              sampling_function=simulated_timestamp_value_sampling_function)
    reg_metric_with_own_ts = graphite.register(metric_with_own_ts)
    graphite.create_relationship(graphite_reg_edge_system, reg_metric_with_own_ts)
    reg_metric_with_own_ts.start_collecting()

    # A simulated metric producing a list of sample values along with their timestamps in the last polling interval
    bulk_collected_metric_name = config['BulkCollectedMetricName']
    bulk_collected_metric = Metric(name=bulk_collected_metric_name, interval=30,
                              aggregation_size=10, sampling_function=simulated_list_of_timestamps_values_sampling_function)
    reg_bulk_collected_metric = graphite.register(bulk_collected_metric)
示例#10
0
    bike_model = BikeSimulated(name=config['DeviceName'], ureg=ureg)

    # Sending data to Graphite data center component
    # Socket is the underlying transport used to connect to the Graphite
    # instance
    graphite = Graphite(Socket(ip=config['GraphiteIP'],
                               port=config['GraphitePort']))
    graphite_reg_dev = graphite.register(bike_model)

    metric_name = "model.bike.speed"
    bike_speed = Metric(
        name=metric_name,
        unit=(ureg.m / ureg.sec),
        interval=5,
        sampling_function=get_bike_speed
    )
    reg_bike_speed = graphite.register(bike_speed)
    graphite.create_relationship(graphite_reg_dev, reg_bike_speed)
    reg_bike_speed.start_collecting()

    metric_name = "model.bike.power"
    bike_power = Metric(
        name=metric_name,
        unit=ureg.watt,
        interval=5,
        sampling_function=get_bike_power
    )
    reg_bike_power = graphite.register(bike_power)
    graphite.create_relationship(graphite_reg_dev, reg_bike_power)
    reg_bike_power.start_collecting()
示例#11
0

def on_message(client, data, msg):
    d = eval(msg.payload)
    print(d)


# getting values from conf file
config = {}
execfile('sampleProp.conf', config)

if __name__ == '__main__':
    edge_system = Dell5KEdgeSystem(config['EdgeSystemName'])
    graphite = Graphite(
        SocketDccComms(ip=config['GraphiteIP'], port=config['GraphitePort']))
    graphite_reg_dev = graphite.register(edge_system)
    mqtt = MqttDeviceComms(url="test.mosquitto.org",
                           port=1883,
                           clean_session=True,
                           conn_disconn_timeout=1000)
    print('Connection to broker established...')
    mqtt.subscribe("random_data", callback=on_message, qos=2)
    print('Subscribed to random_data')
    metric_name = "model.device_data"
    random_metric = Metric(name=metric_name,
                           interval=5,
                           sampling_function=random_function)
    reg_metric = graphite.register(random_metric)
    graphite.create_relationship(graphite_reg_dev, reg_metric)
    reg_metric.start_collecting()
示例#12
0
    edge_system = RaspberrypiEdgeSystem(config['EdgeSystemName'])

    # Sending data to Graphite data center component
    # Socket is the underlying transport used to connect to the Graphite
    # instance
    graphite = Graphite(
        SocketDccComms(ip=config['GraphiteIP'], port=config['GraphitePort']))

    graphite_reg_edge_system = graphite.register(edge_system)

    metric_name_t = config['MetricName_temperature']
    temperature = Metric(name=metric_name_t,
                         interval=3,
                         sampling_function=get_temperature)
    reg_temperature = graphite.register(temperature)
    graphite.create_relationship(graphite_reg_edge_system, reg_temperature)
    reg_temperature.start_collecting()

    metric_name_p = config['MetricName_pressure']
    pressure = Metric(name=metric_name_p,
                      interval=3,
                      sampling_function=get_pressure)

    reg_pressure = graphite.register(pressure)
    graphite.create_relationship(graphite_reg_edge_system, reg_pressure)
    reg_pressure.start_collecting()

    metric_name_h = config['MetricName_humidity']
    humidity = Metric(name=metric_name_h,
                      interval=3,
                      sampling_function=get_humidity)
示例#13
0
                                       actuator_udm=action_actuator)

    graphite = Graphite(SocketDccComms(ip=config['GraphiteIP'], port=8080),
                        edge_component)

    # create a System object encapsulating the particulars of a IoT System
    # argument is the name of this IoT System
    edge_system = Dell5KEdgeSystem(config['EdgeSystemName'])

    # resister the IoT System with the graphite instance
    # this call creates a representation (a Resource) in graphite for this IoT System with the name given

    rule_rpm_metric = Metric(name="rpm",
                             unit=None,
                             interval=1,
                             aggregation_size=1,
                             sampling_function=get_rpm)

    rule_reg_rpm_metric = graphite.register(rule_rpm_metric)
    graphite.create_relationship(edge_system, rule_rpm_metric)
    rule_reg_rpm_metric.start_collecting()

    rule_vib_metric = Metric(name="vib",
                             unit=None,
                             interval=2,
                             aggregation_size=1,
                             sampling_function=get_vibration)
    rule_reg_vib_metric = graphite.register(rule_vib_metric)
    graphite.create_relationship(edge_system, rule_vib_metric)
    rule_reg_vib_metric.start_collecting()
        reg_mem_free_metric.start_collecting()

        swap_mem_free_metric = Metric(name="Swap Memory Free",
                                      unit=None,
                                      interval=8,
                                      aggregation_size=5,
                                      sampling_function=read_swap_mem_free)
        reg_swap_mem_free_metric = iotcc.register(swap_mem_free_metric)
        iotcc.create_relationship(reg_ram_device, reg_swap_mem_free_metric)
        reg_swap_mem_free_metric.start_collecting()

    except RegistrationFailure:
        print "Registration to IOTCC failed"

    # Multiple DCC support
    # Sending data to an alternate data center component (e.g. data lake for analytics)
    # Graphite is a data center component
    # Socket is the transport which the agent uses to connect to the graphite instance
    graphite = Graphite(
        SocketDccComms(ip=config['GraphiteIP'], port=config['GraphitePort']))
    graphite_reg_edge_system = graphite.register(edge_system)
    simulated_metric = Metric(name="edge.simulated.metric",
                              unit=None,
                              interval=10,
                              aggregation_size=5,
                              sampling_function=simulated_value)
    reg_simulated_metric = graphite.register(simulated_metric)
    graphite.create_relationship(graphite_reg_edge_system,
                                 reg_simulated_metric)
    reg_simulated_metric.start_collecting()
def udm1():
    return comms_channel.get(block=True)

#---------------------------------------------------------------------------
# In this example, we demonstrate how an event stream of data can be directed to graphite
# data center component using Liota by setting sampling_interval_sec parameter to zero.

if __name__ == '__main__':

    edge_system = Dk300EdgeSystem(config['EdgeSystemName'])

    # Sending data to Graphite data center component
    # Socket is the underlying transport used to connect to the Graphite
    # instance
    graphite = Graphite(SocketDccComms(ip=config['GraphiteIP'],
                               port=config['GraphitePort']))
    graphite_reg_edge_system = graphite.register(edge_system)

    metric_name = config['MetricName']
    content_metric = Metric(
        name=metric_name,
        unit=None,
        interval=0,
        aggregation_size=6,
        sampling_function=udm1
    )
    reg_content_metric = graphite.register(content_metric)
    graphite.create_relationship(graphite_reg_edge_system, reg_content_metric)
    reg_content_metric.start_collecting()
示例#16
0
    # Sending data to Graphite data center component
    # Socket is the underlying transport used to connect to the Graphite
    # instance
    graphite = Graphite(
        Socket(ip=config['GraphiteIP'], port=config['GraphitePort']))
    graphite_reg_edge_system = graphite.register(edge_system)

    metric_name_temp_degC = config['MetricNameTempDegC']
    temp_metric_degC = Metric(name=metric_name_temp_degC,
                              unit=ureg.degC,
                              interval=33,
                              aggregation_size=6,
                              sampling_function=getTempDegC)
    reg_temp_metric_degC = graphite.register(temp_metric_degC)
    graphite.create_relationship(graphite_reg_edge_system,
                                 reg_temp_metric_degC)
    reg_temp_metric_degC.start_collecting()

    metric_name_temp_degF = config['MetricNameTempDegF']
    temp_metric_degF = Metric(name=metric_name_temp_degF,
                              unit=ureg.degF,
                              interval=62,
                              aggregation_size=1,
                              sampling_function=getTempDegF)
    reg_temp_metric_degF = graphite.register(temp_metric_degF)
    graphite.create_relationship(graphite_reg_edge_system,
                                 reg_temp_metric_degF)
    reg_temp_metric_degF.start_collecting()

    metric_name_temp_kelvin = config['MetricNameTempKelvin']
    temp_metric_kelvin = Metric(name=metric_name_temp_kelvin,
# random numbers can be directed to graphite data center component using Liota.
# The program illustrates the ease of use Liota brings to IoT application
# developers.


def xmpp_subscribe():
    xmpp_conn = XmppDeviceComms("[email protected]", "m1ndst1x", "127.0.0.1",
                                "5222")
    xmpp_conn.subscribe("pubsub.127.0.0.1", "/vmware11",
                        callback_openfire_data)


if __name__ == '__main__':
    xmpp_subscribe()
    edge_system = SimulatedEdgeSystem('EdgeSystemName')

    # Sending data to Graphite data center component
    # Socket is the underlying transport used to connect to the Graphite
    # instance
    graphite = Graphite(SocketDccComms(ip='127.0.0.1', port=80))
    graphite_reg_edge_system = graphite.register(edge_system)

    metric_name = 'OpenfireData'
    openfire_metric = Metric(
        name=metric_name,
        interval=0,
        sampling_function=lambda: get_value(openfire_data))
    reg_openfire_metric = graphite.register(openfire_metric)
    graphite.create_relationship(graphite_reg_edge_system, reg_openfire_metric)
    reg_openfire_metric.start_collecting()
示例#18
0
    # Socket is the underlying transport used to connect to the Graphite
    # instance
    graphite = Graphite(SocketDccComms(ip=config['GraphiteIP'],
                               port=config['GraphitePort']))
    graphite_reg_edge_system = graphite.register(edge_system)

    metric_name_temp_degC = config['MetricNameTempDegC']
    temp_metric_degC = Metric(
        name=metric_name_temp_degC,
        unit=ureg.degC,
        interval=33,
        aggregation_size=6,
        sampling_function=getTempDegC
    )
    reg_temp_metric_degC = graphite.register(temp_metric_degC)
    graphite.create_relationship(graphite_reg_edge_system, reg_temp_metric_degC)
    reg_temp_metric_degC.start_collecting()

    metric_name_temp_degF = config['MetricNameTempDegF']
    temp_metric_degF = Metric(
        name=metric_name_temp_degF,
        unit=ureg.degF,
        interval=62,
        aggregation_size=1,
        sampling_function=getTempDegF
    )
    reg_temp_metric_degF = graphite.register(temp_metric_degF)
    graphite.create_relationship(graphite_reg_edge_system, reg_temp_metric_degF)
    reg_temp_metric_degF.start_collecting()

    metric_name_temp_kelvin = config['MetricNameTempKelvin']
        # create a System object encapsulating the particulars of a IoT System
        # argument is the name of this IoT System
        edge_system = Dell5KEdgeSystem(config['EdgeSystemName'])

        # resister the IoT System with the graphite instance
        # this call creates a representation (a Resource) in graphite for this IoT System with the name given
        reg_edge_system = graphite.register(edge_system)

        # Operational metrics of EdgeSystem
        cpu_utilization_metric = Metric(name="windmill.CPU_Utilization",
                                        unit=None,
                                        interval=10,
                                        aggregation_size=2,
                                        sampling_function=read_cpu_utilization)
        reg_cpu_utilization_metric = graphite.register(cpu_utilization_metric)
        graphite.create_relationship(reg_edge_system,
                                     reg_cpu_utilization_metric)
        # call to start collecting values from the device or system and sending to the data center component
        reg_cpu_utilization_metric.start_collecting()

        cpu_procs_metric = Metric(name="windmill.CPU_Process",
                                  unit=None,
                                  interval=6,
                                  aggregation_size=8,
                                  sampling_function=read_cpu_procs)
        reg_cpu_procs_metric = graphite.register(cpu_procs_metric)
        graphite.create_relationship(reg_edge_system, reg_cpu_procs_metric)
        reg_cpu_procs_metric.start_collecting()

        mem_free_metric = Metric(name="windmill.Memory_Free",
                                 unit=None,
                                 interval=10,