Page MenuHomeDevCentral

An alternative to `who`
Closed, ResolvedPublic

Description

tmux and mosh flood /var/run/utx.active of session records

We need an alternative to the traditional commands w and who display who is online. Then we should replace in csh configuration the watch feature which uses w/who to use our more compact users list.

FreeBSD

$ who
dereckson        pts/8        Sep 29 16:43 (tmux(1384).%601)
dereckson        pts/1        Aug  2 08:19 (tmux(1384).%0)
dereckson        pts/2        Sep 21 09:57 (tmux(1384).%450)
dereckson        pts/30       Oct 10 21:54 (mosh [48117])
kalix            pts/24       Sep 30 07:46 (tmux(80306).%0)
root             pts/5        Sep 21 09:58 (tmux(15735).%0)
dereckson        pts/6        Aug  2 12:42 (tmux(1384).%6)
xcombelle        pts/0        Sep 17 18:12 (tmux(48060).%0)
root             pts/9        Oct  6 15:13 (tmux(15735).%19)
root             pts/11       Sep 25 16:55 (tmux(15735).%5)
dereckson        pts/4        Oct  8 01:03 (mosh [73986])
dereckson        pts/14       Oct  6 17:26 (mosh [72819])
dereckson        pts/17       Oct  9 00:07 (mosh [18898])
root             pts/15       Oct  7 21:42 (tmux(15735).%24)
root             pts/10       Oct  6 15:04 (tmux(15735).%18)
dereckson        pts/7        Sep 29 10:37 (tmux(1384).%590)
dereckson        pts/22       Oct  9 12:06 (mosh [22890])
root             pts/27       Oct  4 17:42 (tmux(15735).%17)
dereckson        pts/31       Oct 12 23:03 (mosh [69400])
dereckson        pts/25       Oct  9 13:02 (mosh [31996])
dereckson        pts/28       Oct  9 22:58 (mosh [32489])
dereckson        pts/33       Oct 13 08:27 (mosh [96392])
root             pts/16       Oct  7 12:47 (tmux(15735).%23)
dereckson        pts/32       Oct 12 11:33 (tmux(1384).%737)
dereckson        pts/34       Oct 12 12:00 (tmux(1384).%740)
dereckson        pts/36       Oct 13 11:36 (mosh [2906])
root             pts/37       Oct 13 16:34 (tmux(15735).%26)
dereckson        pts/40       Oct 13 20:33 (mosh [4254])
dereckson        pts/41       Oct 13 20:35 (... via mosh [8557])
dereckson        pts/42       Oct 13 20:35 (tmux(1384).%756)

$ who | awk '{print $1}' | sort | uniq
dereckson
kalix
root
xcombelle

$ users
dereckson kalix root xcombelle

Fedora

GNU core utils also provide a users command, but without unique warranty.

$ who
dereckson tty1         2015-05-20 15:06
dereckson pts/5        2015-09-30 07:23 (ysul.nasqueron.org)

$ users
dereckson dereckson

Event Timeline

dereckson raised the priority of this task from to Wishlist.
dereckson updated the task description. (Show Details)
dereckson added a project: Servers.
dereckson added a project: good-first-issue.
dereckson moved this task from Backlog to Dev on the good-first-issue board.
dereckson added subscribers: dereckson, Sandlayth, xcombelle.
dereckson raised the priority of this task from Wishlist to High.EditedNov 30 2015, 19:44

This become annoying enough to raise priority.

This task has been identified as suitable for the December product backlog for infrastructure. It's included in our product backlog and will be discussed for inclusion to sprint backlog this E3 meeting.

Alternative command

First, to get a clean, straight, users only output, I've created a whom command:

/usr/local/bin/whom
#!/bin/sh
who | awk '{print $1}' | sort | uniq

Problem we try to solve

csh and tcsh watch for changes in utmp database, the database every session-related software inserts and removes login information. who queries the utmp file, and tcsh  also, directly, through through the watch feature.

So we need to reimplement the watch functionality.

Plan

We bypass the watch functionality.

Instead, we create a script storing somewhere in /tmp the current list of users, and printing the differences.

Then, we ask tcsh to execute this script at each prompt, which is provided by precmd.