move health_check settings tp the metric deictionary

Signed-off-by: John Crispin <john@phrozen.org>
This commit is contained in:
John Crispin
2022-10-27 17:01:36 +02:00
parent 9968cb6688
commit 85698d247b
8 changed files with 97 additions and 136 deletions

View File

@@ -6,3 +6,7 @@
# Health configuration
set ustats.health.interval={{ health.interval }}
set ustats.health.dhcp_local={{ b(health.dhcp_local) }}
set ustats.health.dhcp_remote={{ b(health.dhcp_remote) }}
set ustats.health.dns_local={{ b(health.dns_local) }}
set ustats.health.dns_remote={{ b(health.dns_remote) }}

View File

@@ -1,12 +0,0 @@
{% if (!length(health_check))
health_check = {
dhcp_local: 1,
dhcp_remote: 0,
dns_local: 1,
dns_remote: 1,
};
%}
set health.config.dhcp_local={{ b(health_check.dhcp_local) }}
set health.config.dhcp_remote={{ b(health_check.dhcp_remote) }}
set health.config.dns_local={{ b(health_check.dns_local) }}
set health.config.dns_remote={{ b(health_check.dns_remote) }}

View File

@@ -8,3 +8,23 @@ properties:
The reporting interval defined in seconds.
type: integer
minimum: 60
dhcp-local:
description:
This is makes the AP probe local downstream DHCP servers.
type: boolean
default: true
dhcp-remote:
description:
This is makes the AP probe remote upstream DHCP servers.
type: boolean
default: false
dns-local:
description:
This is makes the AP probe DNS servers.
type: boolean
default: true
dns-remote:
description:
This is makes the AP probe DNS servers.
type: boolean
default: true

View File

@@ -1,24 +0,0 @@
type: object
description:
This section can be used to setup the services that health check will probe.
properties:
dhcp-local:
description:
This is makes the AP probe local downstream DHCP servers.
type: boolean
default: true
dhcp-remote:
description:
This is makes the AP probe remote upstream DHCP servers.
type: boolean
default: false
dns-local:
description:
This is makes the AP probe DNS servers.
type: boolean
default: true
dns-remote:
description:
This is makes the AP probe DNS servers.
type: boolean
default: true

View File

@@ -37,7 +37,5 @@ properties:
$ref: "https://ucentral.io/schema/v1/service/airtime-fairness/"
wireguard-overlay:
$ref: 'https://ucentral.io/schema/v1/service/wireguard-overlay/'
health-check:
$ref: 'https://ucentral.io/schema/v1/service/health-check/'
captive:
$ref: 'https://ucentral.io/schema/v1/service/captive/'

View File

