[fix] various

This commit is contained in:
Christian Fraß 2023-08-31 19:15:40 +02:00
parent 20f2d93bfa
commit ccdbe1f0df
6 changed files with 147 additions and 432 deletions

View file

@ -6,11 +6,16 @@ namespace _heimdall.helpers.misc
export function get_env_language( export function get_env_language(
) : (null | string) ) : (null | string)
{ {
const env_lang : string = process.env["LANG"]; const env_lang : (undefined | string) = process.env["LANG"];
if (env_lang === undefined) {
return null;
}
else {
const locale : string = env_lang.split(".")[0]; const locale : string = env_lang.split(".")[0];
const language : string = locale.split("_")[0]; const language : string = locale.split("_")[0];
return language; return language;
} }
}
/** /**
*/ */

View file

@ -25,12 +25,12 @@ namespace _heimdall.master
( (
(old_item_state === null) (old_item_state === null)
|| ||
(old_item_state.condition !== _heimdall.enum_condition.ok)
||
((options.timestamp - old_item_state.timestamp) >= check.schedule.regular_interval) ((options.timestamp - old_item_state.timestamp) >= check.schedule.regular_interval)
|| ||
( (
(! (old_item_state.count === null)) (old_item_state.count !== null)
&&
(old_item_state.condition !== _heimdall.enum_condition.ok)
&& &&
((options.timestamp - old_item_state.timestamp) >= check.schedule.attentive_interval) ((options.timestamp - old_item_state.timestamp) >= check.schedule.attentive_interval)
) )
@ -42,7 +42,7 @@ namespace _heimdall.master
/** /**
* @todo automated tests * @todo automated tests
*/ */
function determine_shall_send_notification( export function determine_shall_send_notification(
check : _heimdall.type_check, check : _heimdall.type_check,
send_ok_notifications : boolean, send_ok_notifications : boolean,
count : (null | int), count : (null | int),
@ -234,42 +234,35 @@ namespace _heimdall.master
} }
> = await _heimdall.state_repository.probe( > = await _heimdall.state_repository.probe(
check.name, check.name,
(check.threshold + 1), (check.threshold + 1)
); );
if (rows.length <= 0) { if (rows.length <= 0) {
old_item_state = null; old_item_state = null;
} }
else { else {
let count : int = 1; let index : int = 1;
rows.slice(1).some( while (index < rows.length) {
(row) => { if (rows[index].condition === rows[0].condition) {
if (row.condition === rows[0].condition) { index += 1;
count += 1;
return true;
} }
else { else {
return false; break;
} }
} }
);
if (count > check.threshold) {
count = null;
}
else {
// do nothing
}
old_item_state = { old_item_state = {
"timestamp": rows[0].timestamp, "timestamp": rows[0].timestamp,
"condition": rows[0].condition, "condition": rows[0].condition,
"count": count, "count": ((index < check.threshold) ? index : null),
"last_notification_timestamp": last_notification_timestamp, "last_notification_timestamp": last_notification_timestamp,
} };
} }
const timestamp : int = _heimdall.get_current_timestamp(); const timestamp : int = _heimdall.get_current_timestamp();
const due : boolean = determine_due( const due : boolean = determine_due(
check, check,
timestamp, old_item_state,
old_item_state {
"timestamp": timestamp,
}
); );
if (! due) { if (! due) {
// do nothing // do nothing

View file

@ -375,7 +375,7 @@ namespace _heimdall.order
} }
else { else {
const node_ : type_check = Object.assign( const node_ : type_check = Object.assign(
Object.assign( lib_plankton.object.patched(
defaults, defaults,
{ {
"title": node.name, "title": node.name,
@ -473,19 +473,19 @@ namespace _heimdall.order
("defaults" in node) ("defaults" in node)
? node["defaults"] ? node["defaults"]
: {} : {}
) );
const defaults : type_check_common = ( const defaults : type_check_common = (
options.use_implicit_default_values options.use_implicit_default_values
? normalize_defaults( ? normalize_defaults(
defaults_raw defaults_raw
) )
: defaults_raw : defaults_raw
) );
const includes : Array<string> = ( const includes : Array<string> = (
("includes" in node) ("includes" in node)
? node["includes"] ? node["includes"]
: [] : []
) );
return { return {
"defaults": defaults, "defaults": defaults,
"includes": includes, "includes": includes,

View file

@ -14,7 +14,7 @@
"kind": "BOGUS", "kind": "BOGUS",
"parameters": {}, "parameters": {},
"custom": null, "custom": null,
"annoy": true "annoy": false
}, },
"old_item_state": { "old_item_state": {
"timestamp": "2023-01-15T11:00:00", "timestamp": "2023-01-15T11:00:00",
@ -23,19 +23,17 @@
}, },
"cases": [ "cases": [
{ {
"name": "{\"annoy\":false,\"condition\":\"unknown\",\"threshold_reached\":false,\"passed\":\"none\"}", "name": "{\"condition\":\"unknown\",\"threshold_reached\":false,\"passed\":\"none\"}",
"input": { "input": {
"annoy": false,
"condition": "unknown", "condition": "unknown",
"threshold_reached": false, "threshold_reached": false,
"passed": "none" "passed": "none"
}, },
"output": true "output": false
}, },
{ {
"name": "{\"annoy\":false,\"condition\":\"unknown\",\"threshold_reached\":false,\"passed\":\"attentive\"}", "name": "{\"condition\":\"unknown\",\"threshold_reached\":false,\"passed\":\"attentive\"}",
"input": { "input": {
"annoy": false,
"condition": "unknown", "condition": "unknown",
"threshold_reached": false, "threshold_reached": false,
"passed": "attentive" "passed": "attentive"
@ -43,9 +41,8 @@
"output": true "output": true
}, },
{ {
"name": "{\"annoy\":false,\"condition\":\"unknown\",\"threshold_reached\":false,\"passed\":\"regular\"}", "name": "{\"condition\":\"unknown\",\"threshold_reached\":false,\"passed\":\"regular\"}",
"input": { "input": {
"annoy": false,
"condition": "unknown", "condition": "unknown",
"threshold_reached": false, "threshold_reached": false,
"passed": "regular" "passed": "regular"
@ -53,9 +50,8 @@
"output": true "output": true
}, },
{ {
"name": "{\"annoy\":false,\"condition\":\"unknown\",\"threshold_reached\":false,\"passed\":\"reminding\"}", "name": "{\"condition\":\"unknown\",\"threshold_reached\":false,\"passed\":\"reminding\"}",
"input": { "input": {
"annoy": false,
"condition": "unknown", "condition": "unknown",
"threshold_reached": false, "threshold_reached": false,
"passed": "reminding" "passed": "reminding"
@ -63,29 +59,26 @@
"output": true "output": true
}, },
{ {
"name": "{\"annoy\":false,\"condition\":\"unknown\",\"threshold_reached\":true,\"passed\":\"none\"}", "name": "{\"condition\":\"unknown\",\"threshold_reached\":true,\"passed\":\"none\"}",
"input": { "input": {
"annoy": false,
"condition": "unknown", "condition": "unknown",
"threshold_reached": true, "threshold_reached": true,
"passed": "none" "passed": "none"
}, },
"output": true "output": false
}, },
{ {
"name": "{\"annoy\":false,\"condition\":\"unknown\",\"threshold_reached\":true,\"passed\":\"attentive\"}", "name": "{\"condition\":\"unknown\",\"threshold_reached\":true,\"passed\":\"attentive\"}",
"input": { "input": {
"annoy": false,
"condition": "unknown", "condition": "unknown",
"threshold_reached": true, "threshold_reached": true,
"passed": "attentive" "passed": "attentive"
}, },
"output": true "output": false
}, },
{ {
"name": "{\"annoy\":false,\"condition\":\"unknown\",\"threshold_reached\":true,\"passed\":\"regular\"}", "name": "{\"condition\":\"unknown\",\"threshold_reached\":true,\"passed\":\"regular\"}",
"input": { "input": {
"annoy": false,
"condition": "unknown", "condition": "unknown",
"threshold_reached": true, "threshold_reached": true,
"passed": "regular" "passed": "regular"
@ -93,9 +86,8 @@
"output": true "output": true
}, },
{ {
"name": "{\"annoy\":false,\"condition\":\"unknown\",\"threshold_reached\":true,\"passed\":\"reminding\"}", "name": "{\"condition\":\"unknown\",\"threshold_reached\":true,\"passed\":\"reminding\"}",
"input": { "input": {
"annoy": false,
"condition": "unknown", "condition": "unknown",
"threshold_reached": true, "threshold_reached": true,
"passed": "reminding" "passed": "reminding"
@ -103,9 +95,8 @@
"output": true "output": true
}, },
{ {
"name": "{\"annoy\":false,\"condition\":\"ok\",\"threshold_reached\":false,\"passed\":\"none\"}", "name": "{\"condition\":\"ok\",\"threshold_reached\":false,\"passed\":\"none\"}",
"input": { "input": {
"annoy": false,
"condition": "ok", "condition": "ok",
"threshold_reached": false, "threshold_reached": false,
"passed": "none" "passed": "none"
@ -113,19 +104,17 @@
"output": false "output": false
}, },
{ {
"name": "{\"annoy\":false,\"condition\":\"ok\",\"threshold_reached\":false,\"passed\":\"attentive\"}", "name": "{\"condition\":\"ok\",\"threshold_reached\":false,\"passed\":\"attentive\"}",
"input": { "input": {
"annoy": false,
"condition": "ok", "condition": "ok",
"threshold_reached": false, "threshold_reached": false,
"passed": "attentive" "passed": "attentive"
}, },
"output": true "output": false
}, },
{ {
"name": "{\"annoy\":false,\"condition\":\"ok\",\"threshold_reached\":false,\"passed\":\"regular\"}", "name": "{\"condition\":\"ok\",\"threshold_reached\":false,\"passed\":\"regular\"}",
"input": { "input": {
"annoy": false,
"condition": "ok", "condition": "ok",
"threshold_reached": false, "threshold_reached": false,
"passed": "regular" "passed": "regular"
@ -133,9 +122,8 @@
"output": true "output": true
}, },
{ {
"name": "{\"annoy\":false,\"condition\":\"ok\",\"threshold_reached\":false,\"passed\":\"reminding\"}", "name": "{\"condition\":\"ok\",\"threshold_reached\":false,\"passed\":\"reminding\"}",
"input": { "input": {
"annoy": false,
"condition": "ok", "condition": "ok",
"threshold_reached": false, "threshold_reached": false,
"passed": "reminding" "passed": "reminding"
@ -143,9 +131,8 @@
"output": true "output": true
}, },
{ {
"name": "{\"annoy\":false,\"condition\":\"ok\",\"threshold_reached\":true,\"passed\":\"none\"}", "name": "{\"condition\":\"ok\",\"threshold_reached\":true,\"passed\":\"none\"}",
"input": { "input": {
"annoy": false,
"condition": "ok", "condition": "ok",
"threshold_reached": true, "threshold_reached": true,
"passed": "none" "passed": "none"
@ -153,9 +140,8 @@
"output": false "output": false
}, },
{ {
"name": "{\"annoy\":false,\"condition\":\"ok\",\"threshold_reached\":true,\"passed\":\"attentive\"}", "name": "{\"condition\":\"ok\",\"threshold_reached\":true,\"passed\":\"attentive\"}",
"input": { "input": {
"annoy": false,
"condition": "ok", "condition": "ok",
"threshold_reached": true, "threshold_reached": true,
"passed": "attentive" "passed": "attentive"
@ -163,9 +149,8 @@
"output": false "output": false
}, },
{ {
"name": "{\"annoy\":false,\"condition\":\"ok\",\"threshold_reached\":true,\"passed\":\"regular\"}", "name": "{\"condition\":\"ok\",\"threshold_reached\":true,\"passed\":\"regular\"}",
"input": { "input": {
"annoy": false,
"condition": "ok", "condition": "ok",
"threshold_reached": true, "threshold_reached": true,
"passed": "regular" "passed": "regular"
@ -173,9 +158,8 @@
"output": true "output": true
}, },
{ {
"name": "{\"annoy\":false,\"condition\":\"ok\",\"threshold_reached\":true,\"passed\":\"reminding\"}", "name": "{\"condition\":\"ok\",\"threshold_reached\":true,\"passed\":\"reminding\"}",
"input": { "input": {
"annoy": false,
"condition": "ok", "condition": "ok",
"threshold_reached": true, "threshold_reached": true,
"passed": "reminding" "passed": "reminding"
@ -183,389 +167,62 @@
"output": true "output": true
}, },
{ {
"name": "{\"annoy\":false,\"condition\":\"concerning\",\"threshold_reached\":false,\"passed\":\"none\"}", "name": "{\"condition\":\"concerning\",\"threshold_reached\":false,\"passed\":\"none\"}",
"input": { "input": {
"annoy": false,
"condition": "concerning", "condition": "concerning",
"threshold_reached": false, "threshold_reached": false,
"passed": "none" "passed": "none"
}, },
"output": true
},
{
"name": "{\"annoy\":false,\"condition\":\"concerning\",\"threshold_reached\":false,\"passed\":\"attentive\"}",
"input": {
"annoy": false,
"condition": "concerning",
"threshold_reached": false,
"passed": "attentive"
},
"output": true
},
{
"name": "{\"annoy\":false,\"condition\":\"concerning\",\"threshold_reached\":false,\"passed\":\"regular\"}",
"input": {
"annoy": false,
"condition": "concerning",
"threshold_reached": false,
"passed": "regular"
},
"output": true
},
{
"name": "{\"annoy\":false,\"condition\":\"concerning\",\"threshold_reached\":false,\"passed\":\"reminding\"}",
"input": {
"annoy": false,
"condition": "concerning",
"threshold_reached": false,
"passed": "reminding"
},
"output": true
},
{
"name": "{\"annoy\":false,\"condition\":\"concerning\",\"threshold_reached\":true,\"passed\":\"none\"}",
"input": {
"annoy": false,
"condition": "concerning",
"threshold_reached": true,
"passed": "none"
},
"output": true
},
{
"name": "{\"annoy\":false,\"condition\":\"concerning\",\"threshold_reached\":true,\"passed\":\"attentive\"}",
"input": {
"annoy": false,
"condition": "concerning",
"threshold_reached": true,
"passed": "attentive"
},
"output": true
},
{
"name": "{\"annoy\":false,\"condition\":\"concerning\",\"threshold_reached\":true,\"passed\":\"regular\"}",
"input": {
"annoy": false,
"condition": "concerning",
"threshold_reached": true,
"passed": "regular"
},
"output": true
},
{
"name": "{\"annoy\":false,\"condition\":\"concerning\",\"threshold_reached\":true,\"passed\":\"reminding\"}",
"input": {
"annoy": false,
"condition": "concerning",
"threshold_reached": true,
"passed": "reminding"
},
"output": true
},
{
"name": "{\"annoy\":false,\"condition\":\"critical\",\"threshold_reached\":false,\"passed\":\"none\"}",
"input": {
"annoy": false,
"condition": "critical",
"threshold_reached": false,
"passed": "none"
},
"output": true
},
{
"name": "{\"annoy\":false,\"condition\":\"critical\",\"threshold_reached\":false,\"passed\":\"attentive\"}",
"input": {
"annoy": false,
"condition": "critical",
"threshold_reached": false,
"passed": "attentive"
},
"output": true
},
{
"name": "{\"annoy\":false,\"condition\":\"critical\",\"threshold_reached\":false,\"passed\":\"regular\"}",
"input": {
"annoy": false,
"condition": "critical",
"threshold_reached": false,
"passed": "regular"
},
"output": true
},
{
"name": "{\"annoy\":false,\"condition\":\"critical\",\"threshold_reached\":false,\"passed\":\"reminding\"}",
"input": {
"annoy": false,
"condition": "critical",
"threshold_reached": false,
"passed": "reminding"
},
"output": true
},
{
"name": "{\"annoy\":false,\"condition\":\"critical\",\"threshold_reached\":true,\"passed\":\"none\"}",
"input": {
"annoy": false,
"condition": "critical",
"threshold_reached": true,
"passed": "none"
},
"output": true
},
{
"name": "{\"annoy\":false,\"condition\":\"critical\",\"threshold_reached\":true,\"passed\":\"attentive\"}",
"input": {
"annoy": false,
"condition": "critical",
"threshold_reached": true,
"passed": "attentive"
},
"output": true
},
{
"name": "{\"annoy\":false,\"condition\":\"critical\",\"threshold_reached\":true,\"passed\":\"regular\"}",
"input": {
"annoy": false,
"condition": "critical",
"threshold_reached": true,
"passed": "regular"
},
"output": true
},
{
"name": "{\"annoy\":false,\"condition\":\"critical\",\"threshold_reached\":true,\"passed\":\"reminding\"}",
"input": {
"annoy": false,
"condition": "critical",
"threshold_reached": true,
"passed": "reminding"
},
"output": true
},
{
"name": "{\"annoy\":true,\"condition\":\"unknown\",\"threshold_reached\":false,\"passed\":\"none\"}",
"input": {
"annoy": true,
"condition": "unknown",
"threshold_reached": false,
"passed": "none"
},
"output": true
},
{
"name": "{\"annoy\":true,\"condition\":\"unknown\",\"threshold_reached\":false,\"passed\":\"attentive\"}",
"input": {
"annoy": true,
"condition": "unknown",
"threshold_reached": false,
"passed": "attentive"
},
"output": true
},
{
"name": "{\"annoy\":true,\"condition\":\"unknown\",\"threshold_reached\":false,\"passed\":\"regular\"}",
"input": {
"annoy": true,
"condition": "unknown",
"threshold_reached": false,
"passed": "regular"
},
"output": true
},
{
"name": "{\"annoy\":true,\"condition\":\"unknown\",\"threshold_reached\":false,\"passed\":\"reminding\"}",
"input": {
"annoy": true,
"condition": "unknown",
"threshold_reached": false,
"passed": "reminding"
},
"output": true
},
{
"name": "{\"annoy\":true,\"condition\":\"unknown\",\"threshold_reached\":true,\"passed\":\"none\"}",
"input": {
"annoy": true,
"condition": "unknown",
"threshold_reached": true,
"passed": "none"
},
"output": true
},
{
"name": "{\"annoy\":true,\"condition\":\"unknown\",\"threshold_reached\":true,\"passed\":\"attentive\"}",
"input": {
"annoy": true,
"condition": "unknown",
"threshold_reached": true,
"passed": "attentive"
},
"output": true
},
{
"name": "{\"annoy\":true,\"condition\":\"unknown\",\"threshold_reached\":true,\"passed\":\"regular\"}",
"input": {
"annoy": true,
"condition": "unknown",
"threshold_reached": true,
"passed": "regular"
},
"output": true
},
{
"name": "{\"annoy\":true,\"condition\":\"unknown\",\"threshold_reached\":true,\"passed\":\"reminding\"}",
"input": {
"annoy": true,
"condition": "unknown",
"threshold_reached": true,
"passed": "reminding"
},
"output": true
},
{
"name": "{\"annoy\":true,\"condition\":\"ok\",\"threshold_reached\":false,\"passed\":\"none\"}",
"input": {
"annoy": true,
"condition": "ok",
"threshold_reached": false,
"passed": "none"
},
"output": false "output": false
}, },
{ {
"name": "{\"annoy\":true,\"condition\":\"ok\",\"threshold_reached\":false,\"passed\":\"attentive\"}", "name": "{\"condition\":\"concerning\",\"threshold_reached\":false,\"passed\":\"attentive\"}",
"input": { "input": {
"annoy": true, "condition": "concerning",
"condition": "ok",
"threshold_reached": false, "threshold_reached": false,
"passed": "attentive" "passed": "attentive"
}, },
"output": true "output": true
}, },
{ {
"name": "{\"annoy\":true,\"condition\":\"ok\",\"threshold_reached\":false,\"passed\":\"regular\"}", "name": "{\"condition\":\"concerning\",\"threshold_reached\":false,\"passed\":\"regular\"}",
"input": { "input": {
"annoy": true, "condition": "concerning",
"condition": "ok",
"threshold_reached": false, "threshold_reached": false,
"passed": "regular" "passed": "regular"
}, },
"output": true "output": true
}, },
{ {
"name": "{\"annoy\":true,\"condition\":\"ok\",\"threshold_reached\":false,\"passed\":\"reminding\"}", "name": "{\"condition\":\"concerning\",\"threshold_reached\":false,\"passed\":\"reminding\"}",
"input": { "input": {
"annoy": true, "condition": "concerning",
"condition": "ok",
"threshold_reached": false, "threshold_reached": false,
"passed": "reminding" "passed": "reminding"
}, },
"output": true "output": true
}, },
{ {
"name": "{\"annoy\":true,\"condition\":\"ok\",\"threshold_reached\":true,\"passed\":\"none\"}", "name": "{\"condition\":\"concerning\",\"threshold_reached\":true,\"passed\":\"none\"}",
"input": { "input": {
"annoy": true, "condition": "concerning",
"condition": "ok",
"threshold_reached": true, "threshold_reached": true,
"passed": "none" "passed": "none"
}, },
"output": false "output": false
}, },
{ {
"name": "{\"annoy\":true,\"condition\":\"ok\",\"threshold_reached\":true,\"passed\":\"attentive\"}", "name": "{\"condition\":\"concerning\",\"threshold_reached\":true,\"passed\":\"attentive\"}",
"input": { "input": {
"annoy": true, "condition": "concerning",
"condition": "ok",
"threshold_reached": true, "threshold_reached": true,
"passed": "attentive" "passed": "attentive"
}, },
"output": false "output": false
}, },
{ {
"name": "{\"annoy\":true,\"condition\":\"ok\",\"threshold_reached\":true,\"passed\":\"regular\"}", "name": "{\"condition\":\"concerning\",\"threshold_reached\":true,\"passed\":\"regular\"}",
"input": { "input": {
"annoy": true,
"condition": "ok",
"threshold_reached": true,
"passed": "regular"
},
"output": true
},
{
"name": "{\"annoy\":true,\"condition\":\"ok\",\"threshold_reached\":true,\"passed\":\"reminding\"}",
"input": {
"annoy": true,
"condition": "ok",
"threshold_reached": true,
"passed": "reminding"
},
"output": true
},
{
"name": "{\"annoy\":true,\"condition\":\"concerning\",\"threshold_reached\":false,\"passed\":\"none\"}",
"input": {
"annoy": true,
"condition": "concerning",
"threshold_reached": false,
"passed": "none"
},
"output": true
},
{
"name": "{\"annoy\":true,\"condition\":\"concerning\",\"threshold_reached\":false,\"passed\":\"attentive\"}",
"input": {
"annoy": true,
"condition": "concerning",
"threshold_reached": false,
"passed": "attentive"
},
"output": true
},
{
"name": "{\"annoy\":true,\"condition\":\"concerning\",\"threshold_reached\":false,\"passed\":\"regular\"}",
"input": {
"annoy": true,
"condition": "concerning",
"threshold_reached": false,
"passed": "regular"
},
"output": true
},
{
"name": "{\"annoy\":true,\"condition\":\"concerning\",\"threshold_reached\":false,\"passed\":\"reminding\"}",
"input": {
"annoy": true,
"condition": "concerning",
"threshold_reached": false,
"passed": "reminding"
},
"output": true
},
{
"name": "{\"annoy\":true,\"condition\":\"concerning\",\"threshold_reached\":true,\"passed\":\"none\"}",
"input": {
"annoy": true,
"condition": "concerning",
"threshold_reached": true,
"passed": "none"
},
"output": true
},
{
"name": "{\"annoy\":true,\"condition\":\"concerning\",\"threshold_reached\":true,\"passed\":\"attentive\"}",
"input": {
"annoy": true,
"condition": "concerning",
"threshold_reached": true,
"passed": "attentive"
},
"output": true
},
{
"name": "{\"annoy\":true,\"condition\":\"concerning\",\"threshold_reached\":true,\"passed\":\"regular\"}",
"input": {
"annoy": true,
"condition": "concerning", "condition": "concerning",
"threshold_reached": true, "threshold_reached": true,
"passed": "regular" "passed": "regular"
@ -573,9 +230,8 @@
"output": true "output": true
}, },
{ {
"name": "{\"annoy\":true,\"condition\":\"concerning\",\"threshold_reached\":true,\"passed\":\"reminding\"}", "name": "{\"condition\":\"concerning\",\"threshold_reached\":true,\"passed\":\"reminding\"}",
"input": { "input": {
"annoy": true,
"condition": "concerning", "condition": "concerning",
"threshold_reached": true, "threshold_reached": true,
"passed": "reminding" "passed": "reminding"
@ -583,19 +239,17 @@
"output": true "output": true
}, },
{ {
"name": "{\"annoy\":true,\"condition\":\"critical\",\"threshold_reached\":false,\"passed\":\"none\"}", "name": "{\"condition\":\"critical\",\"threshold_reached\":false,\"passed\":\"none\"}",
"input": { "input": {
"annoy": true,
"condition": "critical", "condition": "critical",
"threshold_reached": false, "threshold_reached": false,
"passed": "none" "passed": "none"
}, },
"output": true "output": false
}, },
{ {
"name": "{\"annoy\":true,\"condition\":\"critical\",\"threshold_reached\":false,\"passed\":\"attentive\"}", "name": "{\"condition\":\"critical\",\"threshold_reached\":false,\"passed\":\"attentive\"}",
"input": { "input": {
"annoy": true,
"condition": "critical", "condition": "critical",
"threshold_reached": false, "threshold_reached": false,
"passed": "attentive" "passed": "attentive"
@ -603,9 +257,8 @@
"output": true "output": true
}, },
{ {
"name": "{\"annoy\":true,\"condition\":\"critical\",\"threshold_reached\":false,\"passed\":\"regular\"}", "name": "{\"condition\":\"critical\",\"threshold_reached\":false,\"passed\":\"regular\"}",
"input": { "input": {
"annoy": true,
"condition": "critical", "condition": "critical",
"threshold_reached": false, "threshold_reached": false,
"passed": "regular" "passed": "regular"
@ -613,9 +266,8 @@
"output": true "output": true
}, },
{ {
"name": "{\"annoy\":true,\"condition\":\"critical\",\"threshold_reached\":false,\"passed\":\"reminding\"}", "name": "{\"condition\":\"critical\",\"threshold_reached\":false,\"passed\":\"reminding\"}",
"input": { "input": {
"annoy": true,
"condition": "critical", "condition": "critical",
"threshold_reached": false, "threshold_reached": false,
"passed": "reminding" "passed": "reminding"
@ -623,29 +275,26 @@
"output": true "output": true
}, },
{ {
"name": "{\"annoy\":true,\"condition\":\"critical\",\"threshold_reached\":true,\"passed\":\"none\"}", "name": "{\"condition\":\"critical\",\"threshold_reached\":true,\"passed\":\"none\"}",
"input": { "input": {
"annoy": true,
"condition": "critical", "condition": "critical",
"threshold_reached": true, "threshold_reached": true,
"passed": "none" "passed": "none"
}, },
"output": true "output": false
}, },
{ {
"name": "{\"annoy\":true,\"condition\":\"critical\",\"threshold_reached\":true,\"passed\":\"attentive\"}", "name": "{\"condition\":\"critical\",\"threshold_reached\":true,\"passed\":\"attentive\"}",
"input": { "input": {
"annoy": true,
"condition": "critical", "condition": "critical",
"threshold_reached": true, "threshold_reached": true,
"passed": "attentive" "passed": "attentive"
}, },
"output": true "output": false
}, },
{ {
"name": "{\"annoy\":true,\"condition\":\"critical\",\"threshold_reached\":true,\"passed\":\"regular\"}", "name": "{\"condition\":\"critical\",\"threshold_reached\":true,\"passed\":\"regular\"}",
"input": { "input": {
"annoy": true,
"condition": "critical", "condition": "critical",
"threshold_reached": true, "threshold_reached": true,
"passed": "regular" "passed": "regular"
@ -653,9 +302,8 @@
"output": true "output": true
}, },
{ {
"name": "{\"annoy\":true,\"condition\":\"critical\",\"threshold_reached\":true,\"passed\":\"reminding\"}", "name": "{\"condition\":\"critical\",\"threshold_reached\":true,\"passed\":\"reminding\"}",
"input": { "input": {
"annoy": true,
"condition": "critical", "condition": "critical",
"threshold_reached": true, "threshold_reached": true,
"passed": "reminding" "passed": "reminding"

View file

@ -32,7 +32,7 @@ describe(
const check : _heimdall.type_check = Object.assign( const check : _heimdall.type_check = Object.assign(
data.parameters["check"], data.parameters["check"],
{ {
"annoy": case_.input["annoy"], "annoy": false,
} }
); );
const old_item_state : _heimdall.type_item_state = { const old_item_state : _heimdall.type_item_state = {
@ -75,5 +75,74 @@ describe(
); );
} }
); );
/*
describe(
"master.determine_shall_send_notification",
() => {
it(
"test",
() => {
// setup
const check : _heimdall.type_check = {
"name": "iks.web.2",
"title": "web.2",
"kind": "http_request",
"parameters": {
"request": {
"method": "GET",
"target": "https://iks-sachsen.de"
},
"timeout": 5,
"follow_redirects": true,
"response": {
"status_code": 200
},
"critical": true
},
"custom": null,
"active": false,
"threshold": 3,
"annoy": false,
"schedule": {
"regular_interval": 60,
"attentive_interval": 10,
"reminding_interval": 86400
},
"notifications": [
{
"kind": "console",
"parameters": {
}
}
]
};
const old_item_state : _heimdall.type_item_state = {
"timestamp": 1693493942,
"condition": _heimdall.enum_condition.critical,
"count": 2,
"last_notification_timestamp": 1693493942,
};
const timestamp : int = 1693495622;
// execution
const result : boolean = _heimdall.master.determine_shall_send_notification(
check,
false,
3,
timestamp,
old_item_state,
{
"condition": _heimdall.enum_condition.critical,
"info": {},
}
);
// assertions
nm_assert.equal(result, false);
}
);
}
);
*/
} }
); );

View file

@ -11,7 +11,7 @@ mkdir --parents ${directory}
cp --recursive --update --verbose build/* ${directory}/ cp --recursive --update --verbose build/* ${directory}/
mkdir --parents /usr/local/bin/ mkdir --parents /usr/local/bin/
echo "dir=\$(pwd) && cd ${directory} && ./heimdall --working-directory=\${dir} \$@" > /usr/local/bin/heimdall echo "NODE_PATH=\${NODE_PATH}:${directory} ${directory}/heimdall \$@" > /usr/local/bin/heimdall
mkdir --parents /usr/local/share/icons/ mkdir --parents /usr/local/share/icons/
cp media/icon.png /usr/local/share/icons/heimdall.png cp media/icon.png /usr/local/share/icons/heimdall.png