Hi,
I've missed SMTP plugins for munin to monitor the smtpd daemon from
OpenBSD. So I started to write five simple shell scripts but I'm not
quite sure if I used the proper values from smtpctl.
Any comments are welcome.
Index: Makefile
===================================================================
RCS file: /cvs/ports/net/munin/Makefile,v
retrieving revision 1.37
diff -u -p -r1.37 Makefile
--- Makefile 15 Jan 2014 08:24:25 -0000 1.37
+++ Makefile 9 Feb 2014 22:59:41 -0000
@@ -62,7 +62,8 @@ FAKE_FLAGS += HTMLDIR=${WRKINST}/${PREF
CONFDIR=${WRKINST}/${PREFIX}/share/examples/munin
MUNIN_PLUGINS = bgpd if_pps_ intr pf_changes pf_searches
pf_states \
- sensors_ vmstat
+ sensors_ smtp_delivery smtp_mails smtp_queue_cache \
+ smtp_sessions smtp_sessions_created vmstat
.for i in ${MUNIN_PLUGINS}
SUBST_LIST += ${FILESDIR}/$i ${WRKSRC}/plugins/node.d.openbsd/$i.in
Index: files/openbsd-packages
===================================================================
RCS file: /cvs/ports/net/munin/files/openbsd-packages,v
retrieving revision 1.3
diff -u -p -r1.3 openbsd-packages
--- files/openbsd-packages 21 Jan 2010 20:59:30 -0000 1.3
+++ files/openbsd-packages 9 Feb 2014 22:59:41 -0000
@@ -5,3 +5,18 @@
#[postfix_mailqueue]
#user _postfix
+
+[smtp_delivery]
+user root
+
+[smtp_sessions]
+user root
+
+[smtp_sessions_created]
+user root
+
+[smtp_queue_cache]
+user root
+
+[smtp_mails]
+user root
--- /dev/null Sun Feb 9 23:58:50 2014
+++ files/smtp_delivery Sun Feb 9 23:47:45 2014
@@ -0,0 +1,68 @@
+#!/bin/sh
+#
+# Script to monitor STMP mail delivery
+# (c) 2014 Guenther Niess <[email protected]>
+#
+# Parameters:
+#
+# config (required)
+# autoconf (optional - used by munin-config)
+# suggest (optional - used by munin-config)
+#
+#%# family=auto
+#%# capabilities=autoconf
+
+smtpctl='/usr/sbin/smtpctl'
+
+if [ "$1" = "autoconf" ]; then
+ if [ ! -x ${smtpctl} ]; then
+ echo "no (${smtpctl} is not executable)"
+ exit 0
+ else
+ echo no
+ exit 1
+ fi
+fi
+
+if [ "$1" = "suggest" ]; then
+ exit 0
+fi
+
+if [ "$1" = "config" ]; then
+ echo graph_title SMTP Mail delivery
+ echo graph_vlabel mails / second
+ echo graph_category mail
+ echo graph_args --lower-limit 0
+ echo graph_info smtpd mail delivery plugin
+ echo ok.label ok
+ echo ok.type DERIVE
+ echo ok.min 0
+ echo tempfail.label tempfail
+ echo tempfail.type DERIVE
+ echo tempfail.min 0
+ echo permfail.label permfail
+ echo permfail.type DERIVE
+ echo permfail.min 0
+ echo loop.label loop
+ echo loop.type DERIVE
+ echo loop.min 0
+fi
+
+${smtpctl} show stats | awk -F'=' '
+BEGIN {
+ ok=0;
+ permfail=0;
+ tempfail=0;
+ loop=0;
+}
+/^scheduler.delivery.loop=/{loop=$2;}
+/^scheduler.delivery.permfail=/{permfail=$2;}
+/^scheduler.delivery.tempfail=/{tempfail=$2;}
+/^scheduler.delivery.ok=/{ok=$2;}
+END {
+ print "ok.value", ok
+ print "tempfail.value", tempfail
+ print "permfail.value", permfail
+ print "loop.value", loop
+}
+'
--- /dev/null Sun Feb 9 23:58:57 2014
+++ files/smtp_mails Sun Feb 9 23:47:45 2014
@@ -0,0 +1,68 @@
+#!/bin/sh
+#
+# Script to monitor STMP mail statistics
+# (c) 2014 Guenther Niess <[email protected]>
+#
+# Parameters:
+#
+# config (required)
+# autoconf (optional - used by munin-config)
+# suggest (optional - used by munin-config)
+#
+#%# family=auto
+#%# capabilities=autoconf
+
+smtpctl='/usr/sbin/smtpctl'
+
+if [ "$1" = "autoconf" ]; then
+ if [ ! -x ${smtpctl} ]; then
+ echo "no (${smtpctl} is not executable)"
+ exit 0
+ else
+ echo no
+ exit 1
+ fi
+fi
+
+if [ "$1" = "suggest" ]; then
+ exit 0
+fi
+
+if [ "$1" = "config" ]; then
+ echo graph_title SMTP Mails
+ echo graph_vlabel mails / second
+ echo graph_category mail
+ echo graph_args --lower-limit 0
+ echo graph_info smtpd messages plugin
+ echo delivered.label delivered
+ echo delivered.type DERIVE
+ echo delivered.min 0
+ echo expired.label expired
+ echo expired.type DERIVE
+ echo expired.min 0
+ echo removed.label removed
+ echo removed.type DERIVE
+ echo removed.min 0
+ echo bounced.label bounced
+ echo bounced.type DERIVE
+ echo bounced.min 0
+fi
+
+${smtpctl} show stats | awk -F'=' '
+BEGIN {
+ delivered=0;
+ expired=0;
+ removed=0;
+ bounced=0;
+}
+/^scheduler.delivery.ok=/{delivered=$2;}
+/^scheduler.envelope.expired=/{expired=$2;}
+/^scheduler.envelope.removed=/{removed=$2;}
+/^queue.bounce=/{bounced=$2;}
+END {
+ print "delivered.value", delivered
+ print "expired.value", expired
+ print "removed.value", removed
+ print "bounced.value", bounced
+}
+'
--- /dev/null Sun Feb 9 23:59:03 2014
+++ files/smtp_queue_cache Sun Feb 9 23:47:45 2014
@@ -0,0 +1,56 @@
+#!/bin/sh
+#
+# Script to monitor STMP queue cache
+# (c) 2014 Guenther Niess <[email protected]>
+#
+# Parameters:
+#
+# config (required)
+# autoconf (optional - used by munin-config)
+# suggest (optional - used by munin-config)
+#
+#%# family=auto
+#%# capabilities=autoconf
+
+smtpctl='/usr/sbin/smtpctl'
+
+if [ "$1" = "autoconf" ]; then
+ if [ ! -x ${smtpctl} ]; then
+ echo "no (${smtpctl} is not executable)"
+ exit 0
+ else
+ echo no
+ exit 1
+ fi
+fi
+
+if [ "$1" = "suggest" ]; then
+ exit 0
+fi
+
+if [ "$1" = "config" ]; then
+ echo graph_title SMTP Queue Cache
+ echo graph_vlabel mails / second
+ echo graph_category mail
+ echo graph_args --lower-limit 0
+ echo graph_info smtpd queue cache plugin
+ echo hit.label hit
+ echo hit.type DERIVE
+ echo hit.min 0
+ echo missed.label miss
+ echo missed.type DERIVE
+ echo missed.min 0
+fi
+
+${smtpctl} show stats | awk -F'=' '
+BEGIN {
+ hit=0;
+ missed=0;
+}
+/^queue.evpcache.load.hit=/{hit=$2;}
+/^queue.evpcache.load.missed=/{missed=$2;}
+END {
+ print "hit.value", hit
+ print "missed.value", missed
+}
+'
--- /dev/null Sun Feb 9 23:59:13 2014
+++ files/smtp_sessions Sun Feb 9 23:47:45 2014
@@ -0,0 +1,48 @@
+#!/bin/sh
+#
+# Script to monitor STMP sessions
+# (c) 2014 Guenther Niess <[email protected]>
+#
+# Parameters:
+#
+# config (required)
+# autoconf (optional - used by munin-config)
+# suggest (optional - used by munin-config)
+#
+#%# family=auto
+#%# capabilities=autoconf
+
+smtpctl='/usr/sbin/smtpctl'
+
+if [ "$1" = "autoconf" ]; then
+ if [ ! -x ${smtpctl} ]; then
+ echo "no (${smtpctl} is not executable)"
+ exit 0
+ else
+ echo no
+ exit 1
+ fi
+fi
+
+if [ "$1" = "suggest" ]; then
+ exit 0
+fi
+
+if [ "$1" = "config" ]; then
+ echo graph_title SMTP Sessions
+ echo graph_vlabel sessions
+ echo graph_category mail
+ echo graph_args --lower-limit 0
+ echo graph_info smtpd sessions plugin
+ echo session.label sessions
+fi
+
+${smtpctl} show stats | awk -F'=' '
+BEGIN {
+ session=0;
+}
+/^smtp.session=/{session=$2;}
+END {
+ print "session.value", session
+}
+'
--- /dev/null Sun Feb 9 23:59:18 2014
+++ files/smtp_sessions_created Sun Feb 9 23:47:45 2014
@@ -0,0 +1,62 @@
+#!/bin/sh
+#
+# Script to monitor created STMP sessions
+# (c) 2014 Guenther Niess <[email protected]>
+#
+# Parameters:
+#
+# config (required)
+# autoconf (optional - used by munin-config)
+# suggest (optional - used by munin-config)
+#
+#%# family=auto
+#%# capabilities=autoconf
+
+smtpctl='/usr/sbin/smtpctl'
+
+if [ "$1" = "autoconf" ]; then
+ if [ ! -x ${smtpctl} ]; then
+ echo "no (${smtpctl} is not executable)"
+ exit 0
+ else
+ echo no
+ exit 1
+ fi
+fi
+
+if [ "$1" = "suggest" ]; then
+ exit 0
+fi
+
+if [ "$1" = "config" ]; then
+ echo graph_title SMTP Sessions Created
+ echo graph_vlabel sessions created / second
+ echo graph_category mail
+ echo graph_args --lower-limit 0
+ echo graph_info SMTP sessions created
+ echo local.label local sessions
+ echo local.type DERIVE
+ echo local.min 0
+ echo ipv4.label IPv4 sessions
+ echo ipv4.type DERIVE
+ echo ipv4.min 0
+ echo ipv6.label IPv6 sessions
+ echo ipv6.type DERIVE
+ echo ipv6.min 0
+fi
+
+${smtpctl} show stats | awk -F'=' '
+BEGIN {
+ local=0;
+ ipv4=0;
+ ipv6=0;
+}
+/^smtp.session.local=/{local=$2;}
+/^smtp.session.inet4=/{ipv4=$2;}
+/^smtp.session.inet6=/{ipv6=$2;}
+END {
+ print "local.value", local
+ print "ipv4.value", ipv4
+ print "ipv6.value", ipv6
+}
+'