Repository
Munin (contrib)
Last change
2018-08-02
Graph Categories
Family
auto
Capabilities
Keywords
Language
Shell

mail_connections

Sadly there is no documentation for this plugin.

#!/bin/sh
#
# Plugin to count the open connections for smtp, pop3 and imap
#
# Magic markers - optional - used by installation scripts and
# munin-config:
#
#%# family=auto
#%# capabilities=autoconf

PORTS="25 smtp SMTP
	110 pop3 POP3
	143 imap IMAP
	465 ssmtp SMTP-SSL
	587 submission SMTP (submission)
	993 imaps IMAP-SSL
	995 pop3s POP3-SSL"

if [ "$1" = "autoconf" ]; then
	ports=$(echo "$PORTS" | cut -f 1 -d " ")
	for port in $ports; do
		netstat -ln | grep -q ":$port " && echo "yes" && exit 0
	 done
	# no open connections for typical mail ports found
        echo "no (no listeners for smtp/pop3/imap ports found)"
        exit 0
fi

if [ "$1" = "config" ]; then
	cat <<EOT
graph_title Open mail server connections
graph_args --base 1000 -l 0
graph_vlabel connections per second
graph_category mail
EOT
	echo "$PORTS" | while read port field label; do
		echo "${field}.label $label"
		echo "${field}.type DERIVE"
		echo "${field}.min 0"
	 done
	exit 0
fi

echo "$PORTS" | while read port field label; do
	echo -n "${field}.value "
	netstat -n | grep ":$port " | wc -l
 done