aboutsummaryrefslogtreecommitdiff
path: root/eperd/eooqd.c
diff options
context:
space:
mode:
authorBjørn Mork <bjorn@mork.no>2015-05-15 10:25:14 +0200
committerBjørn Mork <bjorn@mork.no>2015-05-15 10:25:14 +0200
commitc9c35747c0d20cff54561c0b8fe15813c7a8e0ff (patch)
tree206501a10c9f394cce59ce2eec9c25f5a911a783 /eperd/eooqd.c
parentbb2d4d31e2dab11025ae93ebcebc818c36a9747f (diff)
ripe-atlas-fw: imported version 45704570
Signed-off-by: Bjørn Mork <bjorn@mork.no>
Diffstat (limited to 'eperd/eooqd.c')
-rw-r--r--eperd/eooqd.c52
1 files changed, 51 insertions, 1 deletions
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)
{