def setupLogEntries():
    global log
    log = logging.getLogger('r7insight')
    log.setLevel(logging.INFO)
    test = R7InsightHandler(LogEntriesToken, 'eu')

    log.addHandler(test)
示例#2
0
 def __init__(self, token, region):
     self._count = 0.0
     self._sum = 0.0
     self._lock = Lock()
     self.token = token
     self.region = region
     handler = R7InsightHandler(token, region)
     log.addHandler(handler)
示例#3
0
    except:  # Return None if reading was unsuccessful
        print(str(datetime.datetime.now()) + '\tReading unsuccessful')
        return None, None

    return temp, humidity


# Code for scheduled sensor readings
# Readings in 5 seconds intervals

sensor = 11  # Assign GPIO pin numbers
pin = 17

log = logging.getLogger('r7insight')  # Set up logger
log.setLevel(logging.INFO)
rp = R7InsightHandler('8ad868a7-9901-4bc0-ae22-cef76ed2af98', 'eu')
log.addHandler(rp)

t_next = time.time() + 5  # Set time of next reading to current time + 5 sec

while True:

    while time.time() < t_next:  # Sleep until t_next is reached
        time.sleep(0.0001)

    t_next += 5  # Reset t_next

    try:
        temp, humidity = read_sensor(sensor, pin)  # Store reading

        timestamp = datetime.datetime.now()  # Store timestamp
import datetime

sensor = 11
pin = 23

server_sock = bluetooth.BluetoothSocket(bluetooth.RFCOMM)

port = 1
server_sock.bind(("", port))
server_sock.listen(1)

log = logging.getLogger('r7insight')
log.setLevel(logging.INFO)

#Insightops Log Token
test = R7InsightHandler('24568bbf-d50f-4922-b2fc-aede9a941f98', 'eu')

log.addHandler(test)

client_sock, address = server_sock.accept()
print("Accepted connection from ", address)

while True:

    #Record After every 5 sec
    data = client_sock.recv(1024)
    print("received [%s]" % data)

    #Reading Data from RPi 1 Sensor
    log.info(data)
示例#5
0
            time.sleep(1)
        return


# Multi thread variables
logging.basicConfig(
    level=logging.DEBUG,
    format='(%(threadName)-9s) %(message)s',
)
BUF_SIZE = 50
q = Queue.Queue(BUF_SIZE)

log = logging.getLogger('r7insight')
log.setLevel(logging.INFO)
handler = R7InsightHandler('1143ef16-8a10-444b-913c-28844b3ab4b2', 'eu')
log.addHandler(handler)

# Application Configuration parameters
testing = False

# Sensor Configuration parameters
sensor = 11
pin = 4

local = LocalSensorThread(name='sensor')
comms = CommsThread(name='comms')

local.start()
comms.start()
示例#6
0
import logging
from time import sleep
from r7insight import R7InsightHandler

# add your token from insightops here
# token = ''
region = 'EU'

log = logging.getLogger('r7insight')
log.setLevel(logging.INFO)
test = R7InsightHandler(token, region)

log.addHandler(test)

log.warn("Warning message")
log.info("Info message")

sleep(10)
            summary, outdoor_temp, outdoor_humidity))
    print("Message received (MQTT) and logged \n" +
          str(message.payload.decode("utf-8")) +
          " Weather_Summary={}, Outdoor_Temp={}, Outdoor_Humidity={}\n".format(
              summary, outdoor_temp, outdoor_humidity))
    #print("message topic=",message.topic)
    #print("message qos=",message.qos)
    #print("message retain flag=",message.retain)


# Set up logging to Rapid7
log = logging.getLogger('r7insight')
log.setLevel(logging.INFO)

# Stephen G R7 log
handler = R7InsightHandler('d405ebb0-14bd-43a5-a9d3-1dafebce53a6', 'eu')

# Stephen K R7 log
#handler = R7InsightHandler('8d4816d7-026a-48fb-845a-eddf5808ac5b', 'eu')

# Add custom handler with log token here
# handler = R7InsightHandler('XXXXX', 'eu')

log.addHandler(handler)

# Adafruit settings
sensor = 11
pin = 4

# Sensor settings
sensor_ID = "stephen_gaffney"