@@ -7220,75 +7220,6 @@ function instantiateServiceWireguardOverlay(location, value, errors) {
return value;
}
function instantiateServiceHealthCheck(location, value, errors) {
if (type(value) == "object") {
let obj = {};
function parseDhcpLocal(location, value, errors) {
if (type(value) != "bool")
push(errors, [ location, "must be of type boolean" ]);
return value;
}
if (exists(value, "dhcp-local")) {
obj.dhcp_local = parseDhcpLocal(location + "/dhcp-local", value["dhcp-local"], errors);
}
else {
obj.dhcp_local = true;
}
function parseDhcpRemote(location, value, errors) {
if (type(value) != "bool")
push(errors, [ location, "must be of type boolean" ]);
return value;
}
if (exists(value, "dhcp-remote")) {
obj.dhcp_remote = parseDhcpRemote(location + "/dhcp-remote", value["dhcp-remote"], errors);
}
else {
obj.dhcp_remote = false;
}
function parseDnsLocal(location, value, errors) {
if (type(value) != "bool")
push(errors, [ location, "must be of type boolean" ]);
return value;
}
if (exists(value, "dns-local")) {
obj.dns_local = parseDnsLocal(location + "/dns-local", value["dns-local"], errors);
}
else {
obj.dns_local = true;
}
function parseDnsRemote(location, value, errors) {
if (type(value) != "bool")
push(errors, [ location, "must be of type boolean" ]);
return value;
}
if (exists(value, "dns-remote")) {
obj.dns_remote = parseDnsRemote(location + "/dns-remote", value["dns-remote"], errors);
}
else {
obj.dns_remote = true;
}
return obj;
}
if (type(value) != "object")
push(errors, [ location, "must be of type object" ]);
return value;
}
function instantiateServiceCaptiveClick(location, value, errors) {
if (type(value) == "object") {
let obj = {};
@@ -8060,10 +7991,6 @@ function instantiateService(location, value, errors) {
obj.wireguard_overlay = instantiateServiceWireguardOverlay(location + "/wireguard-overlay", value["wireguard-overlay"], errors);
}
if (exists(value, "health-check")) {
obj.health_check = instantiateServiceHealthCheck(location + "/health-check", value["health-check"], errors);
}
if (exists(value, "captive")) {
obj.captive = instantiateServiceCaptive(location + "/captive", value["captive"], errors);
}
@@ -8153,6 +8080,62 @@ function instantiateMetricsHealth(location, value, errors) {
obj.interval = parseInterval(location + "/interval", value["interval"], errors);
}
function parseDhcpLocal(location, value, errors) {
if (type(value) != "bool")
push(errors, [ location, "must be of type boolean" ]);
return value;
}
if (exists(value, "dhcp-local")) {
obj.dhcp_local = parseDhcpLocal(location + "/dhcp-local", value["dhcp-local"], errors);
}
else {
obj.dhcp_local = true;
}
function parseDhcpRemote(location, value, errors) {
if (type(value) != "bool")
push(errors, [ location, "must be of type boolean" ]);
return value;
}
if (exists(value, "dhcp-remote")) {
obj.dhcp_remote = parseDhcpRemote(location + "/dhcp-remote", value["dhcp-remote"], errors);
}
else {
obj.dhcp_remote = false;
}
function parseDnsLocal(location, value, errors) {
if (type(value) != "bool")
push(errors, [ location, "must be of type boolean" ]);
return value;
}
if (exists(value, "dns-local")) {
obj.dns_local = parseDnsLocal(location + "/dns-local", value["dns-local"], errors);
}
else {
obj.dns_local = true;
}
function parseDnsRemote(location, value, errors) {
if (type(value) != "bool")
push(errors, [ location, "must be of type boolean" ]);
return value;
}
if (exists(value, "dns-remote")) {
obj.dns_remote = parseDnsRemote(location + "/dns-remote", value["dns-remote"], errors);
}
else {
obj.dns_remote = true;
}
return obj;
}

View File

@@ -21,7 +21,7 @@ cursor.load("health");
cursor.load("dhcp");
cursor.load("network");
cursor.load("wireless");
let config = cursor.get_all("health", "config");
let config = cursor.get_all("ustats", "health");
let dhcp = cursor.get_all("dhcp");
let wifi_config = cursor.get_all("wireless");
let wifi_state = require('wifi.iface');

View File

@@ -2630,27 +2630,6 @@
}
}
},
"service.health-check": {
"type": "object",
"properties": {
"dhcp-local": {
"type": "boolean",
"default": true
},
"dhcp-remote": {
"type": "boolean",
"default": false
},
"dns-local": {
"type": "boolean",
"default": true
},
"dns-remote": {
"type": "boolean",
"default": true
}
}
},
"service.captive.click": {
"type": "object",
"properties": {
@@ -2913,9 +2892,6 @@
"wireguard-overlay": {
"$ref": "#/$defs/service.wireguard-overlay"
},
"health-check": {
"$ref": "#/$defs/service.health-check"
},
"captive": {
"$ref": "#/$defs/service.captive"
}
@@ -2947,6 +2923,22 @@
"interval": {
"type": "integer",
"minimum": 60
},
"dhcp-local": {
"type": "boolean",
"default": true
},
"dhcp-remote": {
"type": "boolean",
"default": false
},
"dns-local": {
"type": "boolean",
"default": true
},
"dns-remote": {
"type": "boolean",
"default": true
}
}
},