12.04.2016, 14:21
I like to log all the bus traffic to my mysql database.
How to do this with on a resource frendly way?
How to do this with on a resource frendly way?
Log all bus traffic
|
12.04.2016, 14:21
I like to log all the bus traffic to my mysql database.
How to do this with on a resource frendly way?
15.04.2016, 08:41
for now you can mark all objects with Log check-box and use this example to export CSV once hour/day to external server:
http://openrb.com/example-export-last-ho...-from-lm2/ In the future, we will make a real-time example for exporting this data.
19.04.2016, 14:09
(This post was last modified: 19.04.2016, 14:09 by gjniewenhuijse.)
maybe something like this?
But how to show the datahex in readable format? And is it possible to add a general handler, also for groupreads etc? Code: 12345678910111213141516171819 if not client then
require('genohm-scada.eibdgm')
-- handle group writes
function eventhandler(event)
log(event) -- later send this to mysql
--log(knxdatatype.decode(event.datahex,?))
end
-- knx connection
client = eibdgm:new({ timeout = 1 })
client:sethandler('groupwrite', eventhandler)
-- start-up time
sec, usec = os.microtime()
end
-- handle knx
client:step()
20.04.2016, 10:08
Something like this, though it will not work on older FW where grp.all function is not implemented.
Code: 12345678910111213141516171819202122232425262728 if not client then
require('genohm-scada.eibdgm')
objects = grp.all()
datatypes = {}
for _, object in ipairs(objects) do
datatypes[ object.id ] = object.datatype
end
function writehandler(event)
local dpt = datatypes[ event.dstraw ]
if dpt then
local value = knxdatatype.decode(event.datahex, dpt)
end
end
function readhandler(event)
log(event)
end
client:sethandler('groupwrite', writehandler)
client:sethandler('groupresponse', writehandler)
client:sethandler('groupread', readhandler)
end
-- handle knx
client:step()
20.04.2016, 12:21
May be modify script for support sending to SYSLOG collector?
My simple variant for sending all data to SYSLOG server
In User Libraries need create function syslog: Code: 123456789 function syslog(message)
require('socket')
local client = socket.udp()
if client then
client:sendto(message, '192.168.19.254', 514)
client:close()
end
endAfter this markup all objects with tag "All" Create new event-based script "Send all messages to SYSLOG" for tag "All" Code: 12345678 name = grp.alias(event.dst)
-- Fix Group name for empty values
if (name == nil or name == '') then
name = "Noname"
end
value = '"'..name..'" '..event.src..' '..event.dst..' '..event.type..' '..knxdatatype.decode(event.datahex, grp.find(event.dst).datatype)..' 0x'..event.datahex
syslog(value)Sample of log: 2016-04-26T22:52:34.084297+03:00 192.168.16.200 "Wind speed (m/s)" 1.0.1 5/0/6 groupwrite 2.6 0x0104 2016-04-26T22:52:39.817766+03:00 192.168.16.200 "Wind speed (m/s)" 1.0.1 5/0/6 groupwrite 4.5 0x01C2 2016-04-26T22:52:42.632619+03:00 192.168.16.200 "Wind speed (m/s)" 1.0.1 5/0/6 groupwrite 2.7 0x010E 2016-04-26T22:52:45.231188+03:00 192.168.16.200 "Wind speed (m/s)" 1.0.1 5/0/6 groupwrite 3.3 0x014A 2016-04-26T22:52:50.097556+03:00 192.168.16.200 "Wind speed (m/s)" 1.0.1 5/0/6 groupwrite 1.6 0x00A0 2016-04-26T22:52:51.595747+03:00 192.168.16.200 "Noname" 1.3.2 2/2/3 groupwrite 21.4 0x0C2E 2016-04-26T22:52:57.809525+03:00 192.168.16.200 "Temp in room 37" 1.3.22 2/1/24 groupwrite 24.02 0x0CB1 |
« Next Oldest | Next Newest »
|