Обсуждение: Login/logout
Hello all I want to register in an audit table the date and time of the login/logout of a database user. I have been looking for some function in the code but I didn't find something like that. Can you give me some ideas to implement it?. I'm ready to program if it is necessary. Thanks in advance, regards Juan P. Espino
On Sat, Jun 18, 2005 at 11:11:31AM -0500, Juan Pablo Espino wrote: > > I want to register in an audit table the date and time of the > login/logout of a database user. I have been looking for some function > in the code but I didn't find something like that. Are you interested in logging to a table specifically, or are you just trying to get the login/logout info? If the latter, then you can use log_connections and log_disconnections (the second of which is available in 8.0 and later). http://www.postgresql.org/docs/8.0/static/runtime-config.html#RUNTIME-CONFIG-LOGGING-WHAT -- Michael Fuhr http://www.fuhr.org/~mfuhr/
Thanks for the quick response. Yes I want to retrieve the login/logout info, but I want to insert this info in a table that I use as an audit table. Regards Juan P. Espino On 6/18/05, Michael Fuhr <mike@fuhr.org> wrote: > On Sat, Jun 18, 2005 at 11:11:31AM -0500, Juan Pablo Espino wrote: > > > > I want to register in an audit table the date and time of the > > login/logout of a database user. I have been looking for some function > > in the code but I didn't find something like that. > > Are you interested in logging to a table specifically, or are you > just trying to get the login/logout info? If the latter, then you > can use log_connections and log_disconnections (the second of which > is available in 8.0 and later). > > http://www.postgresql.org/docs/8.0/static/runtime-config.html#RUNTIME-CONFIG-LOGGING-WHAT > > -- > Michael Fuhr > http://www.fuhr.org/~mfuhr/ >
On Sat, 2005-06-18 at 11:46 -0500, Juan Pablo Espino wrote: > Thanks for the quick response. Yes I want to retrieve the > login/logout info, but I want to insert this info in a table that I > use as an audit table. Regards I suggest putting together a short script to scan the logs periodically and add the new entries to your table. > On 6/18/05, Michael Fuhr <mike@fuhr.org> wrote: > > On Sat, Jun 18, 2005 at 11:11:31AM -0500, Juan Pablo Espino wrote: > > > > > > I want to register in an audit table the date and time of the > > > login/logout of a database user. I have been looking for some function > > > in the code but I didn't find something like that. > > > > Are you interested in logging to a table specifically, or are you > > just trying to get the login/logout info? If the latter, then you > > can use log_connections and log_disconnections (the second of which > > is available in 8.0 and later). > > > > http://www.postgresql.org/docs/8.0/static/runtime-config.html#RUNTIME-CONFIG-LOGGING-WHAT > > > > -- > > Michael Fuhr > > http://www.fuhr.org/~mfuhr/ > > > > ---------------------------(end of broadcast)--------------------------- > TIP 9: the planner will ignore your desire to choose an index scan if your > joining column's datatypes do not match > --
Hi, thanks for the response. On 6/18/05, Rod Taylor <pg@rbt.ca> wrote: > On Sat, 2005-06-18 at 11:46 -0500, Juan Pablo Espino wrote: > > Thanks for the quick response. Yes I want to retrieve the > > login/logout info, but I want to insert this info in a table that I > > use as an audit table. Regards > > I suggest putting together a short script to scan the logs periodically > and add the new entries to your table. > It sounds to me good in order to resolve my problem. Nevertheless I think that it would be very useful to have a function that does something like "select login()" and gives back to the date and time of login, or that we can retrieve that info from the system catalogs. Regards, Juan P. Espino
Juan Pablo Espino wrote: > > I want to register in an audit table the date and time of the > login/logout of a database user. I have been looking for some function > in the code but I didn't find something like that. This is the kind of functionality I'd expect to go to the pg_system (or however it is named) database if added in pgsql 9.x or so. Would you like to have auditing stuff mixed up with user data (e.g. in terms of backup)? Regards, Andreas