Difference between revisions of "IdleUsers"

From Pickwiki
Jump to navigationJump to search
m
 
m (link fix)
 
Line 1: Line 1:
HomePage>>SourceCode>>PerlSource
+
HomePage>>SourceCode>>[[PerlSource]]
  
 
This script shows a list of terminals that have not sent or received a character in the last xx minutes.  It's useful for enforcing license compliance - put it on a menu somewhere and let your users know it's there.  They suddenly become self-policing :-)
 
This script shows a list of terminals that have not sent or received a character in the last xx minutes.  It's useful for enforcing license compliance - put it on a menu somewhere and let your users know it's there.  They suddenly become self-policing :-)

Latest revision as of 23:48, 26 February 2015

HomePage>>SourceCode>>PerlSource

This script shows a list of terminals that have not sent or received a character in the last xx minutes. It's useful for enforcing license compliance - put it on a menu somewhere and let your users know it's there. They suddenly become self-policing :-)

#!/usr/bin/perl
# 09/13/2000 Ian  Show pty's with no activity in the last 30 minutes

use File::stat;
use Getopt::Std;

getopt("c:");
if ($opt_c) {
   $cutoff = $opt_c;
} else {
   $cutoff = 30;
}

open (LISTUSER, "listuser|") || die "Cannot open listuser command: $!\n";

while (<LISTUSER>) {
   ($x, $x, $x, $user, $x, $pty, $x) = split(" ");
   if ($pty =~ /pts/) {
      $inode = stat("/dev/$pty");
      $mtime = $inode->mtime;
      $idle = int((time() - $mtime) / 60);
      if ($idle > $cutoff) {write;}
   }
}

format =
@<<<<<<<<< logged on to /dev/@<<<<<< has been idle for @#### minutes
$user, $pty, $idle
.