aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--events.log148
-rw-r--r--monitor.c19
2 files changed, 88 insertions, 79 deletions
diff --git a/events.log b/events.log
index 1affe2b..85c4116 100644
--- a/events.log
+++ b/events.log
@@ -1,76 +1,76 @@
# ARFNET status monitor incident log
-http,2024-11-30 22:23:07,down
-http,2024-11-30 23:56:19,up
-http,2024-12-05 06:51:49,down
-http,2024-12-05 10:45:01,up
-http,2024-12-10 23:26:30,down
-http,2024-12-11 04:09:34,up
-http,2024-12-11 15:28:06,down
-http,2024-12-11 15:31:15,up
-http,2024-12-16 09:19:30,down
-http,2024-12-16 09:27:39,up
-http,2025-01-10 01:30:00,down
-http,2025-01-10 01:43:09,up
-http,2025-01-11 16:13:35,down
-http,2025-01-11 16:16:45,up
-http,2025-01-11 16:24:26,down
-http,2025-01-11 17:12:36,up
-http,2025-01-31 19:17:38,down
-http,2025-01-31 19:50:48,up
-http,2025-02-04 07:10:33,down
-http,2025-02-04 08:23:39,up
-http,2025-02-05 07:18:57,down
-http,2025-02-05 08:27:06,up
-http,2025-02-07 02:29:16,down
-http,2025-02-07 02:36:55,up
-http,2025-02-18 01:11:37,down
-http,2025-02-18 01:24:45,up
-http,2025-02-18 01:32:24,down
-http,2025-02-18 01:40:35,up
-http,2025-02-28 19:11:04,down
-http,2025-02-28 20:04:13,up
-http,2025-03-06 19:10:07,down
-http,2025-03-06 19:15:09,up
-http,2025-03-12 01:09:30,down
-http,2025-03-12 01:14:33,up
-http,2025-03-12 01:20:15,down
-http,2025-03-12 01:25:19,up
-http,2025-04-08 23:15:32,down
-http,2025-04-08 23:20:37,up
-http,2025-04-28 10:44:56,down
-http,2025-04-28 21:41:33,up
-http,2025-06-25 08:07:38,down
-http,2025-06-25 08:12:40,up
-http,2025-06-25 08:23:39,down
-http,2025-06-25 08:33:51,up
-http,2025-06-25 12:37:58,down
-http,2025-06-25 12:43:03,up
-http,2025-06-26 20:36:44,down
-http,2025-06-26 21:54:25,up
-http,2025-06-27 13:02:01,down
-http,2025-06-27 13:12:16,up
-http,2025-06-27 14:14:15,down
-http,2025-06-27 14:19:19,up
-http,2025-06-29 15:58:44,down
-http,2025-06-29 17:47:37,up
-http,2025-06-29 18:59:38,down
-http,2025-06-29 19:09:53,up
-http,2025-07-02 09:33:20,down
-http,2025-07-02 09:43:34,up
-http,2025-07-20 23:48:33,down
-http,2025-07-20 23:53:35,up
-http,2025-08-10 08:06:27,down
-http,2025-08-10 17:42:24,up
-http,2025-08-20 13:40:45,down
-http,2025-08-20 15:39:56,up
-http,2025-08-21 11:47:02,down
-http,2025-08-21 16:11:47,up
-http,2025-08-26 11:04:32,down
-http,2025-08-26 11:14:47,up
-http,2025-08-26 11:46:20,down
-http,2025-08-26 11:51:24,up
-http,2025-08-26 14:39:43,down
-http,2025-08-26 14:44:45,up
-http,2025-10-24 10:49:20,down
-http,2025-10-24 12:38:19,up
+http,2024-11-30T22:23:07Z,down
+http,2024-11-30T23:56:19Z,up
+http,2024-12-05T06:51:49Z,down
+http,2024-12-05T10:45:01Z,up
+http,2024-12-10T23:26:30Z,down
+http,2024-12-11T04:09:34Z,up
+http,2024-12-11T15:28:06Z,down
+http,2024-12-11T15:31:15Z,up
+http,2024-12-16T09:19:30Z,down
+http,2024-12-16T09:27:39Z,up
+http,2025-01-10T01:30:00Z,down
+http,2025-01-10T01:43:09Z,up
+http,2025-01-11T16:13:35Z,down
+http,2025-01-11T16:16:45Z,up
+http,2025-01-11T16:24:26Z,down
+http,2025-01-11T17:12:36Z,up
+http,2025-01-31T19:17:38Z,down
+http,2025-01-31T19:50:48Z,up
+http,2025-02-04T07:10:33Z,down
+http,2025-02-04T08:23:39Z,up
+http,2025-02-05T07:18:57Z,down
+http,2025-02-05T08:27:06Z,up
+http,2025-02-07T02:29:16Z,down
+http,2025-02-07T02:36:55Z,up
+http,2025-02-18T01:11:37Z,down
+http,2025-02-18T01:24:45Z,up
+http,2025-02-18T01:32:24Z,down
+http,2025-02-18T01:40:35Z,up
+http,2025-02-28T19:11:04Z,down
+http,2025-02-28T20:04:13Z,up
+http,2025-03-06T19:10:07Z,down
+http,2025-03-06T19:15:09Z,up
+http,2025-03-12T01:09:30Z,down
+http,2025-03-12T01:14:33Z,up
+http,2025-03-12T01:20:15Z,down
+http,2025-03-12T01:25:19Z,up
+http,2025-04-08T23:15:32Z,down
+http,2025-04-08T23:20:37Z,up
+http,2025-04-28T10:44:56Z,down
+http,2025-04-28T21:41:33Z,up
+http,2025-06-25T08:07:38Z,down
+http,2025-06-25T08:12:40Z,up
+http,2025-06-25T08:23:39Z,down
+http,2025-06-25T08:33:51Z,up
+http,2025-06-25T12:37:58Z,down
+http,2025-06-25T12:43:03Z,up
+http,2025-06-26T20:36:44Z,down
+http,2025-06-26T21:54:25Z,up
+http,2025-06-27T13:02:01Z,down
+http,2025-06-27T13:12:16Z,up
+http,2025-06-27T14:14:15Z,down
+http,2025-06-27T14:19:19Z,up
+http,2025-06-29T15:58:44Z,down
+http,2025-06-29T17:47:37Z,up
+http,2025-06-29T18:59:38Z,down
+http,2025-06-29T19:09:53Z,up
+http,2025-07-02T09:33:20Z,down
+http,2025-07-02T09:43:34Z,up
+http,2025-07-20T23:48:33Z,down
+http,2025-07-20T23:53:35Z,up
+http,2025-08-10T08:06:27Z,down
+http,2025-08-10T17:42:24Z,up
+http,2025-08-20T13:40:45Z,down
+http,2025-08-20T15:39:56Z,up
+http,2025-08-21T11:47:02Z,down
+http,2025-08-21T16:11:47Z,up
+http,2025-08-26T11:04:32Z,down
+http,2025-08-26T11:14:47Z,up
+http,2025-08-26T11:46:20Z,down
+http,2025-08-26T11:51:24Z,up
+http,2025-08-26T14:39:43Z,down
+http,2025-08-26T14:44:45Z,up
+http,2025-10-24T10:49:20Z,down
+http,2025-10-24T12:38:19Z,up
diff --git a/monitor.c b/monitor.c
index e6165a3..2c81be5 100644
--- a/monitor.c
+++ b/monitor.c
@@ -93,7 +93,8 @@ incidents_push_ordered(const incident_t *incident)
}
static size_t
-target_events_load(target_t *target, const char *logbuff) {
+target_events_load(target_t *target, const char *logbuff)
+{
char line[256];
size_t n = 0;
@@ -123,11 +124,11 @@ target_events_load(target_t *target, const char *logbuff) {
if (strcmp(name, target->name) != 0)
continue;
- struct tm event_time;
- strptime(time, "%Y-%m-%d %H:%M:%S", &event_time);
+ struct tm event_time = { 0 };
+ strptime(time, "%FT%T%z", &event_time);
event_t event = {
- mktime(&event_time),
+ mktime(&event_time) - timezone,
strcmp(status, "up") == 0 ? STATUS_UP : STATUS_DOWN
};
@@ -182,7 +183,8 @@ incidents_render()
}
int
-monitor_init(const char *cfg_path, const char *log_path) {
+monitor_init(const char *cfg_path, const char *log_path)
+{
/* read monitor log */
FILE *logf = fopen(log_path, "r");
if (!logf) {
@@ -209,6 +211,8 @@ monitor_init(const char *cfg_path, const char *log_path) {
}
printf("monitor targets:\n");
+
+ tzset(); /* initialize tz conversion */
char line[256];
while (fgets(line, sizeof(line), cfgf)) {
@@ -277,6 +281,11 @@ target_uptime(const target_t *target)
{
static char buff[256];
+ if (target->events_size == 0) {
+ snprintf(buff, 256, "-");
+ return buff;
+ }
+
event_t last_event = target->events[target->events_size - 1];
if (last_event.status == STATUS_DOWN) {