All posts by tomasz

Debian syslog replacement

Standard way how Debian is logging things always made me crazy. Why the hell this daemon is logging everything 5 times? Why do I have to see mail logs in syslog file? Anyway, I started to look for some better solution and at one point I came on article describing installation and configuration if the standard syslogd replacement: syslog-ng. I decided to give it a try.

As the whole process is almost trivial I’ll put here only couple info

First – syslog-ng configuration file

The file is under /etc/syslog-ng/syslog-ng.conf

#
# Configuration file for syslog-ng under Debian
#

# the standard syslog levels are (in descending order of priority):
# emerg alert crit err warning notice info debug
# the aliases “error”, “panic”, and “warn” are deprecated
# the “none” priority found in the original syslogd configuration is
# only used in internal messages created by syslogd

######
# options

options {
chain_hostnames(0);
time_reopen(10);
time_reap(360);
sync(5);
log_fifo_size(2048);
create_dirs(yes);
owner(root);
group(root);
perm(0640);
#dir_owner(root);
#dir_group(root);
dir_perm(0755);
use_dns(no);
#log_msg_size(2048);
stats_freq(0);
};

######
# sources

source int { internal(); };
source main { unix-stream(“/dev/log”); };
source kernel { file(“/proc/kmsg” log_prefix(“kernel: “)); };

######
# destinations

destination mail { file(“/var/log/mail.log”); };
destination kernel { file(“/var/log/kernel.log”); };
destination messages { file(“/var/log/messages”); };
destination sshd { file(“/var/log/ssh.log”); };

######
# filters
filter mail { facility(mail); };
filter sshd { program(“ssh”); };

######
# logs
# order matters if you use “flags(final);” to mark the end of processing in a
# “log” statement

# these rules provide the same behavior as the commented original syslogd rules

log { source(kernel); destination(kernel); };
log { source(main); filter(sshd); destination(sshd); flags(final); };
log { source(main); filter(mail); destination(mail); flags(final); };
log { source(main); source(int); destination(messages); };

Little explanation:

  • Sources – defines sorce of incomming lg message. To be honest I didn’t dig deeper about meanings of every line there – it works.
  • Destinations – the name says it all – places (not only files) where messages ends.
  • Filters – again – rules allowing you to filter some messages out
  • Logs – the actual place where something happens. You decide here, from which source, with which filter applied to which destination message goes. Simply, clean and effective.

Second – logrotate script

As you may noticed as an output we have 4 files. I personally preferr to save them for a little longer. So my logrotate file for syslog looks like:

/var/log/ssh.log {
rotate 52
weekly
missingok
notifempty
compress
}

/var/log/kernel.log {
rotate 52
weekly
missingok
notifempty
compress
}

/var/log/mail.log {
rotate 52
weekly
missingok
notifempty
compress
}

/var/log/messages {
rotate 52
weekly
missingok
notifempty
compress
postrotate
/etc/init.d/syslog-ng reload >/dev/null
endscript
}

Please notice the postrotate part at the end of the file. It forces syslog-ng to writo to the new files.

Third – logcheck

Why would we need to have nicely divided logs without automated monitoring – here comes the logcheck. Here the only worth to mention change is a list of monitored files:

comp# cat /etc/logcheck/logcheck.logfiles
# these files will be checked by logcheck
# This has been tuned towards a default syslog install
/var/log/mesages
/var/log/kernel.log
/var/log/ssh.log
/var/log/mail.log
/var/log/auth.log

Don’t forget to teach your antispam filter to accept logcheck’s reports!

Technorati Tags: , , ,

Installing Zend Studio Server on Debian

As I said before – I can’t imagine working without Zend Studio now. So I decided to install server part of the package on one of my Debian powered servers.

So here we go. First we have to download correct package. As you can see on Zend’s site you have wide choice of versions:

-r– 1 25335043 Jan 15 17:20 ZendStudioServer-5.1.0a-Windows-i386.exe
-r– 1 23302044 Jan 15 17:21 ZendStudioServer-5.1.0a-darwin7.8-ppc.tar.gz
-r– 1 21371695 Jan 15 17:23 ZendStudioServer-5.1.0a-freebsd5.4-i386.tar.gz
-r– 1 22451335 Jan 15 17:21 ZendStudioServer-5.1.0a-linux-glibc21-i386.tar.gz
-r– 1 24682987 Jan 15 17:21 ZendStudioServer-5.1.0a-linux-glibc23-x86_64.tar.gz
-r– 1 23703327 Jan 15 17:21 ZendStudioServer-5.1.0a-sunos5.8-sparc.tar.gz

So I downloaded one

