I found this script on IBM's website and it seems to be really good only thing it gives off more info than i need. I was wondering if someone could help me modify it to only find a group instead of every user. (group is support)
I believe i know how to add the line so it will email me the details, but just in case i am wrong if someone could help me with that as well I'd really appreciate it.
Here is the script:
#!/usr/bin/perl
use strict;
use POSIX qw(ceil);
use User::pwent;
use Term::ANSIColor;
my ($user,%userids);
while ($user = getpwent()){
my $u = $user->name;
if ( `lsuser -a account_locked $u` =~ /.*account_locked=true.*/) {next;}
chomp(my $lastupdate = `lssec -f /etc/security/passwd -a lastupdate -s $u | awk -F= '{print \$2}'`);
if (! $lastupdate) { next; }
chomp(my $maxage = `lsuser -a maxage $u | awk -F= '{print \$2}'` * 7);
my $expires = $lastupdate + (60 * 60 * 24 * $maxage);
my $expire_date = scalar(localtime($expires));
my $change_date = scalar(localtime($lastupdate));
my $now = time();
my $daysremaining = ceil((($expires - $now) / (60*60*24)) - 1);
push(@{$userids{$u}}, $daysremaining,$maxage,$change_date,$expire_date);
}
print "User DaysLeft Expires LastChanged DaysValid\n";
foreach $user (sort {$userids{$a}[0] <=> $userids{$b}[0] } keys %userids){
if (@{$userids{$user}}[0] <= 0) {
print color("red");
}elsif(@{$userids{$user}}[0] <= 14){
print color("yellow");
}else{
print color ("green");
}
printf "%-12s %-9d %-26s", $user, @{$userids{$user}}[0], @{$userids{$user}}[3];
printf "%-25s %-9d\n", @{$userids{$user}}[2], @{$userids{$user}}[1];
print color ("reset");
}