Plesk & Server Architecture Matt | 12 Nov 2008
Parse Plesk Maillog, Count Emails Per Domain
I wanted to get a quick count of messages being sent to and from all my domains in plesk. I wrote this script to get the mail domains from the plesk database. Then I loop through them and grep a regex against the maillog file. Since I’m actually using zgrep to look decompress yesterday’s maillog file at the same time I get the counts, it’s a little processor intensive. It takes about 10 seconds to run through 30 domains in a 5 meg gzipped file. If I were to gunzip the file first and just grep it, this would go much quicker. But I’m fine with a 10 second run time and the bonus of not having to trash a decompressed maillog file when I’m done.
Here’s the bash script I’ve saved as mailcount.sh:
#!/bin/sh
MYSQLPASS=`cat /etc/psa/.psa.shadow`
for DOMAIN in `mysql -uadmin -p$MYSQLPASS -e "select distinct domains.name from mail inner join domains on mail.dom_id=domains.id" -B -N psa`
do
echo $DOMAIN `zgrep -c -E "(to|from)=.+@$DOMAIN" /usr/local/psa/var/log/maillog.processed.1.gz`
done
Here’s a version that copies and gunzip’s the maillog before doing any processing.
#!/bin/sh
MYSQLPASS=`cat /etc/psa/.psa.shadow`
# copy the log file before decompress
cp /usr/local/psa/var/log/maillog.processed.1.gz /usr/local/psa/var/log/maillog.processed.1-working.gz &&
# decompress the log working file
gunzip /usr/local/psa/var/log/maillog.processed.1-working.gz
for DOMAIN in `mysql -uadmin -p$MYSQLPASS -e "select distinct domains.name from mail inner join domains on mail.dom_id=domains.id" -B -N psa`
do
echo $DOMAIN `grep -c -E "(to|from)=.+@$DOMAIN" /usr/local/psa/var/log/maillog.processed.1-working`
done
# remove the working log file
rm -f /usr/local/psa/var/log/maillog.processed.1-working &&
echo "file removed"
exit;
ColdFusion & Plesk & Server Architecture Matt | 19 Oct 2007
ColdFusion 8 and Plesk 8 on RedHat 5 via mod_jrun22
After installing Plesk 8 on a RedHat 4 box I’ve needed to install Plesk 8 on Redhat 5. RedHat 5 uses mod_jrun22. Well it’s Apache 2.2 that uses mod_jrun22, so any version of Linux running Apache 2.2 will use this connector.
Since Plesk doesn’t support CF8 yet, it still writes out its apache directives looking for mod_jrun20. This needs to be modified to get per domain support for CF8 and Apache 2.2
Warning this will void your warranty!
I grepped the plesk install directory looking for mentions of jrun. I found a binary file that matched: /usr/local/psa/admin/sbin/websrvmng
Looking at this file, on line 228 there’s a mention of mod_jrun20 in plain text. This is the part of the websrvmng that writes out the http directives. After making a backup of this file I took a chance at making an edit. I simply changed mod_jrun20 to mod_jrun22 and saved the file.
Sure enough, plesk is happy. Now when checking the ColdFusion box in a domain setup I see <IfModule mod_jrun22.c> in the httpd.include file for that domain rather than <IfModule mod_jrun20.c>.
Be careful here, I’m sure this change would not survive a plesk update to websrvmng. After each plesk update double check this file to make sure it still points to mod_jrun22.
Plesk & Server Architecture Matt | 18 Oct 2007
Backup all mysql databases as seperate sql files
When backing up mysql databases via mysqldump you can either specify a database name to backup or use the –all-databases switch to dump all databases in one big file. I’d like to backup all my databases but I’d like them in separate files so they’re easier to manage and I can do a quick restore of a single db if needed.
I wrote the following bash script to help out.
#!/bin/sh
# all db separate files
for customerdb in `mysql -uadmin -pweb7A8u -e "show databases" -B -N`
do
mysqldump -uadmin -pweb7A8u $customerdb > /var/www/vhosts/mysql/$customerdb.sql
done
Or on my plesk server, I’ve got a table in plesk’s psa database that lists out all the databases created within plesk. A modification to this script reads the table names in the psa database table and makes backups of all those.
#!/bin/sh
for customerdb in `mysql -uadmin -pweb7A8u -e "select name from data_bases" -B -N psa`
do
mysqldump -uadmin -pweb7A8u --protocol=tcp --port=3307 $customerdb > /storage/mysqlbackup/$customerdb.sql
done
ColdFusion & Misc & Plesk & Server Architecture Matt | 29 Aug 2007
ColdFusion 8 and Plesk 8 on Red Hat ES 4
By default the Plesk control panel does not work with ColdFusion 8 yet. It sounds like official support will be available in Q1 of ‘08. I couldn’t wait that long. I’ve been able to get Plesk 8 to work with ColdFusion 8 to a degree.
I assume you’re familiar with how to install both separately so I’ll just be going over how to get both to play together.
In my world the Plesk control panel is just used simply used so that staff in our small software company can manage websites and not need to use a shell. No one else even has access to Plesk. Because of this, separation and security are not primary concerns. Also, I have no need to let anyone or myself manage CF DSN’s from within Plesk, being able to do this in CF Admin is fine.
So what I’ve done is enable the ColdFusion checkbox used when setting up a website so that CF code can be used on a particular website. Any ColdFusion management capabilities of Plesk are not enabled.
[root@yadda]# /usr/local/psa/bin/cfsetting -s /opt/coldfusion8
I/O warning : failed to load external entity "/opt/coldfusion8/runtime/servers/default/SERVER-INF/jrun.xml"
Config not parsed successfully.
Running that cfsetting command with the -s switch and the cf root from the commandline showed me an error plesk was running into. I found jrun.xml in a different place.
/opt/coldfusion8/runtime/servers/coldfusion/SERVER-INF/jrun.xml
Since I think jrun.xml should be pretty much the same from CF7 to CF8, I’m going to just try pointing Plesk to the right place with a simlink.
cd /opt/coldfusion8/runtime/servers/ && ln -s coldfusion default
Now I run the cfsetting command again.
/usr/local/psa/bin/cfsetting -s /opt/coldfusion8
Now I notice when starting up Apache that it’s trying to startup mod_jrun twice. In my ColdFusion install I selected to build a mod_jrun connector to hook into Apache during the install. Turns out that this conflicts with Plesk. It’s a simple fix. Just fire up your httpd.conf file and look for all instances of cfm or jrun. You should see these entries toward the bottom of the file. Just comment out the whole block of stuff by putting a hash sign in from of the lines. Or you could always delete this stuff if you want.
For each website that you enable ColdFusion support for you should see this code in the httpd.include file for the site.
JRunConfig Verbose false
JRunConfig Apialloc false
JRunConfig Ignoresuffixmap false
JRunConfig Serverstore /opt/coldfusion8/runtime/lib/wsconfig/psa/jrunserver.store
JRunConfig Bootstrap 127.0.0.1:51800
AddHandler jrun-handler .jsp .jws .cfm .cfml .cfc
If you need to do a little troubleshooting, just make sure that you don’t see code like this in any of the global config files for apache. As well make sure your jrunserver.store file exists. And make sure you’re loading the mod_jrun module somewhere. Plesk should drop this into zz010_psa_httpd.conf in the conf.d folder. Make sure that exists: LoadModule jrun_module /opt/coldfusion8/runtime/lib/wsconfig/psa/mod_jrun20.so. And lastly, double check your jrun.xml file you should see a mention of jrun broadcasting on port 51800 … you should see that in the jrun.servlet.jrpp.JRunProxyService block of the jrun.xml file. It’s possible that jrun is running on a different port, if that’s the case you’ll need to change it to 51800. Or somehow find out how to change the Plesk default.
If you have any troubles, post a comment here and I’ll see if I can help.







