This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

rrdtool problem
#6
Hi,

For those who might be interested to get these multi-valued graphs in their visualization, this is what I ended up doing:

-mark the objects to be used as 'export'.
-the second step involves another server that runs 24x7, otherwise the graphs will be incomplete... I used a powerful machine that I use for backups, Logitech Media Server, zoneminder, etc. I believe that a simple raspberry should do the trick also.
-create rrd archive (see original post).
-schedule a script that runs every x minutes. My script fetches the data, updates the rrd, creates the graph and moves it to the DocumentRoot of the webserver.

This is the script (note that this is quite a basic script with no error checking etc...


Code:
require('socket.http')
socket.http.TIMEOUT = 15

-- get data
local LM_data = socket.http.request('http://remote:remote@<ip_of_LM>/scada-remote?m=xml&r=objects')

if not LM_data then
 log('Data cannot be fetched.')
 return
end
for i in string.gmatch(LM_data, '<object.-</object>') do
 if i ~= nil then
     address =  i:match([[<address>(.-)</address>]])
     data =  i:match([[<data>(.-)</data>]])
     if address == '4/1/11' then
         T_intake = data
     end
     if address == '4/1/12' then
         T_supply = data
     end
     if address == '4/1/14' then
         T_discharge = data
     end
     if address == '4/1/13' then
         T_exhaust = data
     end
 end
end

-- update rrd
rrdupdate = "rrdtool update <path_to>/ventilatie.rrd N:" ..T_intake ..":" ..T_supply ..":" ..T_discharge ..":" ..T_exhaust

result = os.execute(rrdupdate)

--create graph
rrdgraph = "rrdtool graph <path_to>/ventilatie.png -a PNG --title='Ventilatie °C' --slope-mode " ..
" DEF:T_i=<path_to>/ventilatie.rrd:T_intake:AVERAGE " ..
" DEF:T_s=<path_to>/ventilatie.rrd:T_supply:AVERAGE " ..
" DEF:T_d=<path_to>/ventilatie.rrd:T_discharge:AVERAGE " ..
" DEF:T_e=<path_to>/ventilatie.rrd:T_exhaust:AVERAGE " ..
" --width 640" ..
" --height 240" ..
" --full-size-mode" ..
" --color BACK#243d47" ..
" --color CANVAS#243d47" ..
" --color FRAME#243d47" ..
" --color FONT#ffffff" ..
" --color AXIS#515d62" ..
" --color GRID#515d62" ..
" --color MGRID#515d62" ..
" --font TITLE:13:Arial" ..
" --font AXIS:10:Arial" ..
" --font LEGEND:9:Arial" ..
" --grid-dash 1:0" ..
" --border 0" ..
" --y-grid 10:1" ..
" LINE1:T_i#ff0000:' Invoer'" ..
" LINE1:T_s#0400ff:' Toevoer'" ..
" LINE1:T_d#aaff00:' Afvoer'" ..
" LINE1:T_e#35b73d:' Uitvoer'"

result = os.execute(rrdgraph)

-- move graph to web server
result = os.execute("sudo mv <path_to>/ventialtie.png /var/www/html/ventilatie")

Attached is the result.

Attached Files Thumbnail(s)
   
Reply


Messages In This Thread
rrdtool problem - by baggins - 12.03.2017, 22:25
RE: rrdtool problem - by admin - 13.03.2017, 07:31
RE: rrdtool problem - by baggins - 13.03.2017, 07:53
RE: rrdtool problem - by Thomas - 13.03.2017, 12:58
RE: rrdtool problem - by baggins - 13.03.2017, 15:28
RE: rrdtool problem - by baggins - 14.03.2017, 21:53
RE: rrdtool problem - by Thomas - 15.03.2017, 13:32
RE: rrdtool problem - by baggins - 15.03.2017, 15:04

Forum Jump: