Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
da3a0b09b9 |
@@ -0,0 +1,37 @@
|
|||||||
|
import json
|
||||||
|
|
||||||
|
class DataObject():
|
||||||
|
def __init__(self):
|
||||||
|
self.currentSpeed = 0
|
||||||
|
self.speed2AVG = 0
|
||||||
|
self.speed10AVG = 0
|
||||||
|
self.speed2Max = 0
|
||||||
|
self.speed10Max = 0
|
||||||
|
self.compass = 0
|
||||||
|
|
||||||
|
def data(self, client, userdata, msg):
|
||||||
|
|
||||||
|
m_in= self.decode( msg.payload )
|
||||||
|
|
||||||
|
try:
|
||||||
|
self.currentSpeed = m_in['windspeed']
|
||||||
|
self.speed2AVG = m_in['speed2AVG']
|
||||||
|
self.speed10AVG = m_in['speed10AVG']
|
||||||
|
self.speed2Max = m_in['speed2max']
|
||||||
|
self.speed10Max = m_in['speed10max']
|
||||||
|
self.compass = m_in['winddirection']
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def config(self, client, userdata, msg):
|
||||||
|
|
||||||
|
m_in= self.decode( msg.payload )
|
||||||
|
|
||||||
|
try:
|
||||||
|
self.warning = m_in['warning_level']
|
||||||
|
self.alert = m_in['alert_level']
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def decode(self,payload):
|
||||||
|
return json.loads( payload.decode("utf-8", "ignore") )
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
MIT License
|
|
||||||
|
|
||||||
Copyright (c) 2016 Mateusz Trojak
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
||||||
@@ -0,0 +1,100 @@
|
|||||||
|
import os
|
||||||
|
import platform
|
||||||
|
import pygame
|
||||||
|
|
||||||
|
class DriverException(Exception):
|
||||||
|
def __init__(self, driverName):
|
||||||
|
self.driverName = driverName
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return repr(self.driverName)
|
||||||
|
|
||||||
|
class Screen():
|
||||||
|
screen = None
|
||||||
|
bgColor = None
|
||||||
|
|
||||||
|
def __init__(self, width, height, fullscreen):
|
||||||
|
size = (width, height)
|
||||||
|
|
||||||
|
disp_no = os.getenv('DISPLAY')
|
||||||
|
if disp_no:
|
||||||
|
print ("I'm running under X display = {0}".format(disp_no))
|
||||||
|
self.screen = pygame.display.init()
|
||||||
|
else:
|
||||||
|
print("Try to run from framebuffer...")
|
||||||
|
drivers = ['fbcon','directfb', 'svgalib']
|
||||||
|
|
||||||
|
found = False
|
||||||
|
for driver in drivers:
|
||||||
|
print(driver)
|
||||||
|
if not os.getenv('SDL_VIDEODRIVER'):
|
||||||
|
os.putenv('SDL_VIDEODRIVER', driver)
|
||||||
|
try:
|
||||||
|
self.screen = pygame.display.init()
|
||||||
|
except pygame.error:
|
||||||
|
print("Driver: {0} failed.".format(driver))
|
||||||
|
continue
|
||||||
|
found = True
|
||||||
|
break
|
||||||
|
|
||||||
|
if not found:
|
||||||
|
raise Exception('No suitable video driver found!')
|
||||||
|
|
||||||
|
self.realSize = (pygame.display.Info().current_w, pygame.display.Info().current_h)
|
||||||
|
if size[0] > self.realSize[0]:
|
||||||
|
size = (self.realSize[0], size[1])
|
||||||
|
if size[1] > self.realSize[1]:
|
||||||
|
size = (size[0], self.realSize[1])
|
||||||
|
if not fullscreen:
|
||||||
|
self.screen = pygame.display.set_mode(size)
|
||||||
|
else:
|
||||||
|
self.screen = pygame.display.set_mode((0,0), pygame.FULLSCREEN|pygame.DOUBLEBUF|pygame.HWSURFACE)
|
||||||
|
|
||||||
|
|
||||||
|
def quit(self):
|
||||||
|
pygame.display.quit()
|
||||||
|
|
||||||
|
def update(self):
|
||||||
|
pygame.display.flip()
|
||||||
|
|
||||||
|
def blit(self, surface, x, y):
|
||||||
|
|
||||||
|
self.screen.blit( surface, (x, y) )
|
||||||
|
|
||||||
|
def background(self, color):
|
||||||
|
try:
|
||||||
|
self.screen.fill( pygame.Color(color) )
|
||||||
|
except:
|
||||||
|
self.screen.fill( pygame.Color("white"))
|
||||||
|
finally:
|
||||||
|
self.bgColor = color
|
||||||
|
|
||||||
|
def reset(self):
|
||||||
|
self.background(self.bgColor)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def setCaption(self, title):
|
||||||
|
pygame.display.set_caption(title)
|
||||||
|
|
||||||
|
def test(self):
|
||||||
|
# Fill the screen with red (255, 0, 0)
|
||||||
|
self.screen.fill(pygame.Color("red"))
|
||||||
|
# Update the display
|
||||||
|
self.update()
|
||||||
|
|
||||||
|
def getSize(self):
|
||||||
|
return self.screen.get_size()
|
||||||
|
|
||||||
|
def getRealSize(self):
|
||||||
|
return self.realSize
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Binary file not shown.
+71
@@ -0,0 +1,71 @@
|
|||||||
|
[General]
|
||||||
|
fullscreen: True
|
||||||
|
timeToEnd: 5
|
||||||
|
|
||||||
|
[MQTT]
|
||||||
|
topic: DPW/STR/CRAN2/WIND
|
||||||
|
config: DPW/STR/CRAN2
|
||||||
|
host: localhost
|
||||||
|
port: 1884
|
||||||
|
keepalive: 60
|
||||||
|
|
||||||
|
[Color]
|
||||||
|
normal = Black
|
||||||
|
warning = Yellow
|
||||||
|
alert = Red
|
||||||
|
|
||||||
|
|
||||||
|
[CurrentSpeed]
|
||||||
|
font_size = 28
|
||||||
|
x = 386
|
||||||
|
y = 226
|
||||||
|
|
||||||
|
[AVG2Speed]
|
||||||
|
font_size = 28
|
||||||
|
x = 0
|
||||||
|
y = 0
|
||||||
|
width = 400
|
||||||
|
height = 240
|
||||||
|
|
||||||
|
[AVG10Speed]
|
||||||
|
font_size = 28
|
||||||
|
x = 0
|
||||||
|
y = 240
|
||||||
|
width = 400
|
||||||
|
height = 240
|
||||||
|
|
||||||
|
[Max2Speed]
|
||||||
|
font_size = 28
|
||||||
|
x = 400
|
||||||
|
y = 0
|
||||||
|
width = 400
|
||||||
|
height = 240
|
||||||
|
|
||||||
|
[Max10Speed]
|
||||||
|
font_size = 28
|
||||||
|
x = 400
|
||||||
|
y = 240
|
||||||
|
width = 400
|
||||||
|
height = 240
|
||||||
|
|
||||||
|
[Compass]
|
||||||
|
font_size = 20
|
||||||
|
width = 280
|
||||||
|
height = 280
|
||||||
|
x = 260
|
||||||
|
y = 100
|
||||||
|
background = Navy
|
||||||
|
needle_color = Deepskyblue
|
||||||
|
lineLength = 60
|
||||||
|
|
||||||
|
[CompassBackground]
|
||||||
|
dashedLineColor = Darkgrey
|
||||||
|
dashsize = 10
|
||||||
|
groundColor = Lightgrey
|
||||||
|
angleOffset = 13
|
||||||
|
|
||||||
|
[Splashscreen]
|
||||||
|
fadein = 0.5
|
||||||
|
fadeout = 0.5
|
||||||
|
solid = 0.5
|
||||||
|
font_size = 20
|
||||||
Executable
+4
@@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
echo Starting display application
|
||||||
|
cd /home/pi/Windmessanlage/Software/Display/
|
||||||
|
DISPLAY=:0 python3 main.py
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
grafana:
|
|
||||||
image: grafana/grafana:latest
|
|
||||||
ports:
|
|
||||||
- 3000:3000
|
|
||||||
links:
|
|
||||||
- influxdb:influxdb
|
|
||||||
environment:
|
|
||||||
GF_SECURITY_ADMIN_USER: admin
|
|
||||||
GF_SECURITY_ADMIN_PASSWORD: admin
|
|
||||||
GF_SECURITY_SECRET_KEY: grafana
|
|
||||||
GF_USERS_ALLOW_SIGN_UP: "true"
|
|
||||||
GF_USERS_ALLOW_ORG_CREATE: "true"
|
|
||||||
GF_AUTH_ANONYMOUS_ENABLED: "true"
|
|
||||||
GF_AUTH_ANONYMOUS_ORG_NAME: grafana
|
|
||||||
# GF_DASHBOARDS_JSON_ENABLED: "true"
|
|
||||||
# GF_DASHBOARDS_JSON_PATH: /opt/grafana
|
|
||||||
volumes_from:
|
|
||||||
- grafana-data
|
|
||||||
restart: always
|
|
||||||
user: root
|
|
||||||
|
|
||||||
grafana-data:
|
|
||||||
image: busybox
|
|
||||||
tty: true
|
|
||||||
volumes:
|
|
||||||
- /var/lib/grafana
|
|
||||||
- /var/log/grafana
|
|
||||||
- /var/lib/grafana/plugins
|
|
||||||
|
|
||||||
influxdb:
|
|
||||||
build: ./influxdb/
|
|
||||||
ports:
|
|
||||||
- 8083:8083
|
|
||||||
- 8086:8086
|
|
||||||
environment:
|
|
||||||
INFLUX_DATABASE: "telegraf"
|
|
||||||
INLFUX_ADMIN_USER: "grafana"
|
|
||||||
INFLUX_ADMIN_PASS: "grafana"
|
|
||||||
volumes_from:
|
|
||||||
- influxdb-data
|
|
||||||
|
|
||||||
influxdb-data:
|
|
||||||
image: busybox
|
|
||||||
tty: true
|
|
||||||
volumes:
|
|
||||||
- /var/lib/influxdb
|
|
||||||
|
|
||||||
telegraf:
|
|
||||||
build: ./telegraf/
|
|
||||||
links:
|
|
||||||
- influxdb:influxdb
|
|
||||||
environment:
|
|
||||||
HOST_NAME: "telegraf"
|
|
||||||
INFLUXDB_HOST: "influxdb"
|
|
||||||
INFLUXDB_PORT: "8086"
|
|
||||||
DATABASE: "telegraf"
|
|
||||||
tty: true
|
|
||||||
volumes:
|
|
||||||
- /var/run/docker.sock:/var/run/docker.sock
|
|
||||||
privileged: true
|
|
||||||
@@ -0,0 +1,137 @@
|
|||||||
|
import pygame
|
||||||
|
import math
|
||||||
|
|
||||||
|
class Compass():
|
||||||
|
def __init__(self, font_size, size):
|
||||||
|
pygame.font.init()
|
||||||
|
self.textColor = pygame.Color("white")
|
||||||
|
self.backgroundColor = pygame.Color("White")
|
||||||
|
self.needleColor = pygame.Color("black")
|
||||||
|
|
||||||
|
self.font = pygame.font.Font(pygame.font.get_default_font(), font_size)
|
||||||
|
|
||||||
|
self.surface = pygame.Surface(size, pygame.SRCALPHA)
|
||||||
|
self.size = size
|
||||||
|
|
||||||
|
self.x = 0
|
||||||
|
self.y = 0
|
||||||
|
|
||||||
|
self.backgroundSurface = None
|
||||||
|
|
||||||
|
|
||||||
|
def setX(self, x):
|
||||||
|
self.x = x
|
||||||
|
def getX(self):
|
||||||
|
return self.x
|
||||||
|
|
||||||
|
def setY(self, y):
|
||||||
|
self.y = y
|
||||||
|
def getY(self):
|
||||||
|
return self.y
|
||||||
|
|
||||||
|
def get(self):
|
||||||
|
return self.surface
|
||||||
|
|
||||||
|
def setTextColor(self, color):
|
||||||
|
try:
|
||||||
|
self.textColor = pygame.Color(color)
|
||||||
|
except:
|
||||||
|
self.textColor = pygame.Color("black")
|
||||||
|
|
||||||
|
def setBackgroundColor(self, color):
|
||||||
|
try:
|
||||||
|
self.backgroundColor = pygame.Color(color)
|
||||||
|
except:
|
||||||
|
self.backgroundColor = pygame.Color("white")
|
||||||
|
|
||||||
|
def setNeedleColor(self, color):
|
||||||
|
try:
|
||||||
|
self.needleColor = pygame.Color(color)
|
||||||
|
except:
|
||||||
|
self.needleColor = pygame.Color("black")
|
||||||
|
|
||||||
|
def update(self, value):
|
||||||
|
raise NotImplementedError()
|
||||||
|
|
||||||
|
|
||||||
|
class MiddleNeedle(Compass):
|
||||||
|
def update(self, value):
|
||||||
|
radius = min(self.size[0]//2, self.size[1]//2)
|
||||||
|
pygame.draw.circle( self.surface, self.backgroundColor, (self.size[0]//2, self.size[1]//2), radius)
|
||||||
|
|
||||||
|
|
||||||
|
arrow = pygame.Surface( ((self.size[0]//100*60)//2, self.size[1]//100*60), pygame.SRCALPHA )
|
||||||
|
|
||||||
|
polygon_list = [
|
||||||
|
( arrow.get_width()//2, 0 ), #Middle top
|
||||||
|
( 0, arrow.get_height() ), #bottom left
|
||||||
|
( arrow.get_width()//2, (arrow.get_height()-arrow.get_height()//100*30) ), #middle pos
|
||||||
|
( arrow.get_width(), arrow.get_height() ), #bottom right
|
||||||
|
]
|
||||||
|
|
||||||
|
pygame.draw.polygon(arrow, self.needleColor, polygon_list)
|
||||||
|
arrow = pygame.transform.rotate( arrow, value )
|
||||||
|
self.surface.blit( arrow, ( (self.size[0]//2)-(arrow.get_width()//2), (self.size[1]//2)-(arrow.get_height()//2)))
|
||||||
|
|
||||||
|
text = self.font.render("N", True, self.textColor)
|
||||||
|
self.surface.blit( text, ( (self.size[0]//2) - (text.get_width()//2), int(self.size[1]/100*10) - text.get_height()//2 ) )
|
||||||
|
|
||||||
|
text = self.font.render("W", True, self.textColor)
|
||||||
|
self.surface.blit( text, ( int(self.size[0]/100*10) - (text.get_width()//2), (self.size[1]//2) - (text.get_height()//2) ) )
|
||||||
|
|
||||||
|
text = self.font.render("O", True, self.textColor)
|
||||||
|
self.surface.blit( text, ( int(self.size[0]/100*90)- (text.get_width()//2), (self.size[1]//2) - (text.get_height()//2) ) )
|
||||||
|
|
||||||
|
text = self.font.render("S", True, self.textColor)
|
||||||
|
self.surface.blit( text, ( (self.size[0]//2) - (text.get_width()//2), int(self.size[1]/100*90) - text.get_height()//2 ) )
|
||||||
|
|
||||||
|
|
||||||
|
class OuterNeedle(Compass):
|
||||||
|
def update(self, value):
|
||||||
|
radius = min(self.size[0]//2, self.size[1]//2)
|
||||||
|
pygame.draw.circle( self.surface, self.backgroundColor, (self.size[0]//2, self.size[1]//2), radius)
|
||||||
|
|
||||||
|
|
||||||
|
if self.backgroundSurface:
|
||||||
|
self.surface.blit( self.backgroundSurface, (0,0) )
|
||||||
|
|
||||||
|
if self.lineLength is None:
|
||||||
|
self.lineLength = 5
|
||||||
|
|
||||||
|
# 0 is down -> +90
|
||||||
|
# alpha = 2 * arcsin (s / 2r); s is bottom line
|
||||||
|
alpha = 2 * math.asin( self.lineLength / (2*radius) )
|
||||||
|
value = math.radians(value) + math.pi/2 #put 0 to bottom
|
||||||
|
bottom_left = self.getPos(value +alpha/2, radius)
|
||||||
|
bottom_left = ( int(bottom_left[0] + radius), bottom_left[1]+radius) #offset to screen middle
|
||||||
|
bottom_right = self.getPos(value -alpha/2, radius)
|
||||||
|
bottom_right = ( int(bottom_right[0] + radius), bottom_right[1]+radius)
|
||||||
|
height_of_segment = self.lineLength/2 * math.tan( alpha / 4 )
|
||||||
|
height_of_triangle = math.sqrt(3) /2 * self.lineLength
|
||||||
|
top = self.getPos(value, radius-height_of_segment-height_of_triangle)
|
||||||
|
top = ( int(top[0] + radius), top[1]+radius )
|
||||||
|
points = [ bottom_left, top, bottom_right ]
|
||||||
|
|
||||||
|
pygame.draw.lines( self.surface, self.needleColor, False, points,3)
|
||||||
|
|
||||||
|
text = self.font.render("N", True, self.textColor)
|
||||||
|
self.surface.blit( text, ( (self.size[0]//2) - (text.get_width()//2), int(self.size[1]/100*10) - text.get_height()//2 ) )
|
||||||
|
|
||||||
|
text = self.font.render("W", True, self.textColor)
|
||||||
|
self.surface.blit( text, ( int(self.size[0]/100*10) - (text.get_width()//2), (self.size[1]//2) - (text.get_height()//2) ) )
|
||||||
|
|
||||||
|
text = self.font.render("O", True, self.textColor)
|
||||||
|
self.surface.blit( text, ( int(self.size[0]/100*90)- (text.get_width()//2), (self.size[1]//2) - (text.get_height()//2) ) )
|
||||||
|
|
||||||
|
text = self.font.render("S", True, self.textColor)
|
||||||
|
self.surface.blit( text, ( (self.size[0]//2) - (text.get_width()//2), int(self.size[1]/100*90) - text.get_height()//2 ) )
|
||||||
|
|
||||||
|
def getPos(self, alpha, radius):
|
||||||
|
return ( int( radius * math.cos(alpha) ), int( radius * math.sin(alpha) ) )
|
||||||
|
|
||||||
|
def setLineLength(self, length):
|
||||||
|
self.lineLength = length
|
||||||
|
|
||||||
|
def setBackgroundSurface(self, surface):
|
||||||
|
self.backgroundSurface = surface
|
||||||
|
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
import pygame
|
||||||
|
import math
|
||||||
|
|
||||||
|
class Point():
|
||||||
|
# constructed using a normal tupple
|
||||||
|
def __init__(self, point_t = (0,0)):
|
||||||
|
self.x = float(point_t[0])
|
||||||
|
self.y = float(point_t[1])
|
||||||
|
|
||||||
|
# define all useful operators
|
||||||
|
def __add__(self, other):
|
||||||
|
return Point((self.x + other.x, self.y + other.y))
|
||||||
|
def __sub__(self, other):
|
||||||
|
return Point((self.x - other.x, self.y - other.y))
|
||||||
|
def __mul__(self, scalar):
|
||||||
|
return Point((self.x*scalar, self.y*scalar))
|
||||||
|
def __truediv__(self, scalar):
|
||||||
|
return Point((self.x/scalar, self.y/scalar))
|
||||||
|
def __len__(self):
|
||||||
|
return int(math.sqrt(self.x**2 + self.y**2))
|
||||||
|
# get back values in original tuple format
|
||||||
|
def get(self):
|
||||||
|
return (self.x, self.y)
|
||||||
|
|
||||||
|
|
||||||
|
def draw_dashed_line(surf, color, start_pos, end_pos, width=1, dash_length=10):
|
||||||
|
origin = Point(start_pos)
|
||||||
|
target = Point(end_pos)
|
||||||
|
displacement = target - origin
|
||||||
|
length = len(displacement)
|
||||||
|
slope = displacement/length
|
||||||
|
|
||||||
|
for index in range(0, int(length/dash_length), 2):
|
||||||
|
start = origin + (slope * index * dash_length)
|
||||||
|
end = origin + (slope * (index + 1) * dash_length)
|
||||||
|
pygame.draw.line(surf, color, start.get(), end.get(), width)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
start =(50,50)
|
||||||
|
end =(100,50)
|
||||||
|
|
||||||
|
surface = pygame.Surface( (200,200) )
|
||||||
|
|
||||||
|
draw_dashed_line( surface, pygame.Color("Black"), start, end, width=1 )
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
import pygame
|
||||||
|
|
||||||
|
class Text():
|
||||||
|
def __init__(self,txt, font_size):
|
||||||
|
pygame.font.init()
|
||||||
|
self.color = pygame.Color("black")
|
||||||
|
self.txt = txt
|
||||||
|
self.font = pygame.font.Font(pygame.font.get_default_font(), font_size)
|
||||||
|
self.text = self.font.render(self.txt, True, self.color)
|
||||||
|
self.x = 0
|
||||||
|
self.y = 0
|
||||||
|
|
||||||
|
def setX(self, x):
|
||||||
|
self.x = x
|
||||||
|
def getX(self):
|
||||||
|
return self.x
|
||||||
|
|
||||||
|
def setY(self, y):
|
||||||
|
self.y = y
|
||||||
|
def getY(self):
|
||||||
|
return self.y
|
||||||
|
|
||||||
|
def get(self):
|
||||||
|
return self.text
|
||||||
|
|
||||||
|
def getSize(self):
|
||||||
|
return self.text.get_size()
|
||||||
|
|
||||||
|
def getWidth(self):
|
||||||
|
return self.text.get_width()
|
||||||
|
|
||||||
|
def setColor(self, color):
|
||||||
|
try:
|
||||||
|
self.color = pygame.Color(color)
|
||||||
|
except:
|
||||||
|
self.color = pygame.Color("black")
|
||||||
|
self.text = self.font.render(self.txt, True, self.color)
|
||||||
|
|
||||||
|
|
||||||
|
class VariableText(Text):
|
||||||
|
def __init__(self, txt, font_size):
|
||||||
|
pygame.font.init()
|
||||||
|
self.color = pygame.Color("black")
|
||||||
|
self.txt = txt+"{}"
|
||||||
|
self.font = pygame.font.Font(pygame.font.get_default_font(), font_size)
|
||||||
|
self.text = self.font.render(self.txt.format(0), True, self.color)
|
||||||
|
|
||||||
|
def setUnit(self, unit):
|
||||||
|
self.txt = self.txt+unit
|
||||||
|
self.unit = unit
|
||||||
|
|
||||||
|
def update(self, value):
|
||||||
|
self.text = self.font.render(self.txt.format(value), True, self.color)
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
import pygame
|
||||||
|
|
||||||
|
class Textbox():
|
||||||
|
def __init__(self, size, x, y, font_size):
|
||||||
|
self.background = pygame.Color("grey")
|
||||||
|
self.surface = pygame.Surface( size )
|
||||||
|
self.surface.fill( self.background )
|
||||||
|
|
||||||
|
self.color = pygame.Color("White")
|
||||||
|
self.fontsize = 20
|
||||||
|
pygame.font.init()
|
||||||
|
|
||||||
|
self.font = pygame.font.Font(pygame.font.get_default_font(), font_size)
|
||||||
|
text = self.font.render("", True, self.color)
|
||||||
|
self.surface.blit( text, (0,0) )
|
||||||
|
|
||||||
|
self.x = x
|
||||||
|
self.y = y
|
||||||
|
|
||||||
|
def setText(self, text):
|
||||||
|
self.lines = text.split('\n')
|
||||||
|
self.nr_of_lines = len(self.lines)
|
||||||
|
|
||||||
|
def setTextColor(self, color):
|
||||||
|
try:
|
||||||
|
self.color = pygame.Color(color)
|
||||||
|
except:
|
||||||
|
self.color = pygame.Color("black")
|
||||||
|
|
||||||
|
def setBackgroundColor(self, color):
|
||||||
|
try:
|
||||||
|
self.background = pygame.Color(color)
|
||||||
|
except:
|
||||||
|
self.background = pygame.Color("grey")
|
||||||
|
|
||||||
|
def get(self):
|
||||||
|
return self.surface
|
||||||
|
|
||||||
|
def getX(self):
|
||||||
|
return self.x
|
||||||
|
|
||||||
|
def getY(self):
|
||||||
|
return self.y
|
||||||
|
|
||||||
|
def update(self, value):
|
||||||
|
self.surface.fill( self.background )
|
||||||
|
|
||||||
|
for lineNr, line in enumerate(self.lines):
|
||||||
|
text = self.font.render(line.format(value), True, self.color)
|
||||||
|
spacing = text.get_height()//10
|
||||||
|
x = self.surface.get_width()//2 - text.get_width()//2
|
||||||
|
height_total = self.nr_of_lines * (text.get_height() + spacing)
|
||||||
|
y = self.surface.get_height()//2 - height_total//2 + (lineNr * (text.get_height()+spacing))
|
||||||
|
self.surface.blit( text, (x,y) )
|
||||||
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
FROM influxdb:latest
|
|
||||||
MAINTAINER Mateusz Trojak <mateusz.trojak@gmail.com>
|
|
||||||
LABEL version="1.1"
|
|
||||||
LABEL description="InfluxDB docker image with custom setup"
|
|
||||||
|
|
||||||
USER root
|
|
||||||
|
|
||||||
ADD influxdb.template.conf /influxdb.template.conf
|
|
||||||
|
|
||||||
ADD run.sh /run.sh
|
|
||||||
RUN chmod +x /run.sh
|
|
||||||
|
|
||||||
CMD ["/run.sh"]
|
|
||||||
|
|
||||||
@@ -1,122 +0,0 @@
|
|||||||
reporting-disabled = false
|
|
||||||
bind-address = ":8088"
|
|
||||||
|
|
||||||
[meta]
|
|
||||||
dir = "/var/lib/influxdb/meta"
|
|
||||||
retention-autocreate = true
|
|
||||||
logging-enabled = true
|
|
||||||
|
|
||||||
[data]
|
|
||||||
dir = "/var/lib/influxdb/data"
|
|
||||||
engine = "tsm1"
|
|
||||||
wal-dir = "/var/lib/influxdb/wal"
|
|
||||||
wal-logging-enabled = true
|
|
||||||
query-log-enabled = true
|
|
||||||
cache-max-memory-size = 524288000
|
|
||||||
cache-snapshot-memory-size = 26214400
|
|
||||||
cache-snapshot-write-cold-duration = "1h0m0s"
|
|
||||||
compact-full-write-cold-duration = "24h0m0s"
|
|
||||||
max-points-per-block = 0
|
|
||||||
max-series-per-database = 1000000
|
|
||||||
trace-logging-enabled = false
|
|
||||||
|
|
||||||
[coordinator]
|
|
||||||
write-timeout = "10s"
|
|
||||||
max-concurrent-queries = 0
|
|
||||||
query-timeout = "0"
|
|
||||||
log-queries-after = "0"
|
|
||||||
max-select-point = 0
|
|
||||||
max-select-series = 0
|
|
||||||
max-select-buckets = 0
|
|
||||||
|
|
||||||
[retention]
|
|
||||||
enabled = true
|
|
||||||
check-interval = "30m0s"
|
|
||||||
|
|
||||||
[shard-precreation]
|
|
||||||
enabled = true
|
|
||||||
check-interval = "10m0s"
|
|
||||||
advance-period = "30m0s"
|
|
||||||
|
|
||||||
[admin]
|
|
||||||
enabled = true
|
|
||||||
bind-address = ":8083"
|
|
||||||
https-enabled = false
|
|
||||||
https-certificate = "/etc/ssl/influxdb.pem"
|
|
||||||
|
|
||||||
[monitor]
|
|
||||||
store-enabled = true
|
|
||||||
store-database = "_internal"
|
|
||||||
store-interval = "10s"
|
|
||||||
|
|
||||||
[subscriber]
|
|
||||||
enabled = true
|
|
||||||
http-timeout = "30s"
|
|
||||||
|
|
||||||
[http]
|
|
||||||
enabled = true
|
|
||||||
bind-address = ":8086"
|
|
||||||
auth-enabled = false
|
|
||||||
log-enabled = true
|
|
||||||
write-tracing = false
|
|
||||||
https-enabled = false
|
|
||||||
https-certificate = "/etc/ssl/influxdb.pem"
|
|
||||||
https-private-key = ""
|
|
||||||
max-row-limit = 10000
|
|
||||||
max-connection-limit = 0
|
|
||||||
shared-secret = ""
|
|
||||||
realm = "InfluxDB"
|
|
||||||
|
|
||||||
[[graphite]]
|
|
||||||
enabled = false
|
|
||||||
bind-address = ":2003"
|
|
||||||
database = "graphite"
|
|
||||||
retention-policy = ""
|
|
||||||
protocol = "tcp"
|
|
||||||
batch-size = 5000
|
|
||||||
batch-pending = 10
|
|
||||||
batch-timeout = "1s"
|
|
||||||
consistency-level = "one"
|
|
||||||
separator = "."
|
|
||||||
udp-read-buffer = 0
|
|
||||||
|
|
||||||
[[collectd]]
|
|
||||||
enabled = false
|
|
||||||
bind-address = ":25826"
|
|
||||||
database = "collectd"
|
|
||||||
retention-policy = ""
|
|
||||||
batch-size = 5000
|
|
||||||
batch-pending = 10
|
|
||||||
batch-timeout = "10s"
|
|
||||||
read-buffer = 0
|
|
||||||
typesdb = "/usr/share/collectd/types.db"
|
|
||||||
|
|
||||||
[[opentsdb]]
|
|
||||||
enabled = false
|
|
||||||
bind-address = ":4242"
|
|
||||||
database = "opentsdb"
|
|
||||||
retention-policy = ""
|
|
||||||
consistency-level = "one"
|
|
||||||
tls-enabled = false
|
|
||||||
certificate = "/etc/ssl/influxdb.pem"
|
|
||||||
batch-size = 1000
|
|
||||||
batch-pending = 5
|
|
||||||
batch-timeout = "1s"
|
|
||||||
log-point-errors = true
|
|
||||||
|
|
||||||
[[udp]]
|
|
||||||
enabled = false
|
|
||||||
bind-address = ":8089"
|
|
||||||
database = "udp"
|
|
||||||
retention-policy = ""
|
|
||||||
batch-size = 5000
|
|
||||||
batch-pending = 10
|
|
||||||
read-buffer = 0
|
|
||||||
batch-timeout = "1s"
|
|
||||||
precision = ""
|
|
||||||
|
|
||||||
[continuous_queries]
|
|
||||||
log-enabled = true
|
|
||||||
enabled = true
|
|
||||||
run-interval = "1s"
|
|
||||||
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -m
|
|
||||||
CONFIG_TEMPLATE="/influxdb.template.conf"
|
|
||||||
CONFIG_FILE="/etc/influxdb/influxdb.conf"
|
|
||||||
CURR_TIMESTAMP=`date +%s`
|
|
||||||
|
|
||||||
INFLUX_HOST="localhost"
|
|
||||||
INFLUX_API_PORT="8086"
|
|
||||||
[ "${INFLUX_ADMIN_USER}" = "" ] &&
|
|
||||||
INFLUX_ADMIN_USER="grafana"
|
|
||||||
[ "${INFLUX_ADMIN_PASS}" = "" ] &&
|
|
||||||
INFLUX_ADMIN_PASS="grafana"
|
|
||||||
[ "${INFLUX_DATABASE}" = "" ] &&
|
|
||||||
JENKINS_BIN="telegraf"
|
|
||||||
|
|
||||||
mv -v $CONFIG_FILE $CONFIG_FILE.$CURR_TIMESTAMP
|
|
||||||
cp -v $CONFIG_TEMPLATE $CONFIG_FILE
|
|
||||||
|
|
||||||
exec influxd -config=$CONFIG_FILE 1>>/var/log/influxdb/influxdb.log 2>&1 &
|
|
||||||
sleep 5
|
|
||||||
|
|
||||||
USER_EXISTS=`influx -host=${INFLUX_HOST} -port=${INFLUX_API_PORT} -execute="SHOW USERS" | awk '{print $1}' | grep "${INFLUX_ADMIN_USER}" | wc -l`
|
|
||||||
|
|
||||||
if [ -n ${USER_EXISTS} ]
|
|
||||||
then
|
|
||||||
influx -host=${INFLUX_HOST} -port=${INFLUX_API_PORT} -execute="CREATE USER ${INFLUX_ADMIN_USER} WITH PASSWORD '${INFLUX_ADMIN_PASS}' WITH ALL PRIVILEGES"
|
|
||||||
influx -host=${INFLUX_HOST} -port=${INFLUX_API_PORT} -username=${INFLUX_ADMIN_USER} -password="${INFLUX_ADMIN_PASS}" -execute="create database ${INFLUX_DATABASE}"
|
|
||||||
influx -host=${INFLUX_HOST} -port=${INFLUX_API_PORT} -username=${INFLUX_ADMIN_USER} -password="${INFLUX_ADMIN_PASS}" -execute="grant all PRIVILEGES on ${INFLUX_DATABASE} to ${INLFUX_ADMIN_USER}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
tail -f /var/log/influxdb/influxdb.log
|
|
||||||
@@ -0,0 +1,281 @@
|
|||||||
|
import os
|
||||||
|
import platform
|
||||||
|
import pygame
|
||||||
|
import time
|
||||||
|
import math
|
||||||
|
|
||||||
|
import configparser
|
||||||
|
|
||||||
|
import paho.mqtt.client as mqtt
|
||||||
|
from DataObject import DataObject
|
||||||
|
|
||||||
|
from Screen import Screen
|
||||||
|
from elements.Text import Text, VariableText
|
||||||
|
from elements.Textbox import Textbox
|
||||||
|
from elements.Compass import OuterNeedle
|
||||||
|
from elements.Line import draw_dashed_line, Point
|
||||||
|
|
||||||
|
topic = ""
|
||||||
|
|
||||||
|
def on_connect(client, userdata, flags, rc):
|
||||||
|
print("Subscribe to {}".format(topic))
|
||||||
|
client.subscribe(topic)
|
||||||
|
|
||||||
|
|
||||||
|
def splashscreen(screen, fadein, solid, fadeout, font_size):
|
||||||
|
screen.background("white")
|
||||||
|
size = screen.getSize()
|
||||||
|
txt = Text("powered by NetWEB Systems", font_size)
|
||||||
|
img = pygame.image.load("resources/NWS.bmp")
|
||||||
|
imgSize = img.get_rect().size
|
||||||
|
surface = pygame.Surface(size)
|
||||||
|
surface.fill(pygame.Color("white"))
|
||||||
|
surface.blit(img, (size[0]//2 - imgSize[0], size[1]//2 - imgSize[1]))
|
||||||
|
surface.blit(txt.get(), (size[0]//2, size[1]//2))
|
||||||
|
|
||||||
|
if (fadein > 0):
|
||||||
|
for alpha in range(0,255): #0 is transparent, 255 is opaque
|
||||||
|
screen.reset()
|
||||||
|
surface.set_alpha(alpha)
|
||||||
|
screen.blit(surface,0,0)
|
||||||
|
screen.update()
|
||||||
|
time.sleep( fadein/255 )
|
||||||
|
|
||||||
|
screen.reset()
|
||||||
|
screen.blit(surface,0,0)
|
||||||
|
screen.update()
|
||||||
|
time.sleep(solid)
|
||||||
|
|
||||||
|
if (fadeout > 0):
|
||||||
|
for alpha in range(0,255): #0 is transparent, 255 is opaque
|
||||||
|
screen.reset()
|
||||||
|
surface.set_alpha(255-alpha)
|
||||||
|
screen.blit(surface,0,0)
|
||||||
|
screen.update()
|
||||||
|
time.sleep( fadeout/255 )
|
||||||
|
|
||||||
|
def getPos(angle, radius, offset):
|
||||||
|
return ( int( radius * math.cos(angle) )+offset, int( radius * math.sin(angle) )+offset)
|
||||||
|
|
||||||
|
def blitRotate(surf, image, pos, originPos, angle):
|
||||||
|
|
||||||
|
# calcaulate the axis aligned bounding box of the rotated image
|
||||||
|
w, h = image.get_size()
|
||||||
|
box = [pygame.math.Vector2(p) for p in [(0, 0), (w, 0), (w, -h), (0, -h)]]
|
||||||
|
box_rotate = [p.rotate(angle) for p in box]
|
||||||
|
min_box = (min(box_rotate, key=lambda p: p[0])[0], min(box_rotate, key=lambda p: p[1])[1])
|
||||||
|
max_box = (max(box_rotate, key=lambda p: p[0])[0], max(box_rotate, key=lambda p: p[1])[1])
|
||||||
|
|
||||||
|
# calculate the translation of the pivot
|
||||||
|
pivot = pygame.math.Vector2(originPos[0], -originPos[1])
|
||||||
|
pivot_rotate = pivot.rotate(angle)
|
||||||
|
pivot_move = pivot_rotate - pivot
|
||||||
|
|
||||||
|
# calculate the upper left origin of the rotated image
|
||||||
|
origin = (pos[0] - originPos[0] + min_box[0] - pivot_move[0], pos[1] - originPos[1] - max_box[1] + pivot_move[1])
|
||||||
|
|
||||||
|
# get a rotated image
|
||||||
|
rotated_image = pygame.transform.rotate(image, angle)
|
||||||
|
|
||||||
|
# rotate and blit the image
|
||||||
|
surf.blit(rotated_image, origin)
|
||||||
|
|
||||||
|
def buildBackground( size, config ):
|
||||||
|
surface = pygame.Surface( size, pygame.SRCALPHA)
|
||||||
|
|
||||||
|
w = size[0]
|
||||||
|
h = size[1]
|
||||||
|
|
||||||
|
try:
|
||||||
|
dashedLineColor = pygame.Color( config.get('CompassBackground','dashedLineColor') )
|
||||||
|
except:
|
||||||
|
dashedLineColor = pygame.Color("Black")
|
||||||
|
|
||||||
|
try:
|
||||||
|
groundColor = pygame.Color( config.get('CompassBackground','groundColor'))
|
||||||
|
except:
|
||||||
|
groundColor = pygame.Color("Black")
|
||||||
|
|
||||||
|
radius = min( w, h ) // 2
|
||||||
|
angle = config.getint('CompassBackground', 'angleOffset')
|
||||||
|
angle = math.radians( angle )
|
||||||
|
|
||||||
|
dash_length = config.getint('CompassBackground','dashSize')
|
||||||
|
|
||||||
|
#Kaimauer
|
||||||
|
start = getPos( angle, radius, offset=radius )
|
||||||
|
end = getPos( angle+math.pi, radius, offset=radius )
|
||||||
|
draw_dashed_line(surface, dashedLineColor, start, end, width=2, dash_length= dash_length )
|
||||||
|
|
||||||
|
alpha = 2 * math.acos( 1-( (radius-10)/radius ) )
|
||||||
|
start = getPos( (math.pi/2) + (alpha/2) + angle, radius, offset=radius )
|
||||||
|
end = getPos( (math.pi/2) - (alpha/2) + angle, radius, offset=radius )
|
||||||
|
draw_dashed_line(surface, dashedLineColor, start, end, width=2, dash_length= dash_length )
|
||||||
|
|
||||||
|
start = getPos( angle+(math.pi/2), radius//10*8, offset=radius )
|
||||||
|
end = getPos( angle+(math.pi/2), radius//10*1, offset=radius )
|
||||||
|
|
||||||
|
#x1 = Point( start )
|
||||||
|
#x2 = Point( end )
|
||||||
|
#alpha = math.radians(20)
|
||||||
|
#d = len(x1 - x2)
|
||||||
|
#print(d)
|
||||||
|
#length = d * (1/math.sin(math.pi+alpha))
|
||||||
|
#print(length)
|
||||||
|
#x = d * math.cos( alpha )
|
||||||
|
#y = d * math.cos( alpha )
|
||||||
|
#print( x, y)
|
||||||
|
#pygame.draw.line( surface, groundColor, start, (x,y) )
|
||||||
|
|
||||||
|
txt = Text( 'Terminal', 20 )
|
||||||
|
txt.setColor('Lightgrey')
|
||||||
|
txt_surface = pygame.transform.rotate( txt.get(), -math.degrees(angle) )
|
||||||
|
pos = getPos(angle+(math.pi/2), radius/10*2, radius-txt.getWidth()//2)
|
||||||
|
surface.blit( txt_surface, pos )
|
||||||
|
|
||||||
|
#circle_surface = pygame.Surface( size, pygame.SRCALPHA)
|
||||||
|
#pygame.draw.circle( circle_surface, groundColor, (w//2, h//2), radius, width=0, draw_bottom_left=True)
|
||||||
|
#pygame.draw.circle( circle_surface, groundColor, (w//2, h//2), radius, width=0, draw_bottom_right=True)
|
||||||
|
#blitRotate(surface, circle_surface, (w//2,h//2), (w//2,h//2), -math.degrees(angle))
|
||||||
|
|
||||||
|
return surface
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
|
||||||
|
#load config
|
||||||
|
config = configparser.ConfigParser()
|
||||||
|
config.read("config.ini")
|
||||||
|
|
||||||
|
fullscreen = config.getboolean('General', 'fullscreen')
|
||||||
|
timeToEnd = config.getfloat('General','timetoend')
|
||||||
|
|
||||||
|
screen = Screen(800,480, fullscreen)
|
||||||
|
screen.setCaption("Windmessanlage")
|
||||||
|
screen.background("white")
|
||||||
|
|
||||||
|
#Splashscreen
|
||||||
|
splashscreen(screen, config.getfloat('Splashscreen','fadein'), config.getfloat('Splashscreen','solid'), config.getfloat('Splashscreen','fadeout'), config.getint('Splashscreen','font_size'))
|
||||||
|
|
||||||
|
#-average speed 2min
|
||||||
|
size = ( int(config.get('AVG2Speed','width')), int(config.get('AVG2Speed','height')) )
|
||||||
|
x = int(config.get('AVG2Speed','x'))
|
||||||
|
y = int(config.get('AVG2Speed','y'))
|
||||||
|
averageSpeed2 = Textbox( size, x, y, int(config.get('AVG2Speed','font_size')) )
|
||||||
|
averageSpeed2.setText("Ø 2min:\n{}m/s")
|
||||||
|
averageSpeed2.setBackgroundColor("Black")
|
||||||
|
|
||||||
|
#-average speed 10min
|
||||||
|
size = ( int(config.get('AVG10Speed','width')), int(config.get('AVG10Speed','height')) )
|
||||||
|
x = int(config.get('AVG10Speed','x'))
|
||||||
|
y = int(config.get('AVG10Speed','y'))
|
||||||
|
averageSpeed10 = Textbox( size, x, y, int(config.get('AVG10Speed','font_size')) )
|
||||||
|
averageSpeed10.setText("\nØ 10min:\n{}m/s")
|
||||||
|
averageSpeed10.setBackgroundColor("Black")
|
||||||
|
|
||||||
|
#-max speed 2min
|
||||||
|
size = ( int(config.get('Max2Speed','width')), int(config.get('Max2Speed','height')) )
|
||||||
|
x = int(config.get('Max2Speed','x'))
|
||||||
|
y = int(config.get('Max2Speed','y'))
|
||||||
|
maxSpeed2 = Textbox( size, x, y, int(config.get('Max2Speed','font_size')) )
|
||||||
|
maxSpeed2.setText("Max 2min:\n{}m/s")
|
||||||
|
maxSpeed2.setBackgroundColor("black")
|
||||||
|
|
||||||
|
|
||||||
|
#-max speed 10min
|
||||||
|
size = ( int(config.get('Max10Speed','width')), int(config.get('Max10Speed','height')) )
|
||||||
|
x = int(config.get('Max10Speed','x'))
|
||||||
|
y = int(config.get('Max10Speed','y'))
|
||||||
|
maxSpeed10 = Textbox( size, x, y, int(config.get('Max10Speed','font_size')) )
|
||||||
|
maxSpeed10.setText("\nMax 10min:\n{}m/s")
|
||||||
|
maxSpeed10.setBackgroundColor("Black")
|
||||||
|
|
||||||
|
#compass
|
||||||
|
compass = OuterNeedle(int(config.get('Compass','font_size')), (int(config.get('Compass','width')), int(config.get('Compass','height'))) )
|
||||||
|
compass.setX( int(config.get('Compass','x')) )
|
||||||
|
compass.setY( int(config.get('Compass','y')) )
|
||||||
|
compass.setBackgroundColor( config.get('Compass', 'background') )
|
||||||
|
compass.setNeedleColor( config.get('Compass', 'needle_color') )
|
||||||
|
compass.setLineLength( config.getint('Compass', 'lineLength') )
|
||||||
|
|
||||||
|
compass.setBackgroundSurface( buildBackground( (int(config.get('Compass','width')), int(config.get('Compass','height'))), config ) )
|
||||||
|
|
||||||
|
#-Current speed
|
||||||
|
currentSpeed = VariableText("", int(config.get('CurrentSpeed','font_size')))
|
||||||
|
currentSpeed.setX(int(config.get('CurrentSpeed','x')))
|
||||||
|
currentSpeed.setY(int(config.get('CurrentSpeed','y')))
|
||||||
|
currentSpeed.setUnit("m/s")
|
||||||
|
currentSpeed.setColor("white")
|
||||||
|
|
||||||
|
#MQTT
|
||||||
|
topic = config.get('MQTT','topic')
|
||||||
|
mqttc = mqtt.Client()
|
||||||
|
mqttc.on_connect = on_connect
|
||||||
|
|
||||||
|
data = DataObject()
|
||||||
|
mqttc.message_callback_add( config.get('MQTT','topic'), data.data)
|
||||||
|
mqttc.message_callback_add( config.get('MQTT','config'), data.config)
|
||||||
|
|
||||||
|
mqtt_host = config.get('MQTT', 'host')
|
||||||
|
mqtt_port = int(config.get('MQTT', 'port'))
|
||||||
|
|
||||||
|
|
||||||
|
screen.reset()
|
||||||
|
screen.blit( Text("Try to connect to MQTT server", 24).get(), 0, 0)
|
||||||
|
screen.blit( Text("Server: {0}:{1}".format(mqtt_host, mqtt_port),24).get(), 0, 25)
|
||||||
|
screen.update()
|
||||||
|
pygame.mouse.set_visible(False)
|
||||||
|
|
||||||
|
while(True):
|
||||||
|
try:
|
||||||
|
mqttc.connect(mqtt_host, port=mqtt_port, keepalive=int(config.get('MQTT', 'keepalive')))
|
||||||
|
break
|
||||||
|
except (KeyboardInterrupt, SystemExit):
|
||||||
|
print("KeyboardInterrupt or SystemExit")
|
||||||
|
raise
|
||||||
|
except:
|
||||||
|
time.sleep(3)
|
||||||
|
print("Try to reconnect")
|
||||||
|
mqttc.loop_start()
|
||||||
|
|
||||||
|
|
||||||
|
#limit framerate
|
||||||
|
clock = pygame.time.Clock()
|
||||||
|
time_start = 0
|
||||||
|
|
||||||
|
while True:
|
||||||
|
e = pygame.event.poll()
|
||||||
|
if e.type == pygame.QUIT:
|
||||||
|
break
|
||||||
|
|
||||||
|
if e.type == pygame.MOUSEBUTTONDOWN:
|
||||||
|
time_start = time.time()
|
||||||
|
|
||||||
|
if e.type == pygame.MOUSEBUTTONUP:
|
||||||
|
if (time.time() - time_start > timeToEnd):
|
||||||
|
print("{}s".format(time.time() - time_start))
|
||||||
|
break
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
screen.reset()
|
||||||
|
currentSpeed.update(data.currentSpeed)
|
||||||
|
averageSpeed2.update(data.speed2AVG)
|
||||||
|
averageSpeed10.update(data.speed2AVG)
|
||||||
|
maxSpeed2.update(data.speed2Max)
|
||||||
|
maxSpeed10.update(data.speed10Max)
|
||||||
|
compass.update(data.compass)
|
||||||
|
|
||||||
|
|
||||||
|
screen.blit( averageSpeed2.get(), averageSpeed2.getX(), averageSpeed2.getY() )
|
||||||
|
screen.blit( averageSpeed10.get(), averageSpeed10.getX(), averageSpeed10.getY() )
|
||||||
|
screen.blit( maxSpeed2.get(), maxSpeed2.getX(), maxSpeed2.getY() )
|
||||||
|
screen.blit( maxSpeed10.get(), maxSpeed10.getX(), maxSpeed10.getY() )
|
||||||
|
screen.blit( compass.get(), compass.getX(), compass.getY() )
|
||||||
|
screen.blit( currentSpeed.get(), currentSpeed.getX(), currentSpeed.getY() )
|
||||||
|
screen.update()
|
||||||
|
|
||||||
|
#Limit to 30 fps
|
||||||
|
clock.tick(30)
|
||||||
|
|
||||||
|
|
||||||
|
screen.quit()
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 89 KiB |
@@ -1,14 +0,0 @@
|
|||||||
FROM telegraf:latest
|
|
||||||
MAINTAINER Mateusz Trojak <mateusz.trojak@gmail.com>
|
|
||||||
LABEL version="1.1"
|
|
||||||
LABEL description="Telegraf docker image with custom setup"
|
|
||||||
|
|
||||||
USER root
|
|
||||||
|
|
||||||
ADD telegraf.template.conf /telegraf.template.conf
|
|
||||||
|
|
||||||
ADD run.sh /run.sh
|
|
||||||
RUN chmod +x /*.sh
|
|
||||||
|
|
||||||
CMD ["/run.sh"]
|
|
||||||
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -m
|
|
||||||
CONFIG_TEMPLATE="/telegraf.template.conf"
|
|
||||||
CONFIG_FILE="/etc/telegraf/telegraf.conf"
|
|
||||||
|
|
||||||
sed -e "s/\${HOST_NAME}/$HOST_NAME/" \
|
|
||||||
-e "s!\${INFLUXDB_HOST}!$INFLUXDB_HOST!" \
|
|
||||||
-e "s/\${INFLUXDB_PORT}/$INFLUXDB_PORT/" \
|
|
||||||
-e "s/\${DATABASE}/$DATABASE/" \
|
|
||||||
$CONFIG_TEMPLATE > $CONFIG_FILE
|
|
||||||
|
|
||||||
echo "=> Starting Telegraf ..."
|
|
||||||
|
|
||||||
exec telegraf --debug -config /etc/telegraf/telegraf.conf
|
|
||||||
@@ -1,581 +0,0 @@
|
|||||||
# Telegraf Configuration
|
|
||||||
#
|
|
||||||
# Telegraf is entirely plugin driven. All metrics are gathered from the
|
|
||||||
# declared inputs, and sent to the declared outputs.
|
|
||||||
#
|
|
||||||
# Plugins must be declared in here to be active.
|
|
||||||
# To deactivate a plugin, comment out the name and any variables.
|
|
||||||
#
|
|
||||||
# Use 'telegraf -config telegraf.conf -test' to see what metrics a config
|
|
||||||
# file would generate.
|
|
||||||
#
|
|
||||||
# Environment variables can be used anywhere in this config file, simply prepend
|
|
||||||
# them with $. For strings the variable must be within quotes (ie, "$STR_VAR"),
|
|
||||||
# for numbers and booleans they should be plain (ie, $INT_VAR, $BOOL_VAR)
|
|
||||||
|
|
||||||
# Global tags can be specified here in key="value" format.
|
|
||||||
[global_tags]
|
|
||||||
# dc = "us-east-1" # will tag all metrics with dc=us-east-1
|
|
||||||
# rack = "1a"
|
|
||||||
## Environment variables can be used as tags, and throughout the config file
|
|
||||||
# user = "$USER"
|
|
||||||
|
|
||||||
|
|
||||||
# Configuration for telegraf agent
|
|
||||||
[agent]
|
|
||||||
## Default data collection interval for all inputs
|
|
||||||
interval = "1s"
|
|
||||||
## Rounds collection interval to 'interval'
|
|
||||||
## ie, if interval="10s" then always collect on :00, :10, :20, etc.
|
|
||||||
round_interval = true
|
|
||||||
|
|
||||||
## Telegraf will send metrics to outputs in batches of at
|
|
||||||
## most metric_batch_size metrics.
|
|
||||||
metric_batch_size = 1000
|
|
||||||
## For failed writes, telegraf will cache metric_buffer_limit metrics for each
|
|
||||||
## output, and will flush this buffer on a successful write. Oldest metrics
|
|
||||||
## are dropped first when this buffer fills.
|
|
||||||
#metric_buffer_limit = 86000
|
|
||||||
|
|
||||||
## Collection jitter is used to jitter the collection by a random amount.
|
|
||||||
## Each plugin will sleep for a random time within jitter before collecting.
|
|
||||||
## This can be used to avoid many plugins querying things like sysfs at the
|
|
||||||
## same time, which can have a measurable effect on the system.
|
|
||||||
collection_jitter = "0s"
|
|
||||||
|
|
||||||
## Default flushing interval for all outputs. You shouldn't set this below
|
|
||||||
## interval. Maximum flush_interval will be flush_interval + flush_jitter
|
|
||||||
flush_interval = "10s"
|
|
||||||
## Jitter the flush interval by a random amount. This is primarily to avoid
|
|
||||||
## large write spikes for users running a large number of telegraf instances.
|
|
||||||
## ie, a jitter of 5s and interval 10s means flushes will happen every 10-15s
|
|
||||||
flush_jitter = "0s"
|
|
||||||
|
|
||||||
## By default, precision will be set to the same timestamp order as the
|
|
||||||
## collection interval, with the maximum being 1s.
|
|
||||||
## Precision will NOT be used for service inputs, such as logparser and statsd.
|
|
||||||
## Valid values are "ns", "us" (or "µs"), "ms", "s".
|
|
||||||
precision = ""
|
|
||||||
## Run telegraf in debug mode
|
|
||||||
debug = true
|
|
||||||
## Run telegraf in quiet mode
|
|
||||||
quiet = false
|
|
||||||
## Override default hostname, if empty use os.Hostname()
|
|
||||||
hostname = "${HOST_NAME}"
|
|
||||||
## If set to true, do no set the "host" tag in the telegraf agent.
|
|
||||||
omit_hostname = false
|
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# OUTPUT PLUGINS #
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
# Configuration for influxdb server to send metrics to
|
|
||||||
[[outputs.influxdb]]
|
|
||||||
## The full HTTP or UDP endpoint URL for your InfluxDB instance.
|
|
||||||
## Multiple urls can be specified as part of the same cluster,
|
|
||||||
## this means that only ONE of the urls will be written to each interval.
|
|
||||||
# urls = ["udp://localhost:8089"] # UDP endpoint example
|
|
||||||
urls = ["http://${INFLUXDB_HOST}:${INFLUXDB_PORT}"] # required
|
|
||||||
## The target database for metrics (telegraf will create it if not exists).
|
|
||||||
#database = "sensordata"
|
|
||||||
|
|
||||||
## Retention policy to write to. Empty string writes to the default rp.
|
|
||||||
retention_policy = ""
|
|
||||||
## Write consistency (clusters only), can be: "any", "one", "quorum", "all"
|
|
||||||
write_consistency = "any"
|
|
||||||
|
|
||||||
## Write timeout (for the InfluxDB client), formatted as a string.
|
|
||||||
## If not provided, will default to 5s. 0s means no timeout (not recommended).
|
|
||||||
timeout = "5s"
|
|
||||||
username = "telegraf"
|
|
||||||
password = "metricsnws"
|
|
||||||
## Set the user agent for HTTP POSTs (can be useful for log differentiation)
|
|
||||||
user_agent = "telegraf"
|
|
||||||
## Set UDP payload size, defaults to InfluxDB UDP Client default (512 bytes)
|
|
||||||
udp_payload = 512
|
|
||||||
|
|
||||||
## Optional SSL Config
|
|
||||||
# ssl_ca = "/etc/telegraf/ca.pem"
|
|
||||||
# ssl_cert = "/etc/telegraf/cert.pem"
|
|
||||||
# ssl_key = "/etc/telegraf/key.pem"
|
|
||||||
## Use SSL but skip chain & host verification
|
|
||||||
# insecure_skip_verify = false
|
|
||||||
|
|
||||||
# # Configuration for Amon Server to send metrics to.
|
|
||||||
# [[outputs.amon]]
|
|
||||||
# ## Amon Server Key
|
|
||||||
# server_key = "my-server-key" # required.
|
|
||||||
#
|
|
||||||
# ## Amon Instance URL
|
|
||||||
# amon_instance = "https://youramoninstance" # required
|
|
||||||
#
|
|
||||||
# ## Connection timeout.
|
|
||||||
# # timeout = "5s"
|
|
||||||
|
|
||||||
|
|
||||||
# # Configuration for the AMQP server to send metrics to
|
|
||||||
# [[outputs.amqp]]
|
|
||||||
# ## AMQP url
|
|
||||||
# url = "amqp://localhost:5672/influxdb"
|
|
||||||
# ## AMQP exchange
|
|
||||||
# exchange = "telegraf"
|
|
||||||
# ## Auth method. PLAIN and EXTERNAL are supported
|
|
||||||
# # auth_method = "PLAIN"
|
|
||||||
# ## Telegraf tag to use as a routing key
|
|
||||||
# ## ie, if this tag exists, it's value will be used as the routing key
|
|
||||||
# routing_tag = "host"
|
|
||||||
#
|
|
||||||
# ## InfluxDB retention policy
|
|
||||||
# # retention_policy = "default"
|
|
||||||
# ## InfluxDB database
|
|
||||||
# # database = "telegraf"
|
|
||||||
# ## InfluxDB precision
|
|
||||||
# # precision = "s"
|
|
||||||
#
|
|
||||||
# ## Optional SSL Config
|
|
||||||
# # ssl_ca = "/etc/telegraf/ca.pem"
|
|
||||||
# # ssl_cert = "/etc/telegraf/cert.pem"
|
|
||||||
# # ssl_key = "/etc/telegraf/key.pem"
|
|
||||||
# ## Use SSL but skip chain & host verification
|
|
||||||
# # insecure_skip_verify = false
|
|
||||||
#
|
|
||||||
# ## Data format to output.
|
|
||||||
# ## Each data format has it's own unique set of configuration options, read
|
|
||||||
# ## more about them here:
|
|
||||||
# ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_OUTPUT.md
|
|
||||||
# data_format = "influx"
|
|
||||||
|
|
||||||
|
|
||||||
# # Configuration for AWS CloudWatch output.
|
|
||||||
# [[outputs.cloudwatch]]
|
|
||||||
# ## Amazon REGION
|
|
||||||
# region = 'us-east-1'
|
|
||||||
#
|
|
||||||
# ## Amazon Credentials
|
|
||||||
# ## Credentials are loaded in the following order
|
|
||||||
# ## 1) Assumed credentials via STS if role_arn is specified
|
|
||||||
# ## 2) explicit credentials from 'access_key' and 'secret_key'
|
|
||||||
# ## 3) shared profile from 'profile'
|
|
||||||
# ## 4) environment variables
|
|
||||||
# ## 5) shared credentials file
|
|
||||||
# ## 6) EC2 Instance Profile
|
|
||||||
# #access_key = ""
|
|
||||||
# #secret_key = ""
|
|
||||||
# #token = ""
|
|
||||||
# #role_arn = ""
|
|
||||||
# #profile = ""
|
|
||||||
# #shared_credential_file = ""
|
|
||||||
#
|
|
||||||
# ## Namespace for the CloudWatch MetricDatums
|
|
||||||
# namespace = 'InfluxData/Telegraf'
|
|
||||||
|
|
||||||
|
|
||||||
# # Configuration for DataDog API to send metrics to.
|
|
||||||
# [[outputs.datadog]]
|
|
||||||
# ## Datadog API key
|
|
||||||
# apikey = "my-secret-key" # required.
|
|
||||||
#
|
|
||||||
# ## Connection timeout.
|
|
||||||
# # timeout = "5s"
|
|
||||||
|
|
||||||
|
|
||||||
# # Send telegraf metrics to file(s)
|
|
||||||
# [[outputs.file]]
|
|
||||||
# ## Files to write to, "stdout" is a specially handled file.
|
|
||||||
# files = ["stdout", "/tmp/metrics.out"]
|
|
||||||
#
|
|
||||||
# ## Data format to output.
|
|
||||||
# ## Each data format has it's own unique set of configuration options, read
|
|
||||||
# ## more about them here:
|
|
||||||
# ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_OUTPUT.md
|
|
||||||
# data_format = "influx"
|
|
||||||
|
|
||||||
|
|
||||||
# # Configuration for Graphite server to send metrics to
|
|
||||||
# [[outputs.graphite]]
|
|
||||||
# ## TCP endpoint for your graphite instance.
|
|
||||||
# ## If multiple endpoints are configured, output will be load balanced.
|
|
||||||
# ## Only one of the endpoints will be written to with each iteration.
|
|
||||||
# servers = ["localhost:2003"]
|
|
||||||
# ## Prefix metrics name
|
|
||||||
# prefix = ""
|
|
||||||
# ## Graphite output template
|
|
||||||
# ## see https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_OUTPUT.md
|
|
||||||
# template = "host.tags.measurement.field"
|
|
||||||
# ## timeout in seconds for the write connection to graphite
|
|
||||||
# timeout = 2
|
|
||||||
|
|
||||||
|
|
||||||
# # Send telegraf metrics to graylog(s)
|
|
||||||
# [[outputs.graylog]]
|
|
||||||
# ## Udp endpoint for your graylog instance.
|
|
||||||
# servers = ["127.0.0.1:12201", "192.168.1.1:12201"]
|
|
||||||
|
|
||||||
|
|
||||||
# # Configuration for sending metrics to an Instrumental project
|
|
||||||
# [[outputs.instrumental]]
|
|
||||||
# ## Project API Token (required)
|
|
||||||
# api_token = "API Token" # required
|
|
||||||
# ## Prefix the metrics with a given name
|
|
||||||
# prefix = ""
|
|
||||||
# ## Stats output template (Graphite formatting)
|
|
||||||
# ## see https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_OUTPUT.md#graphite
|
|
||||||
# template = "host.tags.measurement.field"
|
|
||||||
# ## Timeout in seconds to connect
|
|
||||||
# timeout = "2s"
|
|
||||||
# ## Display Communcation to Instrumental
|
|
||||||
# debug = false
|
|
||||||
|
|
||||||
|
|
||||||
# # Configuration for MQTT server to send metrics to
|
|
||||||
# [[outputs.mqtt]]
|
|
||||||
# servers = ["localhost:1883"] # required.
|
|
||||||
#
|
|
||||||
# ## MQTT outputs send metrics to this topic format
|
|
||||||
# ## "<topic_prefix>/<hostname>/<pluginname>/"
|
|
||||||
# ## ex: prefix/web01.example.com/mem
|
|
||||||
# topic_prefix = "telegraf"
|
|
||||||
#
|
|
||||||
# ## username and password to connect MQTT server.
|
|
||||||
# # username = "telegraf"
|
|
||||||
# # password = "metricsmetricsmetricsmetrics"
|
|
||||||
#
|
|
||||||
# ## Optional SSL Config
|
|
||||||
# # ssl_ca = "/etc/telegraf/ca.pem"
|
|
||||||
# # ssl_cert = "/etc/telegraf/cert.pem"
|
|
||||||
# # ssl_key = "/etc/telegraf/key.pem"
|
|
||||||
# ## Use SSL but skip chain & host verification
|
|
||||||
# # insecure_skip_verify = false
|
|
||||||
#
|
|
||||||
# ## Data format to output.
|
|
||||||
# ## Each data format has it's own unique set of configuration options, read
|
|
||||||
# ## more about them here:
|
|
||||||
# ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_OUTPUT.md
|
|
||||||
# data_format = "influx"
|
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# INPUT PLUGINS #
|
|
||||||
###############################################################################
|
|
||||||
# # Read metrics from MQTT topic(s)
|
|
||||||
[[inputs.mqtt_consumer]]
|
|
||||||
servers = ["tcp://10.0.1.103:1883"]
|
|
||||||
# ## MQTT QoS, must be 0, 1, or 2
|
|
||||||
qos = 1
|
|
||||||
#
|
|
||||||
# ## Topics to subscribe to
|
|
||||||
topics = [
|
|
||||||
"DPW/STR/BUILDING/WIND",
|
|
||||||
]
|
|
||||||
#
|
|
||||||
# # if true, messages that can't be delivered while the subscriber is offline
|
|
||||||
# # will be delivered when it comes back (such as on service restart).
|
|
||||||
# # NOTE: if true, client_id MUST be set
|
|
||||||
persistent_session = true
|
|
||||||
# # If empty, a random client ID will be generated.
|
|
||||||
client_id = "telegraf_WMA2"
|
|
||||||
#
|
|
||||||
# ## username and password to connect MQTT server.
|
|
||||||
username = "telegraf"
|
|
||||||
password = "telegraf"
|
|
||||||
#
|
|
||||||
# ## Optional SSL Config
|
|
||||||
# # ssl_ca = "/etc/telegraf/ca.pem"
|
|
||||||
# # ssl_cert = "/etc/telegraf/cert.pem"
|
|
||||||
# # ssl_key = "/etc/telegraf/key.pem"
|
|
||||||
# ## Use SSL but skip chain & host verification
|
|
||||||
# # insecure_skip_verify = false
|
|
||||||
#
|
|
||||||
# ## Data format to consume.
|
|
||||||
# ## Each data format has it's own unique set of configuration options, read
|
|
||||||
# ## more about them here:
|
|
||||||
# ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md
|
|
||||||
data_format = "json"
|
|
||||||
json_time_key = "time"
|
|
||||||
json_time_format = "2006-01-02 15:04:05"
|
|
||||||
|
|
||||||
|
|
||||||
# Read metrics about cpu usage
|
|
||||||
|
|
||||||
[[inputs.cpu]]
|
|
||||||
## Whether to report per-cpu stats or not
|
|
||||||
## percpu = true
|
|
||||||
## Whether to report total system cpu stats or not
|
|
||||||
## totalcpu = true
|
|
||||||
## Comment this line if you want the raw CPU time metrics
|
|
||||||
## fielddrop = ["time_*"]
|
|
||||||
|
|
||||||
|
|
||||||
# Read metrics about disk usage by mount point
|
|
||||||
[[inputs.disk]]
|
|
||||||
## By default, telegraf gather stats for all mountpoints.
|
|
||||||
## Setting mountpoints will restrict the stats to the specified mountpoints.
|
|
||||||
# mount_points = ["/"]
|
|
||||||
|
|
||||||
## Ignore some mountpoints by filesystem type. For example (dev)tmpfs (usually
|
|
||||||
## present on /run, /var/run, /dev/shm or /dev).
|
|
||||||
ignore_fs = ["tmpfs", "devtmpfs"]
|
|
||||||
|
|
||||||
|
|
||||||
# Read metrics about disk IO by device
|
|
||||||
[[inputs.diskio]]
|
|
||||||
## By default, telegraf will gather stats for all devices including
|
|
||||||
## disk partitions.
|
|
||||||
## Setting devices will restrict the stats to the specified devices.
|
|
||||||
# devices = ["sda", "sdb"]
|
|
||||||
## Uncomment the following line if you need disk serial numbers.
|
|
||||||
# skip_serial_number = false
|
|
||||||
|
|
||||||
|
|
||||||
# Get kernel statistics from /proc/stat
|
|
||||||
#[[inputs.kernel]]
|
|
||||||
# no configuration
|
|
||||||
|
|
||||||
|
|
||||||
# Read metrics about memory usage
|
|
||||||
#[[inputs.mem]]
|
|
||||||
# no configuration
|
|
||||||
|
|
||||||
|
|
||||||
# Get the number of processes and group them by status
|
|
||||||
#[[inputs.processes]]
|
|
||||||
# no configuration
|
|
||||||
|
|
||||||
|
|
||||||
# Read metrics about swap memory usage
|
|
||||||
#[[inputs.swap]]
|
|
||||||
# no configuration
|
|
||||||
|
|
||||||
|
|
||||||
# Read metrics about system load & uptime
|
|
||||||
#[[inputs.system]]
|
|
||||||
# no configuration
|
|
||||||
|
|
||||||
|
|
||||||
# # Read stats from aerospike server(s)
|
|
||||||
# [[inputs.aerospike]]
|
|
||||||
# ## Aerospike servers to connect to (with port)
|
|
||||||
# ## This plugin will query all namespaces the aerospike
|
|
||||||
# ## server has configured and get stats for them.
|
|
||||||
# servers = ["localhost:3000"]
|
|
||||||
|
|
||||||
|
|
||||||
# # Read Apache status information (mod_status)
|
|
||||||
# [[inputs.apache]]
|
|
||||||
# ## An array of Apache status URI to gather stats.
|
|
||||||
# ## Default is "http://localhost/server-status?auto".
|
|
||||||
# urls = ["http://localhost/server-status?auto"]
|
|
||||||
|
|
||||||
|
|
||||||
# # Read InfluxDB-formatted JSON metrics from one or more HTTP endpoints
|
|
||||||
# [[inputs.influxdb]]
|
|
||||||
# ## Works with InfluxDB debug endpoints out of the box,
|
|
||||||
# ## but other services can use this format too.
|
|
||||||
# ## See the influxdb plugin's README for more details.
|
|
||||||
#
|
|
||||||
# ## Multiple URLs from which to read InfluxDB-formatted JSON
|
|
||||||
# ## Default is "http://localhost:8086/debug/vars".
|
|
||||||
# urls = [
|
|
||||||
# "http://localhost:8086/debug/vars"
|
|
||||||
# ]
|
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# SERVICE INPUT PLUGINS #
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
# # Read metrics from Kafka topic(s)
|
|
||||||
# [[inputs.kafka_consumer]]
|
|
||||||
# ## topic(s) to consume
|
|
||||||
# topics = ["telegraf"]
|
|
||||||
# ## an array of Zookeeper connection strings
|
|
||||||
# zookeeper_peers = ["localhost:2181"]
|
|
||||||
# ## Zookeeper Chroot
|
|
||||||
# zookeeper_chroot = ""
|
|
||||||
# ## the name of the consumer group
|
|
||||||
# consumer_group = "telegraf_metrics_consumers"
|
|
||||||
# ## Offset (must be either "oldest" or "newest")
|
|
||||||
# offset = "oldest"
|
|
||||||
#
|
|
||||||
# ## Data format to consume.
|
|
||||||
# ## Each data format has it's own unique set of configuration options, read
|
|
||||||
# ## more about them here:
|
|
||||||
# ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md
|
|
||||||
# data_format = "influx"
|
|
||||||
|
|
||||||
|
|
||||||
# # Stream and parse log file(s).
|
|
||||||
# [[inputs.logparser]]
|
|
||||||
# ## Log files to parse.
|
|
||||||
# ## These accept standard unix glob matching rules, but with the addition of
|
|
||||||
# ## ** as a "super asterisk". ie:
|
|
||||||
# ## /var/log/**.log -> recursively find all .log files in /var/log
|
|
||||||
# ## /var/log/*/*.log -> find all .log files with a parent dir in /var/log
|
|
||||||
# ## /var/log/apache.log -> only tail the apache log file
|
|
||||||
# files = ["/var/log/apache/access.log"]
|
|
||||||
# ## Read file from beginning.
|
|
||||||
# from_beginning = false
|
|
||||||
#
|
|
||||||
# ## Parse logstash-style "grok" patterns:
|
|
||||||
# ## Telegraf built-in parsing patterns: https://goo.gl/dkay10
|
|
||||||
# [inputs.logparser.grok]
|
|
||||||
# ## This is a list of patterns to check the given log file(s) for.
|
|
||||||
# ## Note that adding patterns here increases processing time. The most
|
|
||||||
# ## efficient configuration is to have one pattern per logparser.
|
|
||||||
# ## Other common built-in patterns are:
|
|
||||||
# ## %{COMMON_LOG_FORMAT} (plain apache & nginx access logs)
|
|
||||||
# ## %{COMBINED_LOG_FORMAT} (access logs + referrer & agent)
|
|
||||||
# patterns = ["%{COMBINED_LOG_FORMAT}"]
|
|
||||||
# ## Name of the outputted measurement name.
|
|
||||||
# measurement = "apache_access_log"
|
|
||||||
# ## Full path(s) to custom pattern files.
|
|
||||||
# custom_pattern_files = []
|
|
||||||
# ## Custom patterns can also be defined here. Put one pattern per line.
|
|
||||||
# custom_patterns = '''
|
|
||||||
# '''
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# # Read metrics from NATS subject(s)
|
|
||||||
# [[inputs.nats_consumer]]
|
|
||||||
# ## urls of NATS servers
|
|
||||||
# servers = ["nats://localhost:4222"]
|
|
||||||
# ## Use Transport Layer Security
|
|
||||||
# secure = false
|
|
||||||
# ## subject(s) to consume
|
|
||||||
# subjects = ["telegraf"]
|
|
||||||
# ## name a queue group
|
|
||||||
# queue_group = "telegraf_consumers"
|
|
||||||
#
|
|
||||||
# ## Data format to consume.
|
|
||||||
# ## Each data format has it's own unique set of configuration options, read
|
|
||||||
# ## more about them here:
|
|
||||||
# ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md
|
|
||||||
# data_format = "influx"
|
|
||||||
|
|
||||||
|
|
||||||
# # Read NSQ topic for metrics.
|
|
||||||
# [[inputs.nsq_consumer]]
|
|
||||||
# ## An string representing the NSQD TCP Endpoint
|
|
||||||
# server = "localhost:4150"
|
|
||||||
# topic = "telegraf"
|
|
||||||
# channel = "consumer"
|
|
||||||
# max_in_flight = 100
|
|
||||||
#
|
|
||||||
# ## Data format to consume.
|
|
||||||
# ## Each data format has it's own unique set of configuration options, read
|
|
||||||
# ## more about them here:
|
|
||||||
# ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md
|
|
||||||
# data_format = "influx"
|
|
||||||
|
|
||||||
|
|
||||||
# # Statsd Server
|
|
||||||
# [[inputs.statsd]]
|
|
||||||
# ## Address and port to host UDP listener on
|
|
||||||
# service_address = ":8125"
|
|
||||||
# ## Delete gauges every interval (default=false)
|
|
||||||
# delete_gauges = false
|
|
||||||
# ## Delete counters every interval (default=false)
|
|
||||||
# delete_counters = false
|
|
||||||
# ## Delete sets every interval (default=false)
|
|
||||||
# delete_sets = false
|
|
||||||
# ## Delete timings & histograms every interval (default=true)
|
|
||||||
# delete_timings = true
|
|
||||||
# ## Percentiles to calculate for timing & histogram stats
|
|
||||||
# percentiles = [90]
|
|
||||||
#
|
|
||||||
# ## separator to use between elements of a statsd metric
|
|
||||||
# metric_separator = "_"
|
|
||||||
#
|
|
||||||
# ## Parses tags in the datadog statsd format
|
|
||||||
# ## http://docs.datadoghq.com/guides/dogstatsd/
|
|
||||||
# parse_data_dog_tags = false
|
|
||||||
#
|
|
||||||
# ## Statsd data translation templates, more info can be read here:
|
|
||||||
# ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md#graphite
|
|
||||||
# # templates = [
|
|
||||||
# # "cpu.* measurement*"
|
|
||||||
# # ]
|
|
||||||
#
|
|
||||||
# ## Number of UDP messages allowed to queue up, once filled,
|
|
||||||
# ## the statsd server will start dropping packets
|
|
||||||
# allowed_pending_messages = 10000
|
|
||||||
#
|
|
||||||
# ## Number of timing/histogram values to track per-measurement in the
|
|
||||||
# ## calculation of percentiles. Raising this limit increases the accuracy
|
|
||||||
# ## of percentiles but also increases the memory usage and cpu time.
|
|
||||||
# percentile_limit = 1000
|
|
||||||
|
|
||||||
|
|
||||||
# # Stream a log file, like the tail -f command
|
|
||||||
# [[inputs.tail]]
|
|
||||||
# ## files to tail.
|
|
||||||
# ## These accept standard unix glob matching rules, but with the addition of
|
|
||||||
# ## ** as a "super asterisk". ie:
|
|
||||||
# ## "/var/log/**.log" -> recursively find all .log files in /var/log
|
|
||||||
# ## "/var/log/*/*.log" -> find all .log files with a parent dir in /var/log
|
|
||||||
# ## "/var/log/apache.log" -> just tail the apache log file
|
|
||||||
# ##
|
|
||||||
# ## See https://github.com/gobwas/glob for more examples
|
|
||||||
# ##
|
|
||||||
# files = ["/var/mymetrics.out"]
|
|
||||||
# ## Read file from beginning.
|
|
||||||
# from_beginning = false
|
|
||||||
#
|
|
||||||
# ## Data format to consume.
|
|
||||||
# ## Each data format has it's own unique set of configuration options, read
|
|
||||||
# ## more about them here:
|
|
||||||
# ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md
|
|
||||||
# data_format = "influx"
|
|
||||||
|
|
||||||
|
|
||||||
# # Generic TCP listener
|
|
||||||
# [[inputs.tcp_listener]]
|
|
||||||
# ## Address and port to host TCP listener on
|
|
||||||
# service_address = ":8094"
|
|
||||||
#
|
|
||||||
# ## Number of TCP messages allowed to queue up. Once filled, the
|
|
||||||
# ## TCP listener will start dropping packets.
|
|
||||||
# allowed_pending_messages = 10000
|
|
||||||
#
|
|
||||||
# ## Maximum number of concurrent TCP connections to allow
|
|
||||||
# max_tcp_connections = 250
|
|
||||||
#
|
|
||||||
# ## Data format to consume.
|
|
||||||
# ## Each data format has it's own unique set of configuration options, read
|
|
||||||
# ## more about them here:
|
|
||||||
# ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md
|
|
||||||
# data_format = "influx"
|
|
||||||
|
|
||||||
|
|
||||||
# # Generic UDP listener
|
|
||||||
# [[inputs.udp_listener]]
|
|
||||||
# ## Address and port to host UDP listener on
|
|
||||||
# service_address = ":8092"
|
|
||||||
#
|
|
||||||
# ## Number of UDP messages allowed to queue up. Once filled, the
|
|
||||||
# ## UDP listener will start dropping packets.
|
|
||||||
# allowed_pending_messages = 10000
|
|
||||||
#
|
|
||||||
# ## Data format to consume.
|
|
||||||
# ## Each data format has it's own unique set of configuration options, read
|
|
||||||
# ## more about them here:
|
|
||||||
# ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md
|
|
||||||
# data_format = "influx"
|
|
||||||
|
|
||||||
|
|
||||||
# # A Webhooks Event collector
|
|
||||||
# [[inputs.webhooks]]
|
|
||||||
# ## Address and port to host Webhook listener on
|
|
||||||
# service_address = ":1619"
|
|
||||||
#
|
|
||||||
# [inputs.webhooks.github]
|
|
||||||
# path = "/github"
|
|
||||||
#
|
|
||||||
# [inputs.webhooks.mandrill]
|
|
||||||
# path = "/mandrill"
|
|
||||||
#
|
|
||||||
# [inputs.webhooks.rollbar]
|
|
||||||
# path = "/rollbar"
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user