diff options
| author | arf20 <aruizfernandez05@gmail.com> | 2025-11-10 13:48:37 +0100 |
|---|---|---|
| committer | arf20 <aruizfernandez05@gmail.com> | 2025-11-10 13:48:37 +0100 |
| commit | 47992fa660c9c82858120c4d16fba0501903ceb9 (patch) | |
| tree | cf1564b51cfcd54ac5ed17e26bf98ce2e85a3c39 | |
| parent | 2ad586295dcd5dcef3d29af32998d55bb5c09843 (diff) | |
| download | arfnet2-status-47992fa660c9c82858120c4d16fba0501903ceb9.tar.gz arfnet2-status-47992fa660c9c82858120c4d16fba0501903ceb9.zip | |
REST POST API alert working
| -rw-r--r-- | alert.c | 8 | ||||
| -rw-r--r-- | events.log | 5 | ||||
| -rw-r--r-- | monitor.c | 3 | ||||
| -rw-r--r-- | monitor.cfg | 27 |
4 files changed, 12 insertions, 31 deletions
@@ -130,8 +130,8 @@ alert_init() alerts[alerts_size].body_tmpl = strdup(body_tmpl); printf("\t%s: %s\n", - alerts[alerts_size].target, - type_str[alerts[alerts_size].type] + type_str[alerts[alerts_size].type], + alerts[alerts_size].target ); alerts_size++; @@ -157,9 +157,9 @@ alert_trigger(const target_t *target) strftime(timestr, 256, "%F %T", tm_now); for (int i = 0; i < alerts_size; i++) { - printf("[%s] [monitor] alerted %s about %s\n", + printf("[%s] [monitor] alerted %.16s about %s\n", timestr, alerts[i].target, target->name); - send_funcs[target->type](target, alerts[i].target, alerts[i].extra, + send_funcs[alerts[i].type](target, alerts[i].target, alerts[i].extra, alerts[i].body_tmpl); } } @@ -78,3 +78,8 @@ dns,2025-10-27T15:43:17+0000,up https,2025-10-27T15:43:17+0000,up http,2025-11-04T18:39:12Z,down http,2025-11-04T18:40:12Z,up +test,2025-11-10T12:34:07+0000,down +test,2025-11-10T12:42:29+0000,up +test,2025-11-10T12:42:54+0000,down +test,2025-11-10T12:45:09+0000,up +test,2025-11-10T12:46:50+0000,down @@ -10,6 +10,7 @@ #include "monitor.h" +#include "alert.h" #include "config.h" @@ -499,6 +500,8 @@ monitor_update_events(const char *log_path) printf("[%s] [monitor] %s is now %s\n", timestr, targets[i].name, status_str[targets[i].status]); + alert_trigger(&targets[i]); + targets[i].status_1 = targets[i].status; } } diff --git a/monitor.cfg b/monitor.cfg deleted file mode 100644 index 226a88e..0000000 --- a/monitor.cfg +++ /dev/null @@ -1,27 +0,0 @@ -# Monitor config -# target=type,name,target - -# listen port -port=8888 - -# monitor interval in seconds (sleep) -interval=5 - -# monitor events log path -log=events.log - -# targets to monitor -target=reach,ipv4,2.59.235.35 -target=dns,dns,arf20.com -target=web,http,http://arf20.com -target=web,https,https://arf20.com - -# email From -from=status@arf20.com - -# what to alert -# alert=api,<url>,<content-type>,<body template> -alert=api,https://arf20.com/%s,application/json,{"content":"%s is %s"} -# alert=email,<address>,<subject template>,<body template> -alert=email,arf20@arf20.com,%s is %s,%s is %s - |
