Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- # -*- coding: utf-8 -*-
- import sys
- from datetime import datetime
- from elasticsearch import Elasticsearch
- import RPi.GPIO as GPIO
- import ipgetter
- GPIO.setmode(GPIO.BCM)
- GPIO.setup(17, GPIO.OUT)
- tFile = open('/sys/class/thermal/thermal_zone0/temp')
- temp = float(tFile.read())
- tempC = temp/1000
- tFile.close()
- GPIO.cleanup()
- ext_ip = ipgetter.myip()
- es = Elasticsearch(host='elk.mydomain.sk', port=9200, http_auth=('admin', 'admin'))
- doc = {
- 'temperature': tempC,
- 'external_ip': ext_ip,
- 'author': 'tomas',
- 'timestamp': datetime.now()
- }
- res = es.index(index="raspberry", doc_type='sys_stats', body=doc)
- print datetime.now()
- print tempC
- print ext_ip
- print(res['created'])
- sys.exit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement