#!/usr/bin/bash
#########################################
######### Chittibabu Generated SCRIPT########
######### PASSWD AGING CHECK##############
##VERSION=1.0############################
##DESIGN&IMPLEMENTED:CHITTIBABU MIRIYALA#
##TESED BY :MAHESH KUMAR#################
#########################################
Node=`uname -n`
echo "From:chittibabu.miriyala@gmail.com" >"/tmp/output1"
echo "To:chittibabu.miriyala@gmail.com">>"/tmp/output1"
#Reply-To:chittibabu.miriyala@gmail.com
echo "Subject:PASSWD AGING : $Node">>"/tmp/output1"
echo "Content-type: text/html">>"/tmp/output1"
echo "<html>">>"/tmp/output1"
echo "<body>">>"/tmp/output1"
echo "<table width=100%>">>"/tmp/output1"
echo "<tr BGCOLOR="#FFFF00"><td colspan="6"> <h1> $Node</h1> </td></tr>">>"/tmp/output1"
NDAYS=`/usr/bin/perl -e 'printf("%d\n", time / (3600 * 24))'`
for i in `cat /etc/passwd|cut -d ":" -f 1|egrep -v "uucp|daemon|bin|sys|adm|lp|dladm|netadm|netcfg|smmsp|gdm|zfssnap|upnp|xvm|mysql|openldap|webservd|postgres|svctag|unknown|nobody|noaccess|nobody4|ftp|dhcpserv|aiuser|pkg5srv"`
do
#echo " user name : $i"
if [ `passwd -s $i |awk '{print $2}'` == "PS" ]
then
LAST_CHANGE=`cat /etc/shadow|grep $i|cut -d ":" -f 3`
DELTA=`echo $NDAYS - $LAST_CHANGE|bc`
MAX=`logins -x -l $i|grep PS|awk '{print $4}'`
con=`echo " $MAX - $DELTA"|bc`
if [ $MAX = -1 ]
then
echo "<TR BGCOLOR="#00FF00">">>"/tmp/output1"
echo "<td>$i USER PASSWD STATUS</td><td>NO PASSWD EXPIRY</td>">>"/tmp/output1"
continue
fi
if [ $DELTA -le $MAX ] && [ $con -le 3 ]
then
echo "<TR BGCOLOR="#FF0000">">>"/tmp/output1"
echo "<td>$i USER PASSWD STATUS</td><td> PASSWD WILL EXPIRE IN $con DAYS</td>">>"/tmp/output1"
else
echo "<TR BGCOLOR="#00FF00">">>"/tmp/output1"
echo "<td>$i USER PASSWD STATUS</td><td> PASSWD WILL EXPIRE IN $con DAYS</td>">>"/tmp/output1"
fi
else
echo "<TR BGCOLOR="#FF0000">">>"/tmp/output1"
echo "<td>$i USER PASSWD STATUS</td><td>BAD</td>">>"/tmp/output1"
fi
done
echo "</table>">>"/tmp/output1"
echo "</body>">>"/tmp/output1"
echo "</html>">>"/tmp/output1"
cat "/tmp/output1"|mail chittibabu.miriyala@gmail.com
#########################################
######### Chittibabu Generated SCRIPT########
######### PASSWD AGING CHECK##############
##VERSION=1.0############################
##DESIGN&IMPLEMENTED:CHITTIBABU MIRIYALA#
##TESED BY :MAHESH KUMAR#################
#########################################
Node=`uname -n`
echo "From:chittibabu.miriyala@gmail.com" >"/tmp/output1"
echo "To:chittibabu.miriyala@gmail.com">>"/tmp/output1"
#Reply-To:chittibabu.miriyala@gmail.com
echo "Subject:PASSWD AGING : $Node">>"/tmp/output1"
echo "Content-type: text/html">>"/tmp/output1"
echo "<html>">>"/tmp/output1"
echo "<body>">>"/tmp/output1"
echo "<table width=100%>">>"/tmp/output1"
echo "<tr BGCOLOR="#FFFF00"><td colspan="6"> <h1> $Node</h1> </td></tr>">>"/tmp/output1"
NDAYS=`/usr/bin/perl -e 'printf("%d\n", time / (3600 * 24))'`
for i in `cat /etc/passwd|cut -d ":" -f 1|egrep -v "uucp|daemon|bin|sys|adm|lp|dladm|netadm|netcfg|smmsp|gdm|zfssnap|upnp|xvm|mysql|openldap|webservd|postgres|svctag|unknown|nobody|noaccess|nobody4|ftp|dhcpserv|aiuser|pkg5srv"`
do
#echo " user name : $i"
if [ `passwd -s $i |awk '{print $2}'` == "PS" ]
then
LAST_CHANGE=`cat /etc/shadow|grep $i|cut -d ":" -f 3`
DELTA=`echo $NDAYS - $LAST_CHANGE|bc`
MAX=`logins -x -l $i|grep PS|awk '{print $4}'`
con=`echo " $MAX - $DELTA"|bc`
if [ $MAX = -1 ]
then
echo "<TR BGCOLOR="#00FF00">">>"/tmp/output1"
echo "<td>$i USER PASSWD STATUS</td><td>NO PASSWD EXPIRY</td>">>"/tmp/output1"
continue
fi
if [ $DELTA -le $MAX ] && [ $con -le 3 ]
then
echo "<TR BGCOLOR="#FF0000">">>"/tmp/output1"
echo "<td>$i USER PASSWD STATUS</td><td> PASSWD WILL EXPIRE IN $con DAYS</td>">>"/tmp/output1"
else
echo "<TR BGCOLOR="#00FF00">">>"/tmp/output1"
echo "<td>$i USER PASSWD STATUS</td><td> PASSWD WILL EXPIRE IN $con DAYS</td>">>"/tmp/output1"
fi
else
echo "<TR BGCOLOR="#FF0000">">>"/tmp/output1"
echo "<td>$i USER PASSWD STATUS</td><td>BAD</td>">>"/tmp/output1"
fi
done
echo "</table>">>"/tmp/output1"
echo "</body>">>"/tmp/output1"
echo "</html>">>"/tmp/output1"
cat "/tmp/output1"|mail chittibabu.miriyala@gmail.com
No comments:
Post a Comment