Off Road

Chris’ blog

Off Road header image 4

Articles de 'en'

Spamassassin can learn from Exchange before 2007

08.12.2008 19:16 · Aucun Commentaire

I found a better way of teaching Spamassassin from Exchange. But it works trough IMAP. And Exchange 2007 doesn’t allow imap to access to public folders any more :-(

http://sstern.ccim.com/2006/07/14/training-sitewide-spam-filters/

here is a copy-paste :

How does one enable end-user training of a site-wide Bayesian spam filter for SpamAssassin when the users are reading mail through Microsoft Exchange and the filtering takes place on several Linux MX servers?

We have created two public folders, should-be-spam and should-be-ham. We created an exchange user, spamiam, that has full rights to these folders. End-users move misclassified mail from their inbox or junk-mail folder into the appropriate should-be public folder.

At the top of every hour, this script is run on the one MX server:

/usr/local/scripts/get_ham_spam
#! /bin/sh
rm -f /var/spool/mail/spamiam
touch /var/spool/mail/spamiam
chown spamiam:mail /var/spool/mail/spamiam
su spamiam -c 'fetchmail -a -K -f
/usr/local/scripts/spamiam.fetchmailrc -r "Public Folders/should-
be-spam"'
cat /var/spool/mail/spamiam >> /var/www/html/spamstuff/should-be-spam
sa-learn --spam --mbox /var/www/html/spamstuff/should-be-spam
rm -f /var/spool/mail/spamiam
touch /var/spool/mail/spamiam
chown spamiam:mail /var/spool/mail/spamiam
su spamiam -c 'fetchmail -a -K -f
/usr/local/scripts/spamiam.fetchmailrc -r "Public Folders/should-
be-ham"'
cat /var/spool/mail/spamiam >> /var/www/html/spamstuff/should-be-ham
sa-learn --ham --mbox /var/www/html/spamstuff/should-be-ham

/usr/local/scripts/spamiam.fetchmailrc
poll exchange.xxxx.com
proto imap
user spamiam
password xxxxxxxxx
is spamiam here

At 15 past each hour, the two other mail servers use wget to grab the
should-be files to their local /tmp and run sa-learn.

get-ham-spam
#! /bin/sh
cd /tmp
rm -f should-be-spam should-be-ham
wget -q http://xxx.xxx.com/spamstuff/should-be-spam
wget -q http://xxx.xxx.com/spamstuff/should-be-ham
sa-learn --spam --mbox should-be-spam
sa-learn --ham --mbox should-be-ham

The files are included in logrotate on the source server, so they get zero’d every Sunday
morning.

[Lire la suite →]

Tags: IT · Server · en · mail · network

entourage et Exchange 2007

29.10.2008 18:00 · Aucun Commentaire

Lors de notre passage à Exchange 2007, les clients Entourage ne pouvaient plus se connecter.

C’est le site de microsoft qui a fini par m’apporter la réponse : il ne faut pas se contenter de mettre le nom du serveur dans la case : nom de serveur….. il faut mettre

mail.contoso.com/exchange/user@contoso.com

Le pire c’est que lorsque je mettais mail.contoso.com je n’avais aucune erreur, tous les tests étaient passés avec succés, mais il ne me listait jamais les dossiers…

C’était à cette adresse : http://support.microsoft.com/kb/931350/en-us

[Lire la suite →]

Tags: IT · Server · apple · en · mail · windows

quotes

30.09.2008 01:18 · Aucun Commentaire

“Excellence is the result of caring more than others think is wise, risking more than others think is safe, dreaming more than others think is practical, and expecting more than others think is possible.” Unknown

“A positive attitude may not solve all your problems, but it will annoy enough people to make it worth the effort.” Herm Albright

“Sometimes there is no next time, no timeouts, no second chances, sometimes it’s now or never.” Unknown

“Whether you believe you can or not, you are right.” Henry Ford

“I have not failed; I’ve only found 10,000 ways that do not work.” Thomas A. Edison

“Some of the world’s greatest feats were accomplished by people who were not smart enough to know they were impossible.” -Doug Larson

“Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world.” Albert Einstein

“All that is needed for evil to triumph is for good men to do nothing.” Edmund Burke

“You must have the desire to want it, the strength to endure it, the attitude to become it, and the commitment to achieve it.” Unknown

[Lire la suite →]

Tags: en · life

Exchange 2007 and mailboxes size list ?

02.09.2008 17:28 · 3 Commentaires

I found a solution here, the paste/copy follows :

You would have noticed that you are not able to see the Total Items and Size (KB) of user’s mailboxes in Exchange Management Console of 2007. Even you are not able to add columns optionally.

image

Like you were able to see in Exchange System Manager of version 2003 displayed below.

image

Now question is where to see/add those options… Your answer is run the PowerShell command to see those options.

When I run below command in Exchange Management Shell for Database name “Mailbox Database”, it gives similar output to ESM 2003. Only difference is it shows size in Bytes instead of KB.

Get-MailboxStatistics -database “Mailbox Database” | Select DisplayName, LastLoggedOnUserAccount, ItemCount, TotalItemSize, LastLogonTime, LastLogoffTime | Format-Table

image

Now if I want to export this into CSV the I need to run below command.

Get-MailboxStatistics -Database “Mailbox Database” | Select DisplayName, LastLoggedOnUserAccount, ItemCount, TotalItemSize, LastLogonTime, LastLogoffTime | Export-CSV test.csv

image

Now lets say I want size in MB then I  need to run below command.

Get-MailboxStatistics -Database “Mailbox Database” | Format-Table DisplayName, LastLoggedOnUserAccount, ItemCount, @{expression={$_.totalitemsize.value.ToMB()};label=”Size(MB)”}, LastLogonTime, LastLogoffTime

image

If I want to sort this report by Mailbox Size then I need to run below command.

Get-MailboxStatistics -Database “Mailbox Database” | Sort -Property TotalItemsize | Format-Table DisplayName, LastLoggedOnUserAccount, ItemCount, @{expression={$_.totalitemsize.value.ToMB()};label=”Size(MB)”}, LastLogonTime, LastLogoffTime

image

  • In these examples we got reports for database “Mailbox Database” in same way we can get it for whole server with below command.

Get-MailboxStatistics -Server MailboxServer01

  • Here we added DisplayName, LastLoggedOnUserAccount, ItemCount, TotalItemSize, LastLogonTime, LastLogoffTime columns in our report and in same way we can add below list of columns …

AssociatedItemCount
Database
DatabaseName
DeletedItemCount
DisconnectDate
DisplayName
Identity
ItemCount
LastLoggedOnUserAccount
LastLogoffTime
LastLogonTime
LegacyDN
MailboxGuid
ServerName
StorageGroupName
StorageLimitStatus
TotalDeletedItemSize
TotalItemSize

[Lire la suite →]

Tags: IT · Server · en · mail

Hamachi, or how sharing files (or whatever else) throughout any Routers

26.08.2008 18:51 · Aucun Commentaire

Hamachi is a centrally-managed zero-configuration virtual private network (VPN) freeware application capable of establishing direct links between computers that are behind NAT firewalls without requiring reconfiguration (in most cases); in other words, it establishes a connection over the Internet that very closely emulates the connection that would exist if the computers were connected over a local area network. Currently available as a production version for Microsoft Windows and, as beta, for Mac OS X and Linux. On August 8, 2006, it was announced that Hamachi was being purchased by LogMeIn.[1]

[Lire la suite →]

Tags: IT · en · network

Configure unmanaged Mac Clients for Softwares Update server

14.05.2008 09:50 · Aucun Commentaire

To point unmanaged clients to a specific software update server:
1 Open Terminal on the unmanaged client.
2 Enter the following command:

$ defaults write com.apple.SoftwareUpdate CatalogURL URL

Replace URL with the URL of the Software Update server. For example:
http://su.domain_name.com:8088/

[Lire la suite →]

Tags: IT · Server · apple · en · network

Subscribe to comments

07.05.2008 14:12 · Aucun Commentaire

subscribe-to-comments

Lorsqu’on laisse un commentaire sur le blog, il est assez frustrant de ne pas pouvoir être tenu au courant des réponses par email. Il existe un plugin wordpress nommé subscribe-to-comments qui ajoute une case à cocher lorsqu’on laisse un commentaire sur un article.

Grace à cette case on peut demander à être notifié par emails chaque fois qu’une autre personne laissera un commentaire sur le même article.

Il existe la possibilité de s’inscrire sans laisser de commentaire, mais c’est si agréable d’en avoir…

Subscribe to Comments is a wordpress plugin that enables commenters to sign up for e-mail notification of subsequent entries. The plugin includes a full-featured subscription manager that your commenters can use to unsubscribe to certain posts, block all notifications, or even change their notification e-mail address!

[Lire la suite →]

Tags: IT · blog · en · fr

Preventing access to .svn folders in Apache

03.05.2008 15:03 · Aucun Commentaire

When you use SVN to deploy your website on the apache server, in each folder everybody can access to the .svn subfolders. So it’s possible to get your code (even passwords…).
2 solutions can be used in the Apache config file :

<Files ".svn">
    Order allow,deny
    Deny from all
</Files>
<DirectoryMatch "/\.svn/">
    Order allow,deny
    Deny from all
</DirectoryMatch>

or

RedirectMatch 404 /\.svn(/|$)

I added the 2nd solution to my apache.conf and it works fine.

I fould them on http://www.subversionary.org/martintomes/preventing-access-to-svn-folders-in-apache

But if you are not the admin of your web server, you can just use a .htaccess file like that :

RewriteRule ^(.*/)?\.svn/ - [F,L]
ErrorDocument 403 "Accès interdit

I found this last line in http://maestric.com/fr/doc/programming/subversion

[Lire la suite →]

Tags: IT · Server · en

Automatic Mysql Backup

02.05.2008 15:25 · Aucun Commentaire

PS (15/05/2008) : my boss has written a new script in shell : mysql-backup.sh.txt

You just change your information at the top of the file (user, password…) and you put it in /etc/cron.daily

You should choose a remote folder for you backup.

Warning : do not keep the .sh at the end of the file once in /etc/cron.daily , on debian etch it’s not allowed

——

My boss has written a very nice code (in Python) to have a backup of every mysql databases.

To use it I had to install mysql library of python on my debian server:

apt-get install python-mysqldb

Then after I can use this script in your crontab:

/usr/bin/python mysqlbackup.py -r 7 -a -u MYUSER -p MYPASSWORD -H localhost -f /home/bakcup/mysql

You can get all options like that:

/usr/bin/python mysqlbackup.py --help

The most important option is “-r”, you can choose how many days you want to keep, to I always have 7 folders :

root@server:/home/backup/mysql/offroad# ll
total 5492
-rw-r--r-- 1 root root 822902 2008-04-29 17:56 offroad_20080429.sql
-rw-r--r-- 1 root root 827306 2008-04-30 03:00 offroad_20080430.sql
-rw-r--r-- 1 root root 823815 2008-05-01 03:00 offroad_20080501.sql
-rw-r--r-- 1 root root 792233 2008-05-02 03:00 offroad_20080502.sql
-rw-r--r-- 1 root root 794411 2008-05-03 03:00 offroad_20080503.sql
-rw-r--r-- 1 root root 761013 2008-05-04 03:00 offroad_20080504.sql
-rw-r--r-- 1 root root 764510 2008-05-05 03:00 offroad_20080505.sql

Here is the code of mysqlbackup.py

import traceback
import datetime
import os
import sys
import re

def backup_folder(options,database):
if options.subdir:
result = os.path.join(options.folder,database)
try:
os.makedirs(result)
except:
pass
return result
else:
return options.folder

def find_previous_backups(options,database):
file_re = re.compile(database+r'_(\d{4})(\d{2})(\d{2})\.sql(\.bz2)?',re.I)

result = []
now = datetime.datetime.now()
folder = backup_folder(options,database)
for filename in os.listdir(folder):
m = file_re.match(filename)
if m is not None:
age = now - datetime.datetime(int(m.group(1)),int(m.group(2)),int(m.group(3)))
fullname = os.path.join(folder,filename)
result.append((age,fullname))

result.sort()

return result

def main(options):
options.excludedatabases=set(db.lower() for db in options.excludedatabases)

if options.alldatabases:
try:
import MySQLdb
except:
print "Could not import MySQLdb ; you should probably install it"
print "Fetch it from the 'MySQL for Python' Sourceforge project :"
print "\thttp://sourceforge.net/project/showfiles.php?group_id=22307"
return

connection = MySQLdb.connect(options.host,options.user,options.password)
try:
cursor = connection.cursor()
try:

cursor.execute('show databases')
for row in iter(cursor.fetchone,None):
db=row[0].lower()
if db not in options.excludedatabases:
options.databases.append(row[0])

finally:
cursor.close()
finally:
connection.close();

for database in options.databases:
try:
now = datetime.datetime.now()
filename = database+'_%04i%02i%02i.sql'%(now.year,now.month,now.day)
directory = backup_folder(options,database)
fullname = os.path.join(directory,filename)

if options.mysqlpath:
mysqldump = os.path.join(options.mysqlpath,'mysqldump')
else:
mysqldump = 'mysqldump'

if options.compress:
command = """%s --host="%s" --user="%s" --password="%s" "%s" | %s -tbzip2 -mx=5 -si a "%s.bz2" """%(
mysqldump,
options.host,
options.user,
options.password,
database,
os.path.join(os.path.dirname(sys.argv[0]),"7za.exe"),
fullname
)
command = "%s " % (
command,
)
else:
command = """%s --host="%s" --user="%s" --password="%s" -r "%s" "%s" """%(
mysqldump, options.host, options.user, options.password, fullname, database
)

print "! %s"%command
os.system(command)

if options.max_age is not None:
for age, fullname in find_previous_backups(options,database):
if age.days > options.max_age:
print "- %s"%fullname
os.remove(fullname)

if options.command :
command = options.command%dict(backup=fullname)
print '! %s'%command
os.system(command)
except:
traceback.print_exc()

if __name__=='__main__':
import optparse
parser = optparse.OptionParser()

parser.add_option('-m','--mysql-path',dest='mysqlpath',help='MySQL binaries path')

parser.add_option('-H','--host',dest='host',help='MySQL host')
parser.add_option('-u','--user',dest='user',help='MySQL user')
parser.add_option('-p','--password',dest='password',help='MySQL password')

parser.add_option('-a','--all-databases',action='store_true',dest='alldatabases',default=False,help="Sauvegarde toutes les bases de donnees")
parser.add_option('-d','--database',action='append',dest='databases',default=[],help="Nom d'une base de donnees a include")
parser.add_option('-D','--exclude-database',action='append',dest='excludedatabases',default=[],help="Nom d'une base de donnees a exclure")

parser.add_option('-f','--folder',dest='folder',default='.',help='Backup folder')
parser.add_option('-S','--no-subdirs',action='store_false',dest='subdir',default=True,help='Don\'t create a separate folder per database')
parser.add_option('-r','--remove',type='int',dest='max_age',help='Remove backup files older than MAX_AGE days')
parser.add_option('-z','--zip',action='store_true',dest='compress',default=False,help='Compress the file')

parser.add_option('-c','--command',dest='command',default=False,help='Execute this command when a database backup is over. Use "%(backup)s" to substitute the file name')

options, args = parser.parse_args()
main(options)

[Lire la suite →]

Tags: IT · Server · en

Cloudy Paris

20.04.2008 00:49 · Aucun Commentaire

En fait Paris a su se faire aux nuages avec élégance

Actualy, Paris wears clouds like a princess…

Cloudy Paris

[Lire la suite →]

Tags: en · fr · life