Computronics    
     
Home Page Image
     

How Does Logmon Work?

Logmon runs as a background daemon, and once a minute it wakes up and checks the cpu utilization of all users on the system. We actually want to look at actual user processes (not other system processes), so we use the data in /etc/utmp (the same information that the who command displays). For each user listed in "who", we look up their process id, and then trace the child processes being run by that parent. Now, if we see no cpu activity on any of these processes, the user is considered idle. (The actual trace of the process id's looks for users in the same process group as the parent process.)

You can also tune it so that a user running a process that always takes "a little" bit of cpu is still considered idle. This is handy for programs that update a clock on the screen, for example. Within Logmon, there is a menu called "rules". Within the rules menu, you specify the name of a program, and a relative cpu usage level. If the cpu usage remains below this level, then the user of this named program is considered idle.

Once you are idle for the specified time period, a warning message can be sent, and if you remain inactive you will be logged off. Note that you can tune the inactivity time by user id, time of day, port in use, etc. It is also possible to combine these attributes and to further fine tune the operation of Logmon by customizing a "code_script", if this is desired.

By default, a user process is killed by running a script that does a kill with a -1 signal (SIGHUP). We will first execute the "kill -1" for each child process that you have started. Then, if these processes remain, we will execute a "kill -9" (SIGKILL) for the child processes. Finally, we will kill the main process, the one that is attached to the terminal/PC, using a "kill -1" signal (again, the same hang-up signal as if you just turned your PC off).

This is only the default and is changeable by modifying the script. A second script is provided that only executes the kill on the main process; this can be used if you do not wish to kill each child process individually. You can even have different scripts and different actions based on the program that is being run. This script can use other kill signals or it can run a program that some databases provide to gracefully terminate a user's access to the database. This is handy when used with programs like Universe or Unidata, using the "master.off" command.

One last note: because we monitor cpu time and not keyboard activity, you will not be logged off if you are running a long job with no keyboard interaction. This is not true of other approaches for controlling idle user processes.

We hope this answers your questions about how Logmon operates, but don't hesitate to ask additional questions!