diff options
author | Eric Faurot <eric@cvs.openbsd.org> | 2011-04-02 16:40:20 +0000 |
---|---|---|
committer | Eric Faurot <eric@cvs.openbsd.org> | 2011-04-02 16:40:20 +0000 |
commit | f3acb273af8efc67104501a764c2ac28a24d7ec3 (patch) | |
tree | 06c2f466949361811be05149cf481f689ba7872c /usr.sbin | |
parent | d46862a1ed811ea75ce64b949869ab12f998ef8a (diff) |
add stat counters for the lookup agent
ok gilles@
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/smtpd/dns.c | 16 | ||||
-rw-r--r-- | usr.sbin/smtpd/smtpctl.c | 10 | ||||
-rw-r--r-- | usr.sbin/smtpd/smtpd.h | 13 |
3 files changed, 36 insertions, 3 deletions
diff --git a/usr.sbin/smtpd/dns.c b/usr.sbin/smtpd/dns.c index ed244452099..dd06fb3bcd5 100644 --- a/usr.sbin/smtpd/dns.c +++ b/usr.sbin/smtpd/dns.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dns.c,v 1.38 2011/03/31 10:40:59 eric Exp $ */ +/* $OpenBSD: dns.c,v 1.39 2011/04/02 16:40:19 eric Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -112,11 +112,13 @@ dns_async(struct smtpd *env, struct imsgev *asker, int type, struct dns *query) switch (type) { case IMSG_DNS_HOST: dnssession_mx_insert(dnssession, query->host, 0); + env->stats->lka.queries_host++; dns_asr_dispatch_host(dnssession); return; case IMSG_DNS_PTR: dnssession->aq = asr_query_cname(asr, (struct sockaddr*)&query->ss, query->ss.ss_len); + env->stats->lka.queries_cname++; if (dnssession->aq == NULL) { log_debug("dns_async: asr_query_cname error"); break; @@ -125,6 +127,7 @@ dns_async(struct smtpd *env, struct imsgev *asker, int type, struct dns *query) return; case IMSG_DNS_MX: dnssession->aq = asr_query_dns(asr, T_MX, C_IN, query->host, 0); + env->stats->lka.queries_mx++; if (dnssession->aq == NULL) { log_debug("dns_async: asr_query_dns error"); break; @@ -136,6 +139,7 @@ dns_async(struct smtpd *env, struct imsgev *asker, int type, struct dns *query) break; } + env->stats->lka.queries_failure++; dnssession_destroy(env, dnssession); noasr: query->error = EAI_AGAIN; @@ -235,6 +239,8 @@ next: while (dnssession->aq == NULL) { if (dnssession->mxcurrent == dnssession->mxarraysz) { query->error = (dnssession->mxfound) ? 0 : EAI_NONAME; + if (query->error) + query->env->stats->lka.queries_failure++; imsg_compose_event(query->asker, IMSG_DNS_HOST_END, 0, 0, -1, query, sizeof(*query)); dnssession_destroy(query->env, dnssession); @@ -281,6 +287,7 @@ dns_asr_dispatch_cname(struct dnssession *dnssession) break; case ASR_DONE: /* This is necessarily an error */ + query->env->stats->lka.queries_failure++; query->error = ar.ar_err; break; } @@ -298,6 +305,12 @@ dnssession_init(struct smtpd *env, struct dns *query) if (dnssession == NULL) fatal("dnssession_init: calloc"); + env->stats->lka.queries++; + env->stats->lka.queries_active++; + if (env->stats->lka.queries_active > env->stats->lka.queries_maxactive) + env->stats->lka.queries_maxactive = \ + env->stats->lka.queries_active; + dnssession->id = query->id; dnssession->query = *query; SPLAY_INSERT(dnstree, &env->dns_sessions, dnssession); @@ -307,6 +320,7 @@ dnssession_init(struct smtpd *env, struct dns *query) void dnssession_destroy(struct smtpd *env, struct dnssession *dnssession) { + env->stats->lka.queries_active--; SPLAY_REMOVE(dnstree, &env->dns_sessions, dnssession); event_del(&dnssession->ev); free(dnssession); diff --git a/usr.sbin/smtpd/smtpctl.c b/usr.sbin/smtpd/smtpctl.c index 8431c8de574..cfe4ff83519 100644 --- a/usr.sbin/smtpd/smtpctl.c +++ b/usr.sbin/smtpd/smtpctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpctl.c,v 1.56 2011/03/09 20:59:22 gilles Exp $ */ +/* $OpenBSD: smtpctl.c,v 1.57 2011/04/02 16:40:19 eric Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -284,6 +284,14 @@ show_stats_output(struct imsg *imsg) printf("mta.sessions.active=%zd\n", stats->mta.sessions_active); printf("mta.sessions.maxactive=%zd\n", stats->mta.sessions_maxactive); + printf("lka.queries=%zd\n", stats->lka.queries); + printf("lka.queries.active=%zd\n", stats->lka.queries_active); + printf("lka.queries.maxactive=%zd\n", stats->lka.queries_maxactive); + printf("lka.queries.mx=%zd\n", stats->lka.queries_mx); + printf("lka.queries.host=%zd\n", stats->lka.queries_host); + printf("lka.queries.cname=%zd\n", stats->lka.queries_cname); + printf("lka.queries.failure=%zd\n", stats->lka.queries_failure); + printf("parent.uptime=%d\n", time(NULL) - stats->parent.start); printf("queue.inserts.local=%zd\n", stats->queue.inserts_local); diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h index f2c037dda77..4b6b25448d0 100644 --- a/usr.sbin/smtpd/smtpd.h +++ b/usr.sbin/smtpd/smtpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpd.h,v 1.206 2011/03/29 20:43:51 eric Exp $ */ +/* $OpenBSD: smtpd.h,v 1.207 2011/04/02 16:40:19 eric Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -692,6 +692,16 @@ struct s_control { size_t sessions_maxactive; }; +struct s_lka { + size_t queries; + size_t queries_active; + size_t queries_maxactive; + size_t queries_mx; + size_t queries_host; + size_t queries_cname; + size_t queries_failure; +}; + struct stats { struct s_parent parent; struct s_queue queue; @@ -700,6 +710,7 @@ struct stats { struct s_mda mda; struct s_session smtp; struct s_control control; + struct s_lka lka; }; struct sched { |