Archive for April, 2010

Generate Awstats Statistics from multiple Apache logs / Generate Awstats statistics for multiple domain names / Automatically configure awstats to show reports for multiple domain names

Friday, April 9th, 2010

Awstats Picture

I’ve created a small shellscript that allows the administrator to build log statistics for multiple domain names.
You can download the script to generate statistics from multiple log files awstats_generate_multiple_sites.sh from here .
The usage of the script is quite self explanatory. You have to follow the instructions in the commented head of the script.
After you have properly configured the script all you have to do is set it to be executed via crontab.
Again in the script head I’ve included information with an example on how to add it to a crontab. The script takes all subdirectories from /var/log/apache2 assuming that each of the subdirectories contains access.log and error.log file names.
It generates a number of configuration files to be later red by awstats and after finishing, invokes awstats to generate the statistics from the previously generated awstats domain configuration files.
Finally the script generates an html files with links to each of the domains for whom awstats has generated statistics.
The idea for the script hit me, before a week time, after I’ve red an article which explains how to achieve something similar to what the script does manually.
You can read the article configuring multiple awstats for multiple domain on dreamhost here . I believe the script can be quite useful to the administrators out there who are looking for a quick way to generate awstats statistics from their many domain log files.
Cheers! 🙂

Enable Rsyslog and Syslog cron events logging in /var/log/cron.log on Debian Lenny

Friday, April 9th, 2010

By default Debian doesn’t log it’s cron events in a separate log file.
All the cron events got logged along with all the other syslog events configured by default in either syslog or rsyslog.
So you end up with a /var/log/syslog which includes many versatile messages. That’s really unpleasent if you want to keep track of your cron events separately.
I always change this behaviour while configuring new servers or Desktop systems running Debian.
Therefore I decided to share here what I do to enable separate cron logging. The logged cron events would go to var/log/cron.log.
As a starter please make sure you have the file /var/log/cron.log existing on your filesystem tree, if you have it not then please create it:
debian:~# touch /var/log/cron.log

To configure your crond to log to /var/log/cron.log on a system running syslogd all you have to do is edit /etc/syslog.conf and either include the line:

cron.* /var/log/cron.log
or simply uncomment the same line already laying commented in the syslog.conf.
If you’re using the enhanced version of syslogd for Linux (Rsyslog) the code syntax that is necessery to be included is absolutely identical.
Again you have to include:

cron.* /var/log/cron.log

in /etc/rsyslog.conf or uncomment the line shown above in /etc/rsyslog.conf.

Now last step to do is to reload syslogd or rsyslogd.

With syslogd running on your system execute:

debian:~# killall -HUP syslogd

With rsyslogd as a default system logger:

debian:~# killall -HUP rsyslogd

Now you should have your crond logging to the separate /var/log/cron.log, wish you happy cron.log reading 🙂

The Name of The Rose (Der Name der Rose) – 1986 Movie

Thursday, April 8th, 2010

The Name of The Rose Movie Poster

A week ago, I’ve watched the The Name of The Rose or as originally entitled (Der Name der Rose).
The movie was recommended to my by a friend, stressing out that the movie has to deal more or less with Christianity topics in general and Catholicism in general.
Though the movie plot is based on Umberto Eco‘s novel, and he as an author is not among my favourite authors.
The movie is definitely worth seeing, if you’re Christian.
It’s also an interesting fact that the movie includes some celebrities like:
Sean Connery and Christian Slater .The whole story revolves around a mystery that emerged in Medieval Abbey in Italy.
For some strange reason, few suicides occur among monks.
That completely puzzles the monk, so the monks in the brotherhood decide to invite a monk who is famous for his good skills in solving mysteries.
The investigating monk (William of Baskerville) arrives at the abbey with his young disciple.
It’s interesting that William of Baskerville is a bit more thinker than a believer, so he refuses to accept the idea of the Abbot that the Devil is crawling the abbey and causes the suicides and misfortunes in the abbey.
After some deep investigation he comes to some conclusion and finds out that all the dead monks in the abbey has a black mark on their right hand finger as well as on their tongue.
This drives him to the idea that the monks were probably poisened.
A notable figure in the Movie is the Abbot who is an old monk whose possesing a vision/image of a prophet.
The old abbot is strongly against the logical approach in solving mysteries and completely trusts in God’s providence.
Monk William of Baskerville as being a logical nature enters in a dispute with the abbot, where they blazingly argue if the monks should laugh or not, should they be allowed to read books with text including laughter or life parody or not.
The abbot is firmly against the idea of the enlightenment of man through books and believes the Christian Monk enlightenment should be achieved mostly through experience in prayer thank in Books.
As the movie progress since the killings in the monastery continue without any solution, the Catholic church sends the Holy Inquisition to solve the mystery.
The inquisition makes the situation even worse and the mystery deepens even further on.
Eventually it turns out that this Abbey actually, has a secret passage leading to one of the largest libraries of it’s time.
The library holds thousands and thousand of books including many laughter books. As the abbot finds out about the discovery, he falls out in holy fear that the laughter books can emerge and be copied and multipled many times.
Opening the humour and laughter genry for the whole Church world as well for the laymen.
The superannuated monk realizes that this book transperancy could underneath the Church authority among people and therefore decides to burn the library putting on fire as he puts on fire the whole monastery tower containing the textbooks.
In the meantine the inquisition doesn’t sleep and judges for a burning at the stake 3 people.
Among which are two monks, who the inquisition classifies as schismatics and a young village girl, who is captured in the monastery right before one of the monstreous monks attempts to rape her.
The girl is innocent as she is completely illiterate and doesn’t have a clear idea on sin e.g. on what is right and what is wrong.
However at the end of the movie the girl, rightously survives by the Grace of the Virgin Mary, while the two dissenter monks are burnt out.

