30
Jan/09
1

Bash: Timestamp in bash history

BashThe bash history is a useful thing to remember commands which were entered on a system. But it’s not only useful to help your mind – you can also keep track of the entered commands. This is especially interesting on multi user systems. You are able to check the executed commands after the user logs out. That is extra interesting when you spotted some problems like missing files on a system – you would be able to check if someone removed that file.
But by default you can only track the commands entered and you won’t know when they were entered. This could be very important. Thankfully there is a way to add timestamps to the bash history since Bash version 3.0.

See how to configure your bash to save the timestamp for each command execution…

23
Jan/09
3

Problem: PHP Gettext translation other than system language in Ubuntu

This is a note to myself: I was fooled by this problem two or three times and had to search all the times for the solution.

I tried to get NagVis work on Ubuntu with a different language than the system language. Gettext did not translate the strings. They were shown all the time in it’s key strings. There was no error message at all. After searching the problem in the PHP scripts I remembered that I needed some package the last time. So I searched for the language packages in Ubuntu. I tried to use the German translation of that application so I need the package for German language: language-pack-de. Simply installing it solves the problem:

sudo apt-get install language-pack-de

Filed under: Open Source
10
Jan/09
0

Gregarius as Feedhandler in Firefox

gregarius_thumbI use the web-based feed reader Gregarius since some time to get my daily dosage of news out of nearly 150 feeds. I used a very old version (0.5.4) since today. Normaly I keep my software up-to-date all the time but in this case I remembered that i made some changes to the code and I never was up to check what I changed exactly, update Gregarius and re-add my changes to the new version when needed.

This was completely causeless. I just updated to current version 0.6.1. I replaced all files and edited the dbinit.php manually. On first launch of Gregarius page I accepted to patch the database with some new default configuration options. That’s it…

By browsing through the admin panel I found a “new” link named “Register as Feed Handler” on the Feeds page. Okay, that feature is not new – it is included since version 0.5.5. But this feature is really useful for browsing with Firefox. When you open a feed in Firefox you have a dropdown menu for adding this feed to your favorite reader. Now I can add new feeds by simply selecting it in the form. No copy ‘n paste of the feed URLs anymore.

9
Jan/09
3

Disable “discard items” in drupal feed aggregator

I’m using the Drupal CMS in version 6.8 on one of my homepages. I use the delivered plugin Aggregator for parsing a news feed. It works as it should with one exception: The Aggregator deletes some objects when they are older than the configured time. This feature is called “discard old items”. You can configure the time-range in admin interface of Aggregator.
I found it not good to have some pre computed values in a drop-down field. I would better like to add an individual time-range myself.
Additional I like to disable this feature for my feed. Additionally it would be nice to be able to change the “discard” criteria to something other – You’ll find some ideas at the end of this post.

7
Jan/09
1

ofs (offline file system) on Ubuntu 8.10

I was searching a long time for something like “windows offline folders” for linux. Finally I found it in an article about ofs (aka offlinefs aka offline file system) in german “linux magazin” 01/09.

After my first tries to get offlinefs running on Ubuntu 8.10 I recognized some problems compiling it. After contacting the developers and adding bugs to the tracker on sourceforge.net the biggest problems where solved. Now I am able to compile it in Ubuntu Intrepid.

According to the developers ofs has only be tested with smbfs/cifs. At the moment I experiment with sshfs and offlinefs. Seems like it is possible to get this work. I’ll experiment a bit and maybe post a small howto later…

Filed under: Open Source
7
Jan/09
3

Software Tipp: Piwik – the open source web analytics software

I’m not a fan of submitting usage information of my web pages to other sites like Google Analytics or any other service providers. I like to keep the data under my control. Some moth ago I found a tool which seems to have the potential to be a good replacement for Google Analytics. It is an easy to install php web application based on a MySQL database. Now I run Piwik for some moths and it’s great. Piwik is licensed under the terms of the GPL. The current version is 0.2.28. I admit Piwik is in development state and not completely stable in all points but it is really good for basic website statistics.

I stopped all other tools which were used for statistic purposes. Now all usage information remain on my servers.

Filed under: Open Source
4
Jan/09
1

Create a dynamic ssh tunnel for your firefox

I had some problems to access the Internet from my local client. My OpenWRT router was not forwarding the connections properly. Connections from the router to the net were no problem. Cause surfing the net with text based browsers is not mine I created a tunnel from my client to the router to be able to connect outside from the client.

I created the tunnel on my Ubuntu box via:

:> ssh -D 8080 <username>@192.168.1.1

After authentication I am able to connect to the Internet with any application on the client. I configured my Firefox to use a socks proxy:

Start firefox, select Edit -> Preferences. At Advanced tab, select Network tab and then “Connection Settings…”. Select “Manual proxy configuration”. Clear everything there expect SOCKS entry. Put IP 127.0.0.1 as host, 8080 as port and select SOCKS v5. Then hit OK. Now you can surf the net from your client via the ssh’ed host.

Filed under: Open Source
18
Dec/08
2

Answer: Why does df -k show wrong percentage usage?

I use the Nagios plugin from check_snmp_storage from manubulon.com to monitor disk usage on several unix and windows systems.

Some times I found some linux admins saying that their volumes are nearly full but Nagios did not notify them before. And in fact df -k said: “Disk is 95% full”. check_snmp_storage said: “Disk is 90% full”.

Well, I was searching some time to find the answer… After reading man pages, checking snmp values manually, reading code of check_snmp_storage I came to the point: The calculation of percentage usage in df -k is “wrong”.

Sample output of df -k:

Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda1             16973900  12379804   3738636  77% /myvol

here my percent calculation:

12379804/16973900*100=72.934352152%

So what? Another 5% diff… Everytime 5% on all disks I looked at.

Sure. All disks are ext3. After some research I found that the reason is the reserved space for root (by default 5%) in ext2 and ext3 volumes. For detailed information see explanation of -m param in man mke2fs:

-m reserved-blocks-percentage Specify the percentage of the filesystem blocks reserved for the super-user. This avoids fragmentation, and allows root-owned daemons, such as syslogd(8), to continue to function correctly after non-privi‐leged processes are prevented from writing to the filesystem. The default percentage is 5%.

You can query volumes to see the amount of reserved space:

tune2fs -l /dev/sda1

After that I found the option -R for check_snmp_storage. With these option you can add the reserved-blocks-percentage to the results of that checks. -R 5 does the job.

Filed under: Open Source
9
Dec/08
5

Quickie: Sort IP-Addresses on linux command line (bash)

I have some ip-addresses in a text file. One address per line. The addresses are unsorted. I’d like to have them in a correct order. Some example from file “addresses”:

192.168.1.1
192.168.1.4
80.68.11.31
192.168.10.33
192.168.11.3
81.67.12.31

Now I run sort with the following options to sort these ip addresses:

:> sort -t . -k 1,1n -k 2,2n -k 3,3n -k 4,4n addresses

The sort command sends this to stdout:

80.68.11.31
81.67.12.31
192.168.1.1
192.168.1.4
192.168.10.33
192.168.11.3

Short explanation for the params:

-t .: Use dot as field seperator. -k 1,1n: First sort key is field 1, sort it numeric.

The lines are sorted by each sort key one after another.

Filed under: Open Source
27
Nov/08
1

My git cheat sheet

In the last days I’ve spent several hours days understanding the concept of git. Now I need to write down some commands to be able to remember the commands which I don’t use every day when working with the git system.