summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorGilles Chehade <gilles@cvs.openbsd.org>2009-01-30 21:40:22 +0000
committerGilles Chehade <gilles@cvs.openbsd.org>2009-01-30 21:40:22 +0000
commit8452589c8ddef50efc571850d1c840f2f09e4ed9 (patch)
tree7dbe30b9aa8baa51284a951ed50b53d864ae0e2e /usr.sbin
parent5328220112c6a2ede4995eb893b771f763c4dc4f (diff)
improve statistics for smtp process. not only collect the current sessions
count, but also the total sessions count, ssmtp sessions (both current and total) and starttls sessions (both current and total) # ./smtpctl/smtpctl show stats|grep smtp.sessions smtp.sessions = 0 smtp.sessions.active = 0 smtp.sessions.ssmtp = 0 smtp.sessions.ssmtp.active = 0 smtp.sessions.starttls = 0 smtp.sessions.starttls.active = 0 #
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/smtpd/smtp.c5
-rw-r--r--usr.sbin/smtpd/smtp_session.c6
-rw-r--r--usr.sbin/smtpd/smtpctl.c10
-rw-r--r--usr.sbin/smtpd/smtpd.h7
-rw-r--r--usr.sbin/smtpd/ssl.c20
5 files changed, 40 insertions, 8 deletions
diff --git a/usr.sbin/smtpd/smtp.c b/usr.sbin/smtpd/smtp.c
index 6693aee04ef..ba45283d835 100644
--- a/usr.sbin/smtpd/smtp.c
+++ b/usr.sbin/smtpd/smtp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtp.c,v 1.21 2009/01/30 21:22:33 gilles Exp $ */
+/* $OpenBSD: smtp.c,v 1.22 2009/01/30 21:40:21 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -724,8 +724,9 @@ smtp_accept(int fd, short event, void *p)
event_add(&l->ev, NULL);
s_smtp.sessions++;
+ s_smtp.sessions_active++;
- if (s_smtp.sessions == s->s_env->sc_maxconn)
+ if (s_smtp.sessions_active == s->s_env->sc_maxconn)
event_del(&l->ev);
}
diff --git a/usr.sbin/smtpd/smtp_session.c b/usr.sbin/smtpd/smtp_session.c
index ee9df424fcf..7d890bf93ab 100644
--- a/usr.sbin/smtpd/smtp_session.c
+++ b/usr.sbin/smtpd/smtp_session.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtp_session.c,v 1.50 2009/01/30 21:22:33 gilles Exp $ */
+/* $OpenBSD: smtp_session.c,v 1.51 2009/01/30 21:40:21 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -905,8 +905,8 @@ session_destroy(struct session *s)
log_debug("session_destroy: killing client: %p", s);
close(s->s_fd);
- s_smtp.sessions--;
- if (s_smtp.sessions < s->s_env->sc_maxconn)
+ s_smtp.sessions_active--;
+ if (s_smtp.sessions_active < s->s_env->sc_maxconn)
event_add(&s->s_l->ev, NULL);
if (s->s_bev != NULL) {
diff --git a/usr.sbin/smtpd/smtpctl.c b/usr.sbin/smtpd/smtpctl.c
index c165c22590c..34d49d3a9ef 100644
--- a/usr.sbin/smtpd/smtpctl.c
+++ b/usr.sbin/smtpd/smtpctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtpctl.c,v 1.10 2009/01/30 21:22:33 gilles Exp $ */
+/* $OpenBSD: smtpctl.c,v 1.11 2009/01/30 21:40:21 gilles Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -273,9 +273,17 @@ show_stats_output(struct imsg *imsg)
return (0);
printf("parent.uptime = %d\n", time(NULL) - s_parent.start);
+
printf("queue.inserts = %zd\n", s_queue.inserts);
+
printf("runner.active = %zd\n", s_runner.active);
+
printf("smtp.sessions = %zd\n", s_smtp.sessions);
+ printf("smtp.sessions.active = %zd\n", s_smtp.sessions_active);
+ printf("smtp.sessions.ssmtp = %zd\n", s_smtp.ssmtp);
+ printf("smtp.sessions.ssmtp.active = %zd\n", s_smtp.ssmtp_active);
+ printf("smtp.sessions.starttls = %zd\n", s_smtp.starttls);
+ printf("smtp.sessions.starttls.active = %zd\n", s_smtp.starttls_active);
return (1);
}
diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h
index fb9924fe721..da097f01504 100644
--- a/usr.sbin/smtpd/smtpd.h
+++ b/usr.sbin/smtpd/smtpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtpd.h,v 1.66 2009/01/30 21:22:33 gilles Exp $ */
+/* $OpenBSD: smtpd.h,v 1.67 2009/01/30 21:40:21 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -656,8 +656,13 @@ struct s_runner {
struct s_smtp {
size_t sessions;
+ size_t sessions_active;
+
size_t ssmtp;
+ size_t ssmtp_active;
+
size_t starttls;
+ size_t starttls_active;
};
struct stats {
diff --git a/usr.sbin/smtpd/ssl.c b/usr.sbin/smtpd/ssl.c
index 377bf726e1a..4cf4b88c672 100644
--- a/usr.sbin/smtpd/ssl.c
+++ b/usr.sbin/smtpd/ssl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssl.c,v 1.7 2009/01/29 14:25:55 gilles Exp $ */
+/* $OpenBSD: ssl.c,v 1.8 2009/01/30 21:40:21 gilles Exp $ */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -55,6 +55,8 @@ void ssl_client_init(struct session *);
extern void bufferevent_read_pressure_cb(struct evbuffer *, size_t,
size_t, void *);
+extern struct s_smtp s_smtp;
+
void
ssl_connect(int fd, short event, void *p)
{
@@ -506,6 +508,16 @@ ssl_session_accept(int fd, short event, void *p)
log_info("ssl_session_accept: accepted ssl client");
s->s_flags |= F_SECURE;
+
+ if (s->s_l->flags & F_SSMTP) {
+ s_smtp.ssmtp++;
+ s_smtp.ssmtp_active++;
+ }
+ if (s->s_l->flags & F_STARTTLS) {
+ s_smtp.starttls++;
+ s_smtp.starttls_active++;
+ }
+
session_pickup(s, NULL);
return;
retry:
@@ -582,5 +594,11 @@ ssl_client_init(struct session *s)
void
ssl_session_destroy(struct session *s)
{
+ if (s->s_l->flags & F_SSMTP) {
+ s_smtp.ssmtp_active--;
+ }
+ if (s->s_l->flags & F_STARTTLS) {
+ s_smtp.starttls_active--;
+ }
SSL_free(s->s_ssl);
}