mirror of
https://github.com/Telecominfraproject/ols-ucentral-schema.git
synced 2025-11-02 02:57:55 +00:00
fix race between state and telemetry streaming
Signed-off-by: John Crispin <john@phrozen.org>
This commit is contained in:
@@ -1,6 +1,12 @@
|
||||
#!/usr/bin/ucode
|
||||
{%
|
||||
let fs = require("fs");
|
||||
|
||||
/* if we are actively streaming telemetry then the state handler does not need to run
|
||||
independently */
|
||||
if (!telemetry && fs.stat("/tmp/ucentral.telemetry"))
|
||||
return 0;
|
||||
|
||||
let uci = require("uci");
|
||||
let ubus = require("ubus");
|
||||
let cfgfile = fs.open("/etc/ucentral/ucentral.active", "r");
|
||||
@@ -297,6 +303,12 @@
|
||||
if (length(stations[vap.ifname]))
|
||||
ssid.associations = stations[vap.ifname];
|
||||
|
||||
|
||||
ssid.iface = vap.ifname;
|
||||
ssid.counters = ports[vap.ifname].stats;
|
||||
if (!ssid.counters)
|
||||
delete ssid.counters;
|
||||
|
||||
push(ssids, ssid);
|
||||
}
|
||||
counter++;
|
||||
@@ -380,6 +392,9 @@
|
||||
};
|
||||
ctx.call("ucentral", "stats", msg);
|
||||
|
||||
if (telemetry)
|
||||
ctx.call("ucentral", "event", { "event": "state", "payload": msg });
|
||||
|
||||
let f = fs.open("/tmp/ucentral.state", "w");
|
||||
if (f) {
|
||||
f.write(msg);
|
||||
|
||||
10
system/telemetry.uc
Executable file
10
system/telemetry.uc
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/usr/bin/ucode
|
||||
{%
|
||||
let fs = require("fs");
|
||||
let f = fs.open("/tmp/ucentral.telemetry", "w");
|
||||
if (f)
|
||||
f.close();
|
||||
|
||||
telemetry = true;
|
||||
include("state.uc");
|
||||
%}
|
||||
Reference in New Issue
Block a user