Network and Database Administration


Navigation

About Us
Services
Jeff's Tech Tips
Contact us

Jeff's Tech Tips Remapping scroll lock in linux

After having your server stop working because someone inadvertenly left the console scroll-locked while switching between machines with the KVM, you're probably curious how to remap the scroll lock key to prevent this. Here's what I did:

You just use the loadkeys utility to remap the keyboard. I map the scroll lock key to num lock so it doesn't do any damage if someone pushes it by accident.

On Fedora, you can use the file: /lib/kbd/keymaps/i386/qwerty/defkeymap.map.gz as the default to edit. I just gzcatted it to /usr/local/lib/defkeymap.map And then made the following changes shown by diff:

/usr/local/lib $ diff defkeymap.old defkeymap.map
168c168
< keycode  70 = Scroll_Lock      Show_Memory      Show_Registers
---
> keycode  70 = Num_Lock      Show_Memory      Show_Registers
170c170
<       alt     keycode  70 = Scroll_Lock
---
>       alt     keycode  70 = Num_Lock
Then, you can just put the following in /etc/rc.local:
#
# Remap scroll lock to num lock so people don't scroll lock the server
# by accident
/bin/loadkeys /usr/local/lib/defkeymap.map
And you should be all set.

How to print to your local print queue via rdesktop

Recent versions of rdesktop now allow you to redirect more than just sound output. The most useful of these is redirecting a local print queue. I often rdesktop into remote client machines and being able to print to the printer sitting on my desk can be a life saver on occassion. The syntax of the command from the man page is quite simple:

-r printer:<printername>[=<driver>],...

And so, to forward my Lexmark E332n via rdesktop, the command looks like so:

rdesktop -r printer:Lexmark-raw="Lexmark E332n PS3" somesystem.example.com

There are 2 gotchas in setting this up. The first is that you must have an exact match on the driver side of the house..which means you must have already installed the Lexmark (in this case) driver on the machine you are remoting into. However, if the printer is postscript capable, you can just leave the driver portion off the end and rdesktop will use a very basic PS driver (HP Laserjet III I believe) like so:

rdesktop -r printer:Lexmark-raw somesystem.example.com

The second gotcha I encountered was that when I actually attempted to print something, all I got was the postscript text filling page after page of my printout. The solution is to set up a raw printer queue (that's why it's named Lexmark-raw above). To do that in KDE, I simply went to the Control Center, clicked on Peripherals, Printers, Administrator Mode, and entered the appropriate password. Then right-click and select Add Printer/Class, click Next, select your printer type (for me it was Network Printer), next, enter the printer details, next, and in the driver section, click the Raw printer (no driver needed) checkbox, next through the rest of the dialogs until you enter the queue name, then click finish. Use the new queue name you created after the -r printer: and you should be in business.

How to find postgresql queries running longer than a certain time frame

If you've ever wondered if you have a long running query in PostgreSQL and have statistics turned on in postgresql.conf:

                stats_start_collector = true
                stats_command_string = true
                stats_block_level = true
                stats_row_level = true
                stats_reset_on_server_start = true

Then, you can simply run a query similar to the following:

select * from pg_stat_activity where query_start < now() - interval '1 min';

If you find this interesting, then you will probably be interested in the Practical Query Analysis tool. PQA will give you insight into which queries are run the most often, which queries take the most run time, etc.

How to setup PostgreSQL PITR based High Availability

This information has been moved to the pgpitrha project at pgfoundry here: http://pgpitrha.projects.postgresql.org/ and here: http://pgfoundry.org/projects/pgpitrha.
Please contribute.

Where is the PostgreSQL pgpass file on Windows?

On windows the .pgpass file is actually called pgpass.conf and can be found in:

%appdata%\postgresql\pgpass.conf

For example, the default path for my user jeff would be:

C:\Documents and Settings\jeff\Application Data\postgresql



Copyright © 2009 Frost Consulting, LLC. All Rights Reserved.