[mod] target.interval -> target.reminders [mod] settings.poll_delay -> settings.interval [mod] ical_feed:timezone

This commit is contained in:
Christian Fraß 2025-04-28 19:51:03 +00:00
parent ac1daf8a68
commit 7f6f080bea
5 changed files with 62 additions and 21 deletions

View file

@ -93,13 +93,13 @@ namespace _munin.conf
/**
* in hours
*/
interval : Array<int>;
reminders : Array<int>;
}
}
)
>;
settings : {
poll_delay : float;
interval : float;
};
labels : {
head : string;
@ -154,9 +154,30 @@ namespace _munin.conf
}
}
),
"targets": conf_v1.targets,
"targets": conf_v1.targets.map(
target => {
switch (target.kind) {
case "telegram_bot": {
return {
"kind": "telegram_bot",
"data": {
"bot_token": target.data.bot_token,
"chat_id": target.data.chat_id,
"reminders": target.data.interval,
},
};
break;
}
default: {
// return target;
throw (new Error("unhandled target kind: " + target.kind));
break;
}
}
}
),
"settings": {
"poll_delay": conf_v1.frequency,
"interval": conf_v1.frequency,
},
"labels": conf_v1.labels,
};
@ -360,7 +381,7 @@ namespace _munin.conf
"nullable": false,
"type": "integer",
},
"interval": {
"reminders": {
"nullable": false,
"type": "array",
"items": {
@ -415,7 +436,7 @@ namespace _munin.conf
"nullable": false,
"type": "object",
"properties": {
"poll_delay": {
"interval": {
"nullable": false,
"type": "number",
"default": 1.0

View file

@ -49,14 +49,14 @@ namespace _munin
}
}
);
for (const hours of target.interval) {
for (const hours of target.reminders) {
const window_from : lib_plankton.pit.type_pit = lib_plankton.pit.shift_hour(
now,
hours + 0
);
const window_to : lib_plankton.pit.type_pit = lib_plankton.pit.shift_hour(
now,
hours + (conf.settings.poll_delay / 2)
hours + conf.settings.interval
);
for (const event of events) {
const event_begin : lib_plankton.pit.type_pit = lib_plankton.pit.from_datetime(event.begin);
@ -64,9 +64,10 @@ namespace _munin
"munin.run.check_dueness",
{
"details": {
"event_begin": lib_plankton.pit.datetime_format(lib_plankton.pit.to_datetime(event_begin)),
"window_from": lib_plankton.pit.datetime_format(lib_plankton.pit.to_datetime(window_from)),
"window_to": lib_plankton.pit.datetime_format(lib_plankton.pit.to_datetime(window_to)),
// "now": lib_plankton.pit.to_date_object(now).toISOString(),
"event_begin": lib_plankton.pit.to_date_object(event_begin).toISOString(),
"window_from": lib_plankton.pit.to_date_object(window_from).toISOString(),
"window_to": lib_plankton.pit.to_date_object(window_to).toISOString(),
}
}
);
@ -84,7 +85,7 @@ namespace _munin
{
"details": {
"event": event,
"target": target,
"target": target.show(),
}
}
);
@ -128,7 +129,7 @@ namespace _munin
);
while (true) {
await run_iteration(conf, sources, targets, {"dry_run": dry_run});
await lib_plankton.call.sleep(conf.settings.poll_delay * 60 * 60);
await lib_plankton.call.sleep(conf.settings.interval * 60 * 60);
}
}
@ -157,7 +158,7 @@ namespace _munin
"indicators_short": ["c"],
"type": lib_plankton.args.enum_type.string,
"mode": lib_plankton.args.enum_mode.replace,
"default": "conf.json",
"default": "munin.json",
"info": "path to configuration file",
"name": "conf-path",
}),
@ -243,7 +244,7 @@ namespace _munin
"threshold": args.verbosity,
}
},
}
},
]
],
}

View file

@ -25,7 +25,7 @@ namespace _munin.sources.ical_feed
"path": url.path,
"version": "HTTP/2",
"method": lib_plankton.http.enum_method.get,
"query": url.query,
"query": ("?" + url.query),
"headers": {},
"body": null,
};
@ -64,13 +64,25 @@ namespace _munin.sources.ical_feed
)
.map(
vevent => {
const begin : lib_plankton.pit.type_datetime = {
/**
* @todo würg!
*/
const timezone_shift : int = lib_plankton.pit.timezone_shift_ce(
lib_plankton.pit.from_datetime(
{
"timezone_shift": 0,
"date": vevent.dtstart.value.date,
"time": vevent.dtstart.value.time,
}
)
);
const begin : lib_plankton.pit.type_datetime = {
"timezone_shift": timezone_shift,
"date": vevent.dtstart.value.date,
"time": vevent.dtstart.value.time,
};
const end : lib_plankton.pit.type_datetime = {
"timezone_shift": 0,
"timezone_shift": timezone_shift,
"date": vevent.dtend.value.date,
"time": vevent.dtend.value.time,
};

View file

@ -26,7 +26,7 @@ namespace _munin.targets.telegram_bot
export type type_parameters = {
bot_token : string;
chat_id : int;
interval : Array<int>;
reminders : Array<int>;
};
@ -78,7 +78,13 @@ namespace _munin.targets.telegram_bot
) : _munin.type_target
{
return {
"interval": parameters.interval,
"reminders": parameters.reminders,
"show": () => lib_plankton.string.coin(
"telegram:{{chat_id}}",
{
"chat_id": parameters.chat_id.toFixed(0),
}
),
"send": (labels, event) => send(parameters, labels, event),
};
}

View file

@ -36,7 +36,8 @@ namespace _munin
/**
*/
export type type_target = {
interval : Array<int>;
reminders : Array<int>;
show : (() => string);
send : (
(
labels : type_labels,