centos7.2 登录时自动报告系统状态

为centos 7.2 用于其他系统需要更改位置变量

[root@didichuxing detection_script]# cat loginuser.sh
#!/bin/bash

cat << EOF > /etc/motd

             Welcome

EOF
if [ -e /detection_script ]
then
mkdir -p /detection_script/
else
mkdir -p /detection_script/
fi
LoginUser=uptime |awk '{print $(NF-6)}'
w=w | awk 'NR&gt;2{print "登录时间:" $4 "\t" "登录用户:"$1}'
i=whoami
nczs=free -m |grep "Mem" | awk '{print $2}'
cpuzs=grep "model name" /proc/cpuinfo | cut -f2 -d:
wlzs=grep 'physical id' /proc/cpuinfo | sort -u | wc -l
hxsl=grep 'core id' /proc/cpuinfo | sort -u | wc -l
xtbb=more /etc/redhat-release
nhbb=uname -r
xtkj=getconf LONG_BIT
Ip=ip a | grep inet | grep -v inet6 | grep -v 127 | sed 's/^[ \t]*//g' | cut -d ' ' -f2
if [ $LoginUser -ge 1 ]
then
echo "==========================================="
echo "系统登录人数为: $LoginUser人"
echo "$w"
echo "==========================================="
echo "系统内存总数为: $nczs M"
echo "==========================================="
echo "物理CPU个数: $wlzs个,核心CPU个数: $hxsl个"
echo "$cpuzs"
echo "==========================================="
echo "系统版本: $xtbb"
echo "内核版本: $nhbb"
echo "系统架构: x$xtkj位"
echo "物理地址: $Ip"
echo "==========================================="
echo "您是管理员$i用户,拥有最大权限,请谨慎操作!"
echo ""

fi
/bin/mv loginuser.sh /detection_script/

chmod a+x loginuser.sh

vim .bash_profile
在最后一行添加
/detection_script/loginuser.sh

转载于:https://blog.51cto.com/amunlinux/2104368

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值