From c9c35747c0d20cff54561c0b8fe15813c7a8e0ff Mon Sep 17 00:00:00 2001 From: Bjørn Mork Date: Fri, 15 May 2015 10:25:14 +0200 Subject: ripe-atlas-fw: imported version 4570 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Bjørn Mork --- eperd/eooqd.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) (limited to 'eperd/eooqd.c') diff --git a/eperd/eooqd.c b/eperd/eooqd.c index 49371ad..ea7162f 100644 --- a/eperd/eooqd.c +++ b/eperd/eooqd.c @@ -57,6 +57,7 @@ static struct builtin { NULL, NULL } }; +static const char *atlas_id; static void process(FILE *file); static void report(const char *fmt, ...); @@ -76,7 +77,7 @@ int eooqd_main(int argc, char *argv[]) { int r; uint32_t opt; - char *atlas_id, *pid_file_name; + char *pid_file_name; struct event *checkQueueEvent, *rePostEvent; struct timeval tv; @@ -468,6 +469,55 @@ static void cmddone(void *cmdstate) } } +#define RESOLV_CONF "/etc/resolv.conf" +static void check_resolv_conf2(const char *out_file, const char *atlasid) +{ + static time_t last_time= -1; + + int r; + FILE *fn; + struct stat sb; + + r= stat(RESOLV_CONF, &sb); + if (r == -1) + { + crondlog(LVL8 "error accessing resolv.conf: %s", + strerror(errno)); + return; + } + + if (sb.st_mtime == last_time) + return; /* resolv.conf did not change */ + evdns_base_clear_nameservers_and_suspend(DnsBase); + r= evdns_base_resolv_conf_parse(DnsBase, DNS_OPTIONS_ALL, + RESOLV_CONF); + evdns_base_resume(DnsBase); + + if (r != 0 || last_time != -1) + { + fn= fopen(out_file, "a"); + if (!fn) + crondlog(DIE9 "unable to append to '%s'", out_file); + fprintf(fn, "RESULT { "); + if (atlasid) + fprintf(fn, DBQ(id) ":" DBQ(%s) ", ", atlasid); + fprintf(fn, DBQ(fw) ":" DBQ(%d) ", " DBQ(time) ":%ld, ", + get_atlas_fw_version(), (long)time(NULL)); + fprintf(fn, DBQ(event) ": " DBQ(load resolv.conf) + ", " DBQ(result) ": %d", r); + + fprintf(fn, " }\n"); + fclose(fn); + } + + last_time= sb.st_mtime; +} + +static void check_resolv_conf(void) +{ + check_resolv_conf1(); +} + static void re_post(evutil_socket_t fd UNUSED_PARAM, short what UNUSED_PARAM, void *arg UNUSED_PARAM) { -- cgit v1.2.3