Qpsmtpd connection time

From SME Server
Jump to navigationJump to search

Qpsmtpd connection_time plugin

The qpsmtpd connection_time plugin copies an entry into the qpsmtpd log file for each connection showing the total time that the connection was open.

Home Page: http://ankh-morp.org/~vetinari/projects/qpsmtpd/

HowTo Created By: Mmccarn 15:56, 26 June 2008 (MDT)

Issues/Problems

  • On SME 7.3 using smeserver-qpsmtpd-1.2.1-54.el4.sme, /var/service/qpsmtpd/config/plugins does not appear to be templated. Installing this plug-in requires editing a configuration file directly (instead of a template); these changes may be lost during normal SME updates or upgrades.
  • This plug-in creates no output unless it is included in BOTH
    • /var/service/qpsmtpd/config/plugins AND
    • /var/service/qpsmtpd/config/peers/<peer_config_file>
  • For SME, this amounts to inclusion in all three of the following plugin files:
    • /var/service/qpsmtpd/config/plugins
    • /var/service/qpsmtpd/config/peers/0
    • /var/service/qpsmtpd/config/peers/local
  • Uses the qpsmtpd LOGINFO log level, which requires SME's qpsmtpd LogLevel to be set to 6 or higher
    • You can verify your qpsmtpd LogLevel using
      config show qpsmtpd LogLevel
    • You can set your qpsmtpd LogLevel using
      config setprop qpsmtpd LogLevel 6

Installation

There is no plugin-specific configuration required; you need only place the plugin itself into SME's qpsmtpd plugins directory, then add the appropriate invocation to qpsmtpd's plugin configuration files.

The script shown here perform all of the required actions automatically. It will also create a backup of /var/service/qpsmtpd/config/plugins in case you encounter any problems.

You can run this script by copying and pasting it from this wiki page into a putty/ssh window logged in to your SME server as root.

# get the plugin itself
cd /usr/share/qpsmtpd/plugins
wget http://ankh-morp.org/~vetinari/qpsmtpd/connection_time
# add invocation to root 'plugins' file
cd /var/service/qpsmtpd/config
if [ -f /var/service/qpsmtpd/config/plugins.org.connection_time ];
 then 
  echo "Using existing backup file"
 else
  mv plugins plugins.org.connection_time
fi
sed s~hosts_allow~connection_time\\nhosts_allow~ plugins.org.connection_time > plugins
# add invocation to peers/0 and peers/local
mkdir -p /etc/e-smith/templates-custom/var/service/qpsmtpd/config/peers
cd /etc/e-smith/templates-custom/var/service/qpsmtpd/config/peers
mkdir 0
echo connection_time > 0/01connection_time
mkdir local
echo connection_time > local/01connection_time
# activate changes
signal-event email-update


Uninstallation

If for some reason you want to un-do the changes made by the above script, you need to:

rm -f /etc/e-smith/templates-custom/var/service/qpsmtpd/config/peers/0/01connection_time
rm -f /etc/e-smith/templates-custom/var/service/qpsmtpd/config/peers/local/01connection_time
cp /var/service/qpsmtpd/config/plugins.org.connection_time /var/service/qpsmtpd/config/plugins
rm -f /usr/share/qpsmtpd/plugins/connection_time