The movie touches one major theme in Christianity which is quite present even today, even though it’s probably out of question among Orthodox Christians.
It discusses the problem should we Christians read many spiritual books to drawn closer to God or should we achieve our holiness in concentrating on prayer.
It deals with the problem which is poisoning many christians today.
Should we base our lifes on science or should we completely consider science fallacy most of the time?
The movie stand point is the same as mine as well as in the Orthodox Church.
While it tells the story it shows that, actually at the end everything is in God’s hands, but however it presents that human factor is also important.
In other words I believe the movie teaches that, We should be moderate in all we do! and keep our faith while moderately evaluating our surrounding world.
Of course ultimately we should place our faith in our God and humble ourselves before him, but we shouldn’t act as a madman and we should also consider the logic which was also created by God in the beginning.

Howto delete multiple files in Linux and FreeBSD / How to deal with “Argument list too long” error while deleting many files in directory

Wednesday, April 7th, 2010

Linux has some Limitations on the number of files you can delete within a directory, therefore if you try to delete let’s say 100000 files with a quarantine mails from spamassassin.
In that case you are about to face an error Argument list too long . The amount of files you can delete in Linux is tied with something specified by a file:
/usr/include/linux/limits.h
This limitation is a limitation caused by kernel_limits. In order to check the limitation on your Linux distribution, you have to execute the command:

egrep ARG_MAX /usr/include/linux/limits.h

You should receive a result on most Linux distrubutions similar to:
#define ARG_MAX 131072 /* # bytes of args + environ for exec() */

The 131072 is actually a default limitation on Debian GNU/Linux as well.The reason for the error is that the the maximum number (in bytes) of the arguments to a command could be equal max to the ARG_MAX defined in the limits.h.
For instance rm -f * in a directory with 40000 fileswould be evaluted as rm -f file1 file2 file3 … file40000. Therefore at a certain point the maximum limitation of 131072 bytes long for arguments or 128KB is about to be reached and then the command let’s say ls * would refuse to list the files in the directory showing up the annoying Argument list too long error.
There are a couple of ways to deal with that unpleasant situation.

1. You can use the linux find command to delete the files, you have to execute after changing dir (cd) to the directory where the multiple files are located:
find . -exec rm -fr {} ; 2. Second approach to the problem is passing the xargs command to find .
For instance execute the command:

find . -name "*" -print | xargs rm

3. In FreeBSD to get around the “Argument list too long” problem”, in bash shell you have to execute:

for files in *.*; do rm -f $files; done

4. Another possible way is to increase the ARG_MAX value in limits.h though this approach in my personal belief could have a negative impact on some productive servers, therefore it’s not a recommended.
Yet if you desire to do so simply edit /usr/include/linux/limits.h and change the ARG_MAX to your value of choice.

Howto delete empty directories in GNU /Linux with find linux command

Wednesday, April 7th, 2010

Ever wondered how you can delete all the empty directories in Linux?
I bet you did, there are many ways to achieve that in GNU/Linux, however here is one way you might go:
First it is probably a good idea to list the empty directories and examinethe empty directories before you take the next step and execute a command to delete them:

find . -depth -type d -empty

Now after you take a close look in the directories, next step to partake is delete the directories.

find . -depth -type d empty -exec rmdir {} ;

Be aware that in the above examples, the first one would list all directories in your current directory in which you
execute the command, the second example will delete all the empty directories starting from your current directory unto thedeepest located empty directory in the directory tree.

Christ is Risen! – Truly he is Risen! Hristos Voskrese! Voistinu Voskrese!

Sunday, April 4th, 2010

The Gloriour Resurrection of Our Lord and Saviour Jesus Christ!

Christ is risen from the dead, trampling on death by death, and on those in the tombs bestowing life.Christ is Risen!Indeed He is Risen!