comp# wget -c http://downloads…..-glibc21-i386.tar.gz

and then as the README file says

comp# cd ZendStudioServer-5.1.0a-linux-glibc21-i386
comp# ./install-tty

All ther rest of the process was quick and easy with one note: when the instalator was looking for a php.ini fond one in /usr/lib directory.

Trying to determine the version of PHP.
Please wait… (this may take a few seconds)

Detecting … \ [100%]

Confirm the location of your php.ini file [/usr/local/lib]: /etc/php5/apache

So remember to make sure which php.ini is your Apache using and ajust that path accordingly. If you are not sure – call the phpinfo() function on any of your sites and check. It can save your day :-)

Technorati Tags: , ,

To use or not to use? IDE in everyday work.

I think almost all programmers, and web developers aren’t any different kind of them, come at one point to the situation when they have to build their work environment. From what you can see on various web sites usually they divide into two groups:

  • Vim advocates
  • IDE fans

I have to admit that for a long time I belonged to the first part – I was using basic text editor, all I needed was and ftp features. Then one day I started to work for Foothold and they wanted me to use Zend Studio. They even were so generous that they provided the license at no cost to me :-).

At the beginning it was pretty hard to get used to that system. It was written in Java. As you know the only advantage of Java (especially on slower machines) is it’s cross-platform nature. It took me almost three months to finally get all thing working, including the finally bought secondary monitor and faster computer with more RAM (if you don’t have at least 768MB it will freeze from time to time). But now the work is almost a pleasure.

More – I can’t imagine developing ANY more complicated site (like CMS or mentioned above A.W.A.R.D.S system) without the variable watchers, breakpoints, step by step debugging.

It’s like Polish way of driving cars – everybody prefer stick shift until they actually try the automatic one.

Technorati Tags: , , ,

Private VPN

As I needed to have my home HVAC server always reachable and keeping in mind that it’s on a dial-up connection (dynamic IP) I decided to build virtual private network. The main goal is to get the home computer visible from the server as it was in local network. Don’t worry, it’s much easier than it seems. Thanks to detailed HOWTO it took me less than 1h to build working connection.

As it’s to easy to do and to long to describe I won’t post detailed description. Just go to the howto and follow the instructons step by step.

OWFS instalation on Ubuntu 6.06

Here is small help and instruction howto install OWFS on new, out of the box Ubuntu 6.06 server edition.

1. Dependencies

First off all we need to take care of some needed packets:

comp# apt-get install \
       automake \
       autoconf \
       autotools-dev \
       gcc \
       g++ \
       libtool \
       libusb-dev \
       fuse-utils \
       libfuse-dev \
       swig \
       python2.4-dev \
       tcl8.4-dev \
       php5-dev

Agree for all additional needed packages apt will want to install

2. OWFS

Thanks to having fuse libraries already instaled we can go directly to the final step. First download the sourse.

comp# cd /usr/src
comp# wget http://umn.dl.sourceforge.net/sourceforge/owfs/owfs-2.4p3.tar.gz

Then extaract the file

comp# tar zxpf owfs-2.4p3.tar.gz

Compile and install

comp# cd owfs-2.4p3
comp# ./configure
comp# make && make install

3. Mounting one wire file system

First make sure that fuse kernel module is loaded

comp# modprobe fuse

It good to put it in /etc/modules file to have it automatically loaded during every system startup.

Then create the directory where 1-Wire filesystem will be mounted.

comp# mkdir /var/1-Wire/mnt

Finally we can connect our sensors to that point. In this case 1-Wire hardware is connected to the COM1 (ttyS0).

comp# /opt/owfs/bin/owfs /dev/ttyS0 /var/1-Wire/mnt

Now check if there are files and directories representing our sensors structure:

comp# ls /var/1-Wire/mnt
09.CF9EC8010000
10.64502F000800
alarm
bus.0
simultaneous
statistics
structure
system
uncached

Looks like everything is ok. The 10.64502F000800 (and all xx.yyyyyyyyyyyy) directory represents device on our 1-Wire architecture. First two characters define device family (10 – temperature sensor) the 12 characters after dot represents unique device serial number. You can go into that directory and check more properties of that particular sensor:

comp:/var/1-Wire/mnt/10.64502F000800# ls
address
family
power
r_id
temphigh
trimblanket
crc8
id
present
r_locator
templow
trimvalid
die
locator
r_address
temperature
trim
type

For detailed description of all parameters visit OWFS web site. To make sure our system is working – one last check:

comp:/var/1-Wire/mnt/10.64502F000800# cat temperature
75.3125

Looks good. Now it’s time to run some data collection thing to make those thing more usefull.

Technorati Tags: , , ,