Monté un banc test pour trouver pourquoi il plante toutes les heures environ, je le mets en stress avec pleins de http_post

This commit is contained in:
Christian Zufferey
2020-06-10 18:48:26 +02:00
parent 40cb639ea4
commit 6839ae56b4
5 changed files with 33 additions and 20 deletions

View File

@@ -1,15 +1,22 @@
-- Petit script pour faire office de crontab pour les mesures
print("\n 0_cron.lua zf200604.1629 \n")
print("\n 0_cron.lua zf200610.1838 \n")
cron1=tmr.create()
cron1:alarm(10*1000, tmr.ALARM_AUTO, function()
if verbose then print("cron1........................") end
if verbose then gpio.write(zLED, gpio.LOW) tmr.delay(10000) gpio.write(zLED, gpio.HIGH) end
-- http_post(influxdb_url,"energy,value=test1_"..yellow_id.." val=1")
http_post(influxdb_url,"energy,value=test1_"..yellow_id.." val=1")
http_post(influxdb_url,"energy,memory=cron1_"..yellow_id.." ram="..node.heap())
http_post(influxdb_url,"energy,compteur=3 puissance="..zpower/1000)
-- http_post(influxdb_url,"energy,value=test2_"..yellow_id.." val=2")
if yellow_id == 60 then http_post(influxdb_url,"energy,compteur=3 puissance="..zpower/1000) end
if yellow_id == 64 then http_post(influxdb_url,"energy,compteur=4 puissance="..zpower/1000) end
http_post(influxdb_url,"energy,value=test2_"..yellow_id.." val=2")
http_post(influxdb_url,"energy,value=test3_"..yellow_id.." val=3")
http_post(influxdb_url,"energy,value=test4_"..yellow_id.." val=4")
-- f = "0_zdyndns.lua" if file.exists(f) then dofile(f) end

View File

@@ -1,6 +1,6 @@
-- Lit le convertisseur ADC connecté sur le transformateur de courant
-- pour mesurer le courant électrique de l'installation PV
print("\n 0_get_power.lua zf200605.1050 \n")
print("\n 0_get_power.lua zf200610.1154 \n")
-- Astuce de mesure:
-- On converti le courant en tension avec la résistance de charge du
@@ -55,6 +55,7 @@ function calc_rms()
if zadc_rms<=4 then zadc_rms=0 end
zadc_offset=math.floor(zadc_offset_sum/znb_mes)
zpower=math.floor(zadc_rms*zpow_cal/zadc_cal)
if verbose then print(node.heap()) end
if verbose then print(zadc_min,zadc_max,zadc_max-zadc_min,zadc_offset,zadc_rms,zpower.."W") end
zadc_min=zadc_offset zadc_max=zadc_offset
zadc_sum=0 zadc_offset_sum=0 znb_mes=0

View File

@@ -1,7 +1,7 @@
-- Petit script pour envoyer en // es valeurs sur un serveur WEB (InfluxDB)
-- via un http POST à travers un FIFO
if verbose then print("\n 0_http_post.lua zf200607.1639 \n") end
if verbose then print("\n 0_http_post.lua zf200610.1822 \n") end
t_zurl={} t_zarg={} f_zpost=false
@@ -40,8 +40,7 @@ function zpost()
end
function http_post(zurl,zarg)
table.insert(t_zurl, zurl) table.insert(t_zarg, zarg)
if #t_zurl <=10 then table.insert(t_zurl, zurl) table.insert(t_zarg, zarg) end
if verbose then print("Nb wait: "..#t_zurl) print(node.heap()) end
if verbose then print("t_zurl:") tprint(t_zurl) print("t_zarg:") tprint(t_zarg) end
if f_zpost==false then zpost() end

View File

@@ -27,7 +27,7 @@ telnet -rN localhost 23000
]]
print("\n 0_tst4_socat.lua zf200607.1102 \n")
print("\n 0_tst4_socat.lua zf200610.1826 \n")
local node, table, tmr, uwrite, tostring =
node, table, tmr, uart.write, tostring
@@ -164,6 +164,9 @@ tmr_socat1:alarm(15*1000, tmr.ALARM_AUTO , function()
-- rt_retry=1
-- if verbose then gpio.write(zLED, gpio.LOW) tmr.delay(10000) gpio.write(zLED, gpio.HIGH) end
if srv_rt~=nil then
if http_post~=nil then http_post(influxdb_url,"energy,memory=srv_rt_no_nil_"..yellow_id.." ram="..node.heap()) end
if console_port ~= srv_rt:getpeer() then
--on relance...
rt_connect()

View File

@@ -1,7 +1,7 @@
-- Petit script pour initaliser la couche WIFI
function wifi_init()
print("\n wifi_init.lua zf200606.1223 \n")
print("\n wifi_init.lua zf200610.1835 \n")
f= "secrets_wifi.lua" if file.exists(f) then dofile(f) end
f= "secrets_project.lua" if file.exists(f) then dofile(f) end
@@ -47,17 +47,20 @@ function wifi_init()
end)
print("setup gadget lancé...")
else
wifi.setmode(wifi.STATIONAP,true)
wifi.setmode(wifi.STATION,true)
wifi.sta.config{ssid=cli_ssid, pwd=cli_pwd} wifi.sta.connect()
if node_id == nil then node_id = "generic" ap_pwd = "12345678" end
wifi.ap.config({ ssid = ap_ssid.."_"..node_id, pwd = ap_pwd, save=true })
ap_ssid=nil ap_pwd=nil
tmr_wifi_init2=tmr.create()
tmr_wifi_init2:alarm(60*1000, tmr.ALARM_SINGLE, function()
print("BOOOOUM, y'a plus de AP WIFI !")
wifi.setmode(wifi.STATION,true) tmr_wifi_init2=nil
print(node.heap()) collectgarbage() print(node.heap())
end)
-- wifi.setmode(wifi.STATIONAP,true)
-- if node_id == nil then node_id = "generic" ap_pwd = "12345678" end
-- wifi.ap.config({ ssid = ap_ssid.."_"..node_id, pwd = ap_pwd, save=true })
-- ap_ssid=nil ap_pwd=nil
-- tmr_wifi_init2=tmr.create()
-- tmr_wifi_init2:alarm(60*1000, tmr.ALARM_SINGLE, function()
-- print("BOOOOUM, y'a plus de AP WIFI !")
-- wifi.setmode(wifi.STATION,true) tmr_wifi_init2=nil
-- print(node.heap()) collectgarbage() print(node.heap())
-- end)
gpio.write(zLED, gpio.HIGH) gpio.mode(zLED, gpio.OUTPUT) i=1
tmr_wifi_init1=tmr.create()
tmr_wifi_init1:alarm(1*1000, tmr.ALARM_AUTO , function()