I'd like to announce start of new project for PostgreSQL admins – Curo.
Some time ago, we talked with my colleagues at OmniTI about administration of PostgreSQL, and how nicer it would be if we'd have some common tool that shows important info at will.
The thing is, that when you have PostgreSQL installed, you get psql – which you can use to get all the info you might need, but you need to type long queries to get the info you want/need.
The problem with additional tools is that not always admins are happy to install stuff for you, or there are problems with compilation. So snippets can be nicer to use.
So, I got the idea of preparing set of such snippets, ready to use, and possibly – make them easier to use.
How easier? Generally when you have snippet, you have top copy/paste it, or save in file, and then do \i file in psql. But what about making them available through a menu? Or a single key press?
This is how Curo was born.
It is in very early stage right now, but it works, and we tested it on 3 systems: Linux, Mac OS X and Solaris.
So, how it works.
Afterwards, you save the checkout as ~/.curo directory – that is “.curo" in your home directory.
Then, if you want (and you do want) keyboard shortcuts (f1-f8 keys) to work, you install appropriate readline/libedit configuration file, and you're done.
How to know which is appropriate? If you don't know – use both.
As for the configuration files – it's all described in docs so there is not much point in repeating.
Afterwards, as long as you have psql, bash and dialog, it's done.
Dialog installation is necessary to get nice menus, and dialog is usually not installed by default. So to get it you need to use your system package manager (yum, apt-get, pkgadd, port, whatever) to get it. It shouldn't be complicated, the software is free, and it's only dependency should be ncurses.
One note – dialog is needed for menu/setup screens. All reports can be ran directly using appropriate \i ~/.curo/s/something.sql from within your psql, including actions ran by pressing f* keys.
When you'll finish installation, run psql, connect to your database of choice, and you can play with Curo.
For starters – press F1. It should show menu with all currently installed actions, plus setup screen.
In setup, you can change key bindings for f1-f8 keys.
From menu you can run the actions – like “Current Activity", but you should be able to get them also from f* keys.
At the moment we have 4 actions/snippets committed to svn:
- Current activity – shows, refreshed automatically, every 1 second, information about activity in current database. This is subset of information from pg_stat_activity, but presented in potentially easier to read way (plus it autorefreshes!)
- Locks information – not yet finished – information of locks taken by backends connected to current database. This will be revamped soon(ish)
- Idle in Transaction – Information about oldest current “IDLE in transaction" backend, together with info about which relations it has locks on
- Blocked queries – shows which queries are blocked, and by which queries
As you can see we're focusing now on locks, but that's just for now. We will add more functionality to Curo, and we'll be happy to get information from other users, about what could be useful to add there.