Tuesday, April 25, 2006

Long lines listing dpkg

I use to store a list of packages previous to an update and before it in order to mantain documentation about the changes made to each system I administer.

To do this I use to dump the following information prior and before the upgrade of packages:

  • ls -l /var/cache/apt/archives

  • dpkg -l



The problem is that dpkg -l shows the result well under console shell but cuts the output to 80 columns when the output of the command is redirected to a file.

To solve it is so easy, you only need to change the following environment variable to a value greater than 80 with a command like that:

# export COLUMNS=120
# dpkg -l > dpkg_l.list


That give us the report without that column shrink

Monday, April 24, 2006

Configuring a Linux host to receive log messages from external systems, including Windows

This article explains how to configure a linux server to receive syslog messages from external sources and how to configure those external systems to send log messages to the server, including NetScreen, Cisco, Linux and Windows systems.

Background information

I'm using systems using Debian GNU/Linux as Linux hosts and Windows 2000 SP4 and Windows 2003 SP1 as Windows hosts. The Netscreen firewalls are running ScreenOS 5 and Cisco routers are using IOS 12.2.

1. Configuring the server

The first step to do is to install a syslog server. My choice is syslog-ng, because provide an easy to use configuration files and because I'm using it for more than ten years :-).

To install the syslog-ng software under Debian i have to execute:

# apt-get install syslog-ng


In my environment the syslog-ng version is 1.6.5-2.2.Now it's time to configure the syslog-ng system. To do this, edit the file under /etc/syslog-ng/syslog-ng.conf and add the following line under the source s_all environment (between source s_all { and the } brackets) add the following line to enable the syslog listen udp paquets from outside:

udp();


Now it's time to restart the service (/etc/init.d/syslog-ng restart) and continue the installation.

2. Configuring the client

I provide the configuration guidelines for my systems, but the explanation is easy to extend to any system, specially if the system is a router, switch or similar with a configuration system using web pages.

2.1 Linux

To configure a linux host as a syslog client is as easy to do as configuring it as a server (that's the magic of Linux...). You only need to add a few lines to the syslog-ng.conf file located under /etc/syslog-ng:

destination sysloghost { udp(""); };
filter f_all { level(info, notice, warn, crit, err); };
log { source(s_all); filter(f_all); destination(sysloghost); };



The first line adds a new destination to the syslog system, changing the ip_address field using the ip address of the syslog server. The second line add a new filter that accept any level of information, and finally, the last entry adds a new log 'file' that links the source (the default source s_all accept any source), the filter and the destination.

2.2 Windows

To prepare the windows system to send the event viewer information to a syslog server we need to install a GPL software called ntsyslog. This software can be download from http://ntsyslog.sourceforge.net/.

To install the software you have un unpack it to the destination folder where you want to keep it and, under command line, execute the following commands to install it as a service:

c:\ntsyslog> ntsyslog -install


Now you can configure it using a control tool called NTSyslogCtrl, where you can choose the destination host of the events (our sysloghost) and then choose which kind of events to send.

2.3 Cisco IOS

To configure a Cisco IOS to send syslog messages to a syslog server, you need, under config environment, execute the following command:

# set logging
# wr


The first command add the sysloghost, and the second write the configuration :-).

2.4 NetScreen ScreenOS

The Juniper NetScreen can also send their messages. You can select this options under Configuration -> Report Settings -> Syslog, but take care of which kind of traffic you send to the syslog, or you'll get files of a few GB per month with all the logging from the rules!!!

3. Syslogging and beyond

Once we have all the systems targetting to our new syslog server, you'll see there is a lot of information saved that can make the files unreadable. That's a few suggestions about next steps to take, that i'll cover in next articles:

  • Rotate the logs using a tool like logrotate daily. I have configured my syslog host keeping a month (previous month are compacted to a file by a script and backed up to a DAT cartridge

  • Create a database to store online logs as they arrive to syslog

  • Create a database to store logs as they are rotated if you have a big amount of entries

  • Install a log checker as logcheck to resume the entries to those more interesting sending by e-mail the result

  • Send the messages to a network management system like JFFNMS



Disclaimer
I hope this article will give you the chance you need to start this fascinating world of the syslog messages and their management. Anyway the article is offered in good faith as comprising only safe programming and procedures. No responsibility is accepted by the author for any loss or damage caused in any way to any person or equipment, as a direct or indirect consequence of following these instructions.

You are welcome to send me any suggestion, comment or problem related to this article or their implementation to my e-mail address (josep.llaurado AT gmail.com).

Customize the My Places Bar in the save as dialog boxes

Well, I'm one of those that don't agree with the conventional use of the computers, and that means, for example, that I had never used the left icons in the save as dialog boxes to access my favorite places to save files.

I have my own personal directory structure separated in three paths, one for the professional ones, another for the personal ones, and the latest for the university documentation... and the question is: Why I have to see on the left of every save as dialog box the same useless links to folders I will never use?

I was investigating this weekend to solve it and to find a way to change those links for my own set of 'favorite folders'. First I was thinking the way to do this was modifying the registry, but it's not necessary thanks to the MS people!! We can customize that kind of personal things under Windows using Microsoft tools.

First of all you need to download the PowerToys for Windows XP from Microsoft. I give you the link to the main page of the powertoys in order to take a look a lot of tools that can be usefull for you, take a look, a few ones promise a lot of entertainment... But for our purpose we need to download th TweakUI program (it's easy to download using IExplorer rather than Firefox, you are aware of that).

Yo need to install, and then execute it. Go to the "Common Dialogs" -> "Places Bar". Now you can choose the amazing places Windows offer to you, like My documents, my music, etc... or you can write the full path of the folders you are interested to use.

Saving and closing the application it's the only thing to do in order to get the new beauviour of the save as dialog for all the windows applications.... except one... Microsoft Office!!!! Yes, it's incredible but it's true. Microsoft Office don't use the standard that Microsoft Windows uses to save files.

In order to change the save as dialog under Office, you have to follow the instructions of a KB note 826214 modifying the registry. I have do it and works...

I will investigate the TweakUI app in more depth and I'll give you more interesting tips in the future.