File: //var/opt/OV/bin/instrumentation/SIUserLastLogin.pl
###############################
#
# Version : 11.11.025
#
###############################
use OvCommon;
my $catalog = OvCommon::GetCatalog(qw/SystemPerl/);
$ENV{CODAMAGIC} = qw/0x05201993/;
open (OVCODADUMP, "ovcodautil -ds SISPI -o LOGINS -flat|") or die;
my %userlogins;
foreach $line (<OVCODADUMP>) {
chomp $line;
($name,$value) = split /:/, $line;
if ($name =~ /^_InstanceName/) {
$user = trim($value);
}
next unless$name =~ /^SECONDS_SINCE_LASTLOGIN/;
$userlogins{$user} = trim($value);
}
print "------------------------------------------------------------------------\n";
print "><User Last Login";
print "------------------------------------------------------------------------\n";
foreach $key (sort hashValueDescendingNum (keys(%userlogins))) {
$sec = $userlogins{$key};
if ($sec != -1) {
$idletime = int($sec/(24*60*60)) . "days, " . ($sec/(60*60))%24 . "hours, " . ($sec/60)%60 . "mins, " . $sec%60 . "secs\n";
printf "%-40s %s\n",$key, $idletime;
}
elsif ($sec == -1) {
$idletime = "never\n";
printf "%-40s %s\n",$key, $idletime;
}
}
close (LASTLOGINS);
sub trim($)
{
my $string = shift;
$string =~ s/^\s+//;
$string =~ s/\s+$//;
return $string;
}
sub hashValueDescendingNum {
$userlogins{$b} <=> $userlogins{$a};
}