Ask Reuben

Send Message, Close Session

How can I send a message to users to log out of the system? 

How can I close unattended programs before shutting a system down?

A common frustration of an applications system administrator is that they want to perform some system administration that requires all the users to be off the system, but when it comes time to perform the task they can see that there are still user(s) on the system.  The system administrator doesn’t want to inconvenience the user by shutting the system down whilst they are in the middle of something important, but at the same time wants to do their assigned task.

In recent GAS and GBC maintenance releases there has been some functionality added and refined that enables the system administrator to send messages to users before forcing the users off the system.  This is in the form of the options send-message, close-session, close-all-sessions that have been added to and refined within the gasadmin tool.

gasadmin send-message allows you to send a message to all users, users of particular session, or users of particular applications.  This section of the documentation shows the arguments you can use to narrow the range of users that receive a message.  It is important to note that the user does not receive the message straight away, they receive it on their next user interaction.  If the user is not doing anything, they will receive it the next time there is ping activity to keep the session alive, this time interval is determined by the USER_AGENT setting.  By default the message is received in the form of a purple tile in the top center of the Genero Application window (see screenshot below).  This can be customised with GBC theme variables, see the entries beginning $gbc-messageWidget-gasadmin



Having warned the user, hopefully more than once, the system administrator can then use the gasadmin close-session or gasadmin close-all-sessions command to gracefully close the Genero applications.  By gracefully close, this means the OPTIONS ON CLOSE APPLICATION functionality can be used to rollback transaction, write to errorlog etc.  I spoke a little about the OPTIONS ON CLOSE APPLICATION in an earlier Ask-reuben.

The gasadmin close-session has similar arguments to the gasadmin send-message so you can use target users of a particular application (the -a / –app argument) or particular sessions (-s / –session argument)  by using the same arguments with both gasadmin send-message and gasadmin close-session.  The close-session option also has arguments (-m / –message) to send a final message when the session is closed or to redirect the user to a particular url (-u / –end-url).

The -a / — app argument is used to target users of a particular application as controlled by the URL that was used to start the application.  For example, if you were targeting users of the gwc-demo that is started with hostname/ua/r/gwc-demo then you would use gasadmin send-message -a gwc-demo message.

The -s / –session argument is used to target individual sessions.  The gasadmin tool can be used to retrieve a list of sessions (gasadmin session –list-sessions), provide details about a session (gasadmin session –monitor session-id) including the idle time (gasadmin session –idle-time session-id).  You might use these to clean up individual sessions where you believe the user has left a program running at the end of the day rather than logging out.


To get users off a system for regular maintenance, a sequence of tasks might be …

6pm

gasadmin send-message "Please logoff by 7pm for system maintenance"

6:45pm

gasadmin send-message "Please logoff by 7pm for system maintenance"

7pm

gasadmin close-all-sessions --end-url "..."

To purge inactive sessions a sequence of tasks might be …

gasadmin session --list-sessions

for each session id

gasadmin session --monitor session-id

gasadmin session --idle-time session-id

if value returned greater than a certain value

gasadmin close-session -s session-id --end-url "..."

If you are still using GDC Direct Connection, this functionality is one of the reasons you might consider shifting from Direct Connection to connecting via a Genero Application Server.

For users in a load balancing situation and you want to reduce the number of servers, these commands are what you could use to gracefully move some users off a resource before you shut it down.

I would suggest having your application system administrator review the gasadmin documentation and noting the options that are available for them.