Re: How do I find out which users are connected to a database
Posted in 1997
Sean Wong wrote:
>
> > John Clutterbuck wrote:
> > When trying to do a dbexport of ONE database amongst many on a server =
> I
> > often find it fails as it is locked by another user. I find I cannot
> > identify which of the sqlturbos is to blaim (mainly PC I-NET clients).
>
> I have dealt with similar problem before, but only up to the Informix =
> instance level. We need to back up our live data every night by using =
> 'tbunload' or 'dbexport', luckily we only have one 'critical' database =
> on our production environment. =20
>
> I wrote couple of scripts which will work togather and terminate all =
> sessions which has locked the Informix instance on the environment. As =
> I have mentioned above, I don't need to check who has locked which =
> database. If a user has been hot-listed by my script, he will not be =
> able to login next morning, until his name has been removed out of a =
> file, e.g. ".nologin".
>
> Here's the logic of my scripts:
> 1. check 'tbstat -u', extract all PIDs into an awk array with =
> 'locks>=3D1'
> 2. recursively trace back PPID for all PIDs, until it hits the top
> 3. terminate the session by issuing 'kill -9 PPPPID' (certainly not =
> 'kill -9 sqlturbo')
> 4. chuck the user name to file '.nologin', the unix login process will =
> check the file
>
> If you want, I can e-mail the script to you. At least, with this =
> method, you don't need to kill any other user except those one who has =
> locks on the Informix instance.
>
> It would be quite complicated if you want to work on database level (I =
> would like to know as well), unless all users attach to the database by =
> issuing the same command or application. If this is the case, then we =
> can use:
> ps -ef | grep "mycommand mydb" > a_tmp_file
> and then we can work from there. (this won't pick up the user who locks =
> the db with isql).
>
> Hope this can give your some help, and please correct me if there is =
> anything wrong. TA
>
> SEAN
> -------------------------------------------------------------------------=
> ------------------------------
> \\\\|||// |=09
> (o|o) | 'In nowadays, roosters can even be late
> //|||\\\\ |=09
> -------------------------------------------------------------------------=
> ------------------------------
Could you send it to me also,
thanks,