2024-05-31 03:28:28 +02:00
|
|
|
/*
|
|
|
|
* Alertik: a tiny 'syslog' server & notification tool for Mikrotik routers.
|
|
|
|
* This is free and unencumbered software released into the public domain.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef EVENTS_H
|
|
|
|
#define EVENTS_H
|
|
|
|
|
2024-07-25 02:15:38 +02:00
|
|
|
#include <regex.h>
|
2024-05-31 03:28:28 +02:00
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
#define MSG_MAX 2048
|
|
|
|
#define NUM_EVENTS 1
|
|
|
|
|
2024-07-18 03:41:58 +02:00
|
|
|
#define EVNT_SUBSTR 0
|
|
|
|
#define EVNT_REGEX 1
|
2024-05-31 03:28:28 +02:00
|
|
|
|
|
|
|
/* Log event. */
|
|
|
|
struct log_event {
|
|
|
|
char msg[MSG_MAX];
|
|
|
|
time_t timestamp;
|
|
|
|
};
|
|
|
|
|
2024-07-25 02:15:38 +02:00
|
|
|
struct static_event {
|
2024-07-19 03:41:19 +02:00
|
|
|
void(*hnd)(struct log_event *, int); /* Event handler. */
|
2024-07-25 02:15:38 +02:00
|
|
|
const char *ev_match_str; /* Substr or regex to match. */
|
|
|
|
int ev_match_type; /* Whether substr or regex. */
|
|
|
|
int ev_notifier_idx; /* Telegram, Discord... */
|
|
|
|
int enabled; /* Whether if handler enabled or not. */
|
|
|
|
regex_t regex; /* Compiled regex. */
|
2024-05-31 03:28:28 +02:00
|
|
|
};
|
|
|
|
|
2024-07-18 03:41:58 +02:00
|
|
|
extern int process_static_event(struct log_event *ev);
|
2024-07-19 03:41:19 +02:00
|
|
|
extern int init_static_events(void);
|
2024-05-31 03:28:28 +02:00
|
|
|
|
|
|
|
#endif /* EVENTS_H */
|