Check out the Paschal Greeting which is common to be pronounced as a hello greetin the Eastern Orthodox Church.
Also widely common practice in Bulgaria during The day of the Glorious Resurrection of our Lord and Saviour Jesus Christ!

Today it’s Holy Saturday or the Great Sabbath day (The day in which Jesus Christ rested physically in the tomb) right before the Lord’s Resurrection

Saturday, April 3rd, 2010

It’s Holy Friday . It’s the day in which our Lord and Saviour Jesus Christ’s dead body was resting in the “tomb” as the Gospels from the New Testament teaches.
Today we in the Orthodox Church held a late Church service to honour for a last time the Lord’s death holding the deep spiritual grief for his betrayal and death on the cross.
We also wait with expectancy the Son of God’s resurrection which as the Holy Scriptures teaches has been found Risen! by the Our Holy Virgin Mary and Mary Magdalene.
We at are on about to enter the joyous part of the year. The time of miracles and great Divine Grace.
The Son of God is Dead but yet he should rise again as he has already resurrect some 20 centuries earlier.
We are about to be enlighten once again with his Never ending holy Light, through the Church service to be held this night.
In Bulgaria the Church service usually starts about 23:30 and usually continues until 02:30 early in the Morning.
We also have the practice to pick up the burning light from the priest’s candle in the Church and bring it home.
We believe this transfers God’s grace in both our hearts, mind soul as well as our homes. This is being done as we expect that God blesses us with this act with a good spiritual and physical health.
It’s also important to note that on this day each year the the Holy Fire comes down from heaven in the Jerusalem Temple Church (The Holy Sepulchre) and lights up the Jerusalem’s Orthodox Patriarch (High Priest)’s Candle.
This is undoubtfully a miracle that proofs the truthfulness of the Orthodox Faith. This also proofs that our Orthodox Faith Church as well as tradition is the puriest Christian faith available for us the Christians of this age!
This Holy Fire after is usually distributed among the Orthodox Christian Churches around the world using planes with candles burning with the the Holy Fire.
The fire is being brouhgt to Bulgarian Orthodox Church from Jerusalem through a plane, right after it descends from Heaven and is being distributed to the Major cities, towns and villages.
Then we the normal church layman can benefit from the fire, lighting up our candles from this Holy Fire and in that find God’s Grace both by God and in God (The Holy Trinity).
Here is a link to the Video of the Holy Fire Ceremony from Jerusalem 2010.

So Thanks and Glory to our Holy God for his great miracle! Glory be to our Holy Lord (The Father, The Son and the Holy Spirit) now and unto ages of Ages! Amen.

Some Helpful Subversion (SVN) general repository managing commands when you have to deal with Subversion on Debian Lenny servers

Friday, April 2nd, 2010

When I started with subversion it was a bit chaotic for me to grasp the subversion repository software basics.
Since I know there are many other people like me who are a novice into suversion I decided to post few of the
life saving (vital) subversion commands, I learned and use quite often this days.
This post should be considered as a very very overview of subversion commands. For more information please check, The subversion red-bean book here .
So here we go:
1. First To create repository after installing subversion you need to execute something similar to:

debian-server:~# svnadmin create --fs-type fsfs /path/to/repos/repo

In the above example /path/to/repos is actually the path to where you store the svn repositories, and repo is actually the repository name.
By the way note that by default svnadmin would create the repository in the fsfs database format, even if you skip the,
fsfs option.2. Let’s say you want to import some code into the newly created repository located in /path/to/repo via the local filesystem.
Here is how:

# imports in the subversion repositorydebian-server:~# svn import -m "importing directory in svn over local filesystem"
~/directory_to_import/ files:///path/to/repos/repo/trunk

In the forementioned example the, -m and the following text: “importing directory in svn over local filesystem” is for description of the importing data,
the ~/directory_to_import/ is the directory you prefer to import into the local repository, the code left,
files:///path/to/repo/trunk specifies that you want to import the data into the repository subdirectory “trunk”.

Then again let’s assume that you want to achieve a file import into a newly created repository through ssh + the apache mod_dav_svn

It’s pretty easy the above should be changed to:

debian-server:~# svn import -m "importing directory in svn over mod_dav_svn e.g. (svn+ssh)"
~/directory_to_import/ svn+ssh://user@host/path/to/repos/repo/trunk
of course it preliminary that you input a proper user and host or ip address as you have previously configured the mod_dav_svn, then again svn+ssh specifies the protocol type.

Now as we have imported our program source code into the repository, next it’s important to checkout the code to have a current copy of the source code.
3. To checkout code already existing in some repository in your subversion server via (svn+ssh) protocol, you need to execute some command similar to:

debian-server:~# svn co svn+ssh://user@host/path/to/repos/repo/trunk ~/checkout_into_directory/

