Skip to content

Commit

Permalink
ssh_user_monitor
Browse files Browse the repository at this point in the history
  • Loading branch information
aqzt committed Jun 3, 2016
1 parent 4519ebf commit 145fdda
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions monitor/ssh_user_monitor.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@


##监控SSH的一个脚本
is_root=`w | awk -F'[ ]' '{print $7}'`
#if [ $is_root >= 0 ]
# then
# echo $is_root
#is_root1=`w | awk -F'[ ]' '{print $8}'`
#echo >> 111.log
#is_root1=`cat 111.log`
is_root2=`w | awk -F'[ ]' '{print $9}'`
echo $is_root2 > /tmp/user2.log
#root1=`cat 111.log | awk -F'[ ]' '{print $1}'`
#root2=`cat 222.log | awk -F'[ ]' '{print $1}'`
is_root3=`w | awk -F'[ ]' '{print $1}'`
echo $is_root2 > /tmp/user5.log
echo $is_root3 >> /tmp/user5.log
echo $is_root3 > /tmp/user3.log
diff /tmp/user1.log /tmp/user3.log
if [ $? -eq 0 ]
then
echo 222
else
echo 333
#root2=`cat 222.log | awk -F'[ ]' '{print $2}'`
/bin/mail -s "$is_root test_haha" [email protected] < /tmp/user5.log
echo $is_root3 > /tmp/user1.log
exit 1
fi
#fi


#is_root=`w | awk -F'[ ]' '{print $7}'`
#if [ $is_root > 0 ]
# then
# echo $is_root
# exit 1
#fi


0 comments on commit 145fdda

Please sign in to comment.