Posts tagged swap

Server Side Spam Filter – Sendmail – Dovecot – Procmail

I tried for a long time to get sieve to work with sendmail. I could not get it to work. I would try and create a custom .m4 mailer, as per the sieve pages on the dovecot website, but nothing would work. Ultimately I gave up and used client side mail filtering built into Thunderbird. But this has a big drawback. A desktop session has to be logged on to keep the graphical application running. Because of this large amounts of system resources are consumed and end up being swapped out. As I would sit down at night it would take a significant amount of time for the desktop session to become responsive as it is retreived from swap. I tried disabling swap, but this was a no no because of MythTV’s commercial flagging. It would cause problems and lead to random system instability. Even with 8 gigs of ram my virtual server would sometimes crash. I don’t want this. Now I keep swap enabled and figured out how to get procmail to do server side mail filtering.

It was easy. Simply go into your sendmail.mc file and change the mailer. The default mailers are likely:

MAILER(local)

or

MAILER(smtp)

Install procmail and change the mailer accordingly:

MAILER(procmail)

Now go into your users home directory and touch a new file:

touch .procmailrc

Open it:

nano .procmailrc

Add:

GNU nano 2.0.7 File: .procmailrc
:0:
* ^X-Spam-Flag: YES
$HOME/mail/Junk

With this particular rule all messages flagged as spam, as per spamassassin, will be deposited into the Junk folder in the mail directory. It works as expected. For more information about sendmail, and how to configure spamassassin and clamav, visit a previous post.

Server Memory Setup – To Swap or Not to Swap

For a while I turned off the swap file on my virtual machine. It worked, but then I began to use more php pages and the server began acting funny, especially with database queries. After a day or two of the system crashing I turned on a swap file and the system stability came back real quick. The virtual machine has 1024 megs of ram and 2048 megs of swap and the system appears to be managing memory much better. Review your system performance and status with the top binary.

As for the host, I turned the swap partition back on, but I dont think it is needed. I will try server configurations on my days off this week.

Create a Swap File – Separate Partition is not Needed

Debian, and Ubuntu have an incredibly convenient package that creates a swap file in any directory. Install with:

sudo apt-get install dphys-swapfile

The installation process with automatically create the swap file. Then just enable it with:

sudo swapon -a

Viola, a fully function swap file that is not on a separate partition.

Swap Lag – Time to Retreive Data

I have a virtual machine, a MythTV server, and an email server running on my computer at home. The compiz desktop environment will lag substantially when I get home from work. I conclude that this is because during the day the desktop interface is not being use therefore it is thrown to the swap. There are several things that can be done to alleviate this lag.

1) The easiest thing to do is turn the swap off completely. This is done with a simple command:

sudo swapoff -a

2) I can logout of the desktop session to the GDM window.

Then after logging in the desktop session will be new in memory and will be responsive accordingly. The problem with this is that I need Thunderbird for its mail filtering capabilities. I can do mail filtering server level with Sieve, but I cannot get it to work right. I don’t know why it wont work, but to get around the problem, and achieve the same functionality, I use Thunderbird which is a graphical application. TO use Thunderbird I need the Gnome desktop fully loaded. EOS (End of Story).

3) To help with the situation you can renice running processes to help you desktop environment get better priority with the processor. Overall I wish I could get Sieve working, then I could just logout of the desktop session when I am done using it. The server would just run in the background using a “nohup” command, but im stuck with needing Thunderbird’s mail filtering. So for now I’ve turned the swap off to maintain system responsiveness. This is working ok because of the 8 gigs the system has. I will try to get Sieve working again.