Subject Re: [firebird-support] getting server properties in fb classic 1.5
Author Milan Babuskov
wang960 wrote:
> Is there a way to get Server properties of fb classic 1.5 in a linux?

"Server properties" can have a lot of meanings.

> I want to know what are the databases connected

You can use lsof(1) command, grepping out by file extension:

root@asus:/# lsof | grep firebird | grep fdb
1799 firebird 1028096 207312 /baze/chat.fdb
1780 firebird 1028096 207312 /baze/chat.fdb
1836 firebird 93411328 208887 /baze/keops.fdb
1835 firebird 1028096 168282 /opt/firebird/examples/employee.fdb


To be more precise, you can send PID (process ID) of Firebird server to
lsof and only show its open files. That works much faster on a busy
system and also filters out the other output that may contain the word
firebird in it. Obtaining PID can be done with pidof(8) command:

root@asus:/# pidof fb_inet_server
1836 1835 1799 1780

As you can see, I have 4 database connections and thus 4 processes. The
lsof command expects those to be separated by commas and not spaces, so
we'll replace those before sending it:

root@asus:/# pidof fb_inet_server | sed "s/ /,/g"
1836,1835,1799,1780

And here is the final command:

root@asus:/# lsof -p `pidof fb_inet_server | sed "s/ /,/g"` | grep fdb
1799 firebird 1028096 207312 /baze/chat.fdb
1780 firebird 1028096 207312 /baze/chat.fdb
1836 firebird 93411328 208887 /baze/keops.fdb
1835 firebird 1028096 168282 /opt/firebird/examples/employee.fdb

Please note that I removed some columns of output to make it look nicer
on the screen. For a nice and terse output, you can use awk(1) to
extract the column you wish. Version of lsof on my system prints out the
filenames in 9th column, so I write this:

root@asus:/# lsof -p `pidof fb_inet_server | sed "s/ /,/g"` | grep fdb |
awk '{ print $9; }'

/baze/chat.fdb
/baze/chat.fdb
/baze/keops.fdb
/opt/firebird/examples/employee.fdb

I also recommend you pipe that further to sort(1) and get the things
grouped together.

> and how many users
> connected to a particular database.

The above lsof command shows that as well, but it is more efficient and
precise to use fuser(1) command on the database file. Like this:

root@asus:/# fuser /baze/chat.fdb
/baze/chat.fdb: 1780 1799

So, two users (processes 1780 and 1799) are connected.

> Using a gui tool like ibadmin
> returns : unexpected output buffer value. can we use isql for that
> purpose? thanks.

GUI tools don't work as information is not available via ServiesAPI.

P.S. This might all look intimidating, but sed, awk, grep and other
commands are basic Linux/Unix knowlegde and any admin should learn them
in first few weeks of using the *nix system. As Linux systems try to
break into desktop market, distributions add graphical layers that hide
this from people coming from Windows world.

So, if you plan to administer a Linux server, take a look in /bin
directory. You should at least know what each of these commands can do.

--
Milan Babuskov
http://swoes.blogspot.com/
http://www.flamerobin.org