You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@guacamole.apache.org by Rafael Cervillera <ra...@ugr.es> on 2022/04/27 10:27:46 UTC

SQL Query for active sessions

Hello all.

Firstable, thanks for the awesome work with Apache Guacamole.

Our environment is CentOS with Guacamole 1.3.0 and RDP connections to 
Windows10 virtual clients. Now we need to query the active RDP sessions 
in order to shutdown inactive devices and start up in the moment we need 
them.

Our idea is get the active sessions with an SQL query from the command 
line and launch the shutdown/start up process. So, we have looked for a 
SQL table with the active connections to make an SQL query unsucessfully.

Is there any way to do that with SQL?  Or do you have another idea to 
get the active sessions?

Thanks in advance


-- 
--------------------------------------------------
  ____        __        Rafael Cervillera Cortés
|  _ \ __ _ / _| __ _  Servicio de Microinformática
| |_) / _` | |_ / _` | C.S.I.R.C.
|  _ < (_| |  _| (_| | Universidad de Granada
|_| \_\__,_|_|  \__,_| rafacc@ugr.es, 958 241448

---------------------------------------------------------------------------
Este mensaje se dirige exclusivamente a su destinatario y puede contener
información privilegiada o confidencial. Si no es vd. el destinatario
indicado, queda notificado de que la utilización, divulgación o copia
sin autorización está prohibida en virtud de la legislación Vigente. Si
ha recibido este mensaje por error, le rogamos que nos lo comunique
inmediatamente por esta misma vía y proceda a su destrucción
---------------------------------------------------------------------------
This message is intended exclusively for its addressee and may contain
information that is CONFIDENTIAL and protected by professional privilege.
If you are not the intended recipient you are hereby notified that any
dissemination, copy or disclosure of this communication is strictly
prohibited by law. If this message has been received in error, please
immediately notify us via e-mail and delete it.
---------------------------------------------------------------------------


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@guacamole.apache.org
For additional commands, e-mail: user-help@guacamole.apache.org


Re: SQL Query for active sessions

Posted by Rafael Cervillera <ra...@ugr.es>.
Thanks for your answer.

We will try your suggesstion.



El 28/04/2022 a las 0:11, Michael Jumper escribió:
> On Wed, Apr 27, 2022 at 3:30 AM Rafael Cervillera <ra...@ugr.es> wrote:
>
>     Hello all.
>
>     Firstable, thanks for the awesome work with Apache Guacamole.
>
>     Our environment is CentOS with Guacamole 1.3.0 and RDP connections to
>     Windows10 virtual clients. Now we need to query the active RDP
>     sessions
>     in order to shutdown inactive devices and start up in the moment
>     we need
>     them.
>
>     Our idea is get the active sessions with an SQL query from the
>     command
>     line and launch the shutdown/start up process. So, we have looked
>     for a
>     SQL table with the active connections to make an SQL query
>     unsucessfully.
>
>     Is there any way to do that with SQL?
>
>
> I wouldn't recommend doing this. Releases from 1.4.0 and older do not 
> record active sessions in the database.
>
> This has changed recently, and active sessions will have an entry in 
> the connection history table, but you should still not rely on this. 
> The existence of an entry within the table doesn't guarantee that 
> there is a corresponding session. It could also be the case that the 
> server or database was forcibly shut down, went offline, etc. before 
> the entry could be updated with the end time.
>
>     Or do you have another idea to get the active sessions?
>
>
> If the intent is to start/shutdown resources required for connections, 
> I'd recommend instead writing an extension that decorates the 
> Connections and ConnectionGroups of other extensions. By doing this, 
> you can override connect() to provide whatever additional behavior you 
> need when the connection starts, and override close() of the returned 
> GuacamoleTunnel to provide whatever additional behavior you need when 
> the connection is disconnected.
>
> See: 
> https://guacamole.apache.org/doc/guacamole-ext/org/apache/guacamole/net/auth/AuthenticationProvider.html#decorate(org.apache.guacamole.net.auth.UserContext,org.apache.guacamole.net.auth.AuthenticatedUser,org.apache.guacamole.net.auth.Credentials)
>
> There are convenience classes for handling this sort of decoration:
>
> https://guacamole.apache.org/doc/guacamole-ext/org/apache/guacamole/net/auth/DelegatingUserContext.html
> https://guacamole.apache.org/doc/guacamole-ext/org/apache/guacamole/net/auth/DecoratingDirectory.html
>
> An overview of the format of extensions can be found here:
>
> https://guacamole.apache.org/doc/gug/guacamole-ext.html
>
> - Mike
>
-- 
--------------------------------------------------
  ____        __        Rafael Cervillera Cortés
|  _ \ __ _ / _| __ _  Servicio de Microinformática
| |_) / _` | |_ / _` | C.S.I.R.C.
|  _ < (_| |  _| (_| | Universidad de Granada
|_| \_\__,_|_|  \__,_|rafacc@ugr.es, 958 241448

---------------------------------------------------------------------------
Este mensaje se dirige exclusivamente a su destinatario y puede contener
información privilegiada o confidencial. Si no es vd. el destinatario
indicado, queda notificado de que la utilización, divulgación o copia
sin autorización está prohibida en virtud de la legislación Vigente. Si
ha recibido este mensaje por error, le rogamos que nos lo comunique
inmediatamente por esta misma vía y proceda a su destrucción
---------------------------------------------------------------------------
This message is intended exclusively for its addressee and may contain
information that is CONFIDENTIAL and protected by professional privilege.
If you are not the intended recipient you are hereby notified that any
dissemination, copy or disclosure of this communication is strictly
prohibited by law. If this message has been received in error, please
immediately notify us via e-mail and delete it.
---------------------------------------------------------------------------

Re: SQL Query for active sessions

Posted by Michael Jumper <mj...@apache.org>.
On Wed, Apr 27, 2022 at 3:30 AM Rafael Cervillera <ra...@ugr.es> wrote:

> Hello all.
>
> Firstable, thanks for the awesome work with Apache Guacamole.
>
> Our environment is CentOS with Guacamole 1.3.0 and RDP connections to
> Windows10 virtual clients. Now we need to query the active RDP sessions
> in order to shutdown inactive devices and start up in the moment we need
> them.
>
> Our idea is get the active sessions with an SQL query from the command
> line and launch the shutdown/start up process. So, we have looked for a
> SQL table with the active connections to make an SQL query unsucessfully.
>
> Is there any way to do that with SQL?


I wouldn't recommend doing this. Releases from 1.4.0 and older do not
record active sessions in the database.

This has changed recently, and active sessions will have an entry in the
connection history table, but you should still not rely on this. The
existence of an entry within the table doesn't guarantee that there is a
corresponding session. It could also be the case that the server or
database was forcibly shut down, went offline, etc. before the entry could
be updated with the end time.

Or do you have another idea to get the active sessions?
>

If the intent is to start/shutdown resources required for connections, I'd
recommend instead writing an extension that decorates the Connections and
ConnectionGroups of other extensions. By doing this, you can override
connect() to provide whatever additional behavior you need when the
connection starts, and override close() of the returned GuacamoleTunnel to
provide whatever additional behavior you need when the connection is
disconnected.

See:
https://guacamole.apache.org/doc/guacamole-ext/org/apache/guacamole/net/auth/AuthenticationProvider.html#decorate(org.apache.guacamole.net.auth.UserContext,org.apache.guacamole.net.auth.AuthenticatedUser,org.apache.guacamole.net.auth.Credentials)

There are convenience classes for handling this sort of decoration:

https://guacamole.apache.org/doc/guacamole-ext/org/apache/guacamole/net/auth/DelegatingUserContext.html
https://guacamole.apache.org/doc/guacamole-ext/org/apache/guacamole/net/auth/DecoratingDirectory.html

An overview of the format of extensions can be found here:

https://guacamole.apache.org/doc/gug/guacamole-ext.html

- Mike