Here again as a first protocol argument (svn+ssh://) it’s necessery to enter path/to/repos/repo/trunk and as a second argument to gsvn (the subversion command line client interface) we put ~/checkout_into_directory/ , it’s a nice idea to to create the checkout_into_directory beforehead.

Now if we have to checkout the code after we’ve been logged in the system and the repository database is locally stored on the same server as we are, we have to execute:

debian-server:~# svn co files://path/to/repos/repo/trunk ~/checkout_into_directory/

Take a note that in the example above I use the root user but possibly you would choose a non-privileged user, therefore you should have properly set both physical user account permissons on the subversion repository database (e.g. chown your /path/to/repos/repo/ and put your local user into the proper /etc/groups).

Another truly precious command that you will probably need to use on daily and hourly basis would probably be:
4. The listing of repository content cmd, in order to do that while locally logged on the server with the svn repository execute:

debian-server:~# svn list file:///path/to/repos/repo/trunk

I believe the above command is self-explanatory enough, in case if you plan to do file listing within the svn repository over (ssh+svn) here is how:

debian-server:~# svn list --verbose svn+ssh://user@host/path/to/repos/repo/trunk

Again, I won’t take the time to explain since the logic in the syntax is equal to the one exhibited beforehead.
5. Another handy thing to do with your subversion repository content after checkout is the subversion source repository update

the svn update The checkout will enable you to always synchronize your ~/checkout_into_directory to the latest stable version of the code within your svn repository.

So after the first checkout it would be good idea to use svn update and update your repository project source tree.
So here is how:

debian-server:~# svn update ~/checkout_into_directory/

So now as I have shown most basic operations with subversion, Lest important to show you is
6. How to delete source from a repository in subversion.

In order to delete some part from your subversion repository project source from the local filesystem use:
debian-server:~# svn delete files:///path/to/repos/repo/track/some_directory

This command would completely erradidacate some_directory from your example repo. Yet if you desire to delete a file specify a file instead of the some_directory

Now to accomplish the same delete operation via (svn+ssh) execute something like:

debian-server:~# svn delete svn+ssh://user@host/path/to/repos/repo/track/some_directory

Once again I won’t bother to explain the above example code, cause I believe it’s clear enough for everybody to understand.

7. To reverse your project code to some stable release of your source code existing in the repository you should use something like:

debian-serve~:# svn checkout -r 4 files:///path/to/repos/repo/trunk
This would checkout the project source to it's 4th release from the repository: repo

8. To commit code with changes in your subversion repository use a command like:

debian-server:~# svn commit -m "Some description text" some_directory/

The svn command line interface is also capable of svn copy and svn rename in order to either,
copy or rename commited source, however I won’t get into details on that just experiment and you’ll quickly master them.
9. Now one last thing I’m gonna tell you about is the subversion svn info command and svn status . This really useful command should be used to check information on your source tree after you have either checked it out or have used svn update to have the latest copy of it. This is an absolute necessity.

Here is how to check the information assigned about the version release and some other useful info for your source tree.

debian-server:~# svn info ~/check_into_directory
or you might type svn info without arguments as well
debian-server:~# svn info

Yet another useful one on project status is:

debian-server:~# svn status

Fix to a problem with Varnish Cache not showing Apache’s .htm files extension on FreeBSD

Thursday, April 1st, 2010

I’m running my Apache server behind a Varnish Cache server. At most of the time all works okay, however today I’ve noticed a significant problem.
The problem consists in the fact that whenever I have directory listing enabled for some directory and I have dropped some .htm files, the htm files wouldn’t open as a proper html but instead the following message appears on click over some of the htm files:.

You have choosen to open 1.htm
which is a: PTHML file
from: http://myurl.com/
What should firefox do with this file?
(*) Open With (Browse ...)
( ) Save File ...

Here is also a screenshot of the error You have choosen to open … which is a: PHTML file:
you have choosen to open ... which is a PHTML file

At the beginning I though the error is caused by Apache and it was kind of weird since Apache my Apache serves a bunch of .html files without any issues.
It took me a while to realize that actually the problem is caused by the Varnish Cache server.
I digged my head into Varnish configuration, in hope to find something mentioned in the documentation but I couldn’t find anything meaningful there.
So after a while I decided to start experimenting with Apache.
Invoking the files directly on the port where I have Apache listening prooved me that Apache doesn’t have any problems with passing the .htm files content with a proper Application Type.
But anyways since I couldn’t find nothing in Varnish documentation, I’ve tried changing some stuff into my Apache configuration until finally I solved it!
The whole issue got solved by simply adding the following line in my Apache configuration file httpd.conf in my case on my FreeBSD

AddHandler application/x-httpd-php .htm .html .phtml

A simple Apache and Varnish restart and Hoooray, It Works again! 😀