shell/机器自检脚本.txt

28 lines
1.0 KiB
Plaintext
Raw Permalink Normal View History

2024-05-30 20:46:36 +08:00
#!/usr/bin/bash
#
#by fuxiaoshun 3/25
time=`date +%F-%T`
men_free=`free -h | awk NR==2'{print $4}'`
cpu_load=`uptime | cut -d, -f3-`
disk_user=`df -h | awk NR==6'{print $5}'`
sys_verson=`cat /etc/redhat-release | awk '{print $1,$4}'`
user_total=`cat /etc/passwd | wc -l`
lgoin_failed=`gerp -i failed /var/log/secure | wc -l`
ip_addr=`ifconfig | grep broadcast | awk '{print $2}'`
inode_used=`df -i | awk NR==6'{print $5}'`
mem_free=`free -m | awk NR==2'{print $4}'`
mem_total=`free -m | awk NR==2'{print $2}'`
mem_freept=$((mem_free*100/mem_total))
echo "当前系统时间是:" $time
echo "当前用户是:" $USER
echo "当前用户标识:" $UID
echo "当前系统主机名:" $HOSTNAME
echo "当前系统内存剩余状态:" $men_free
echo "当前磁盘cpu平均负载:" $cpu_load
echo "磁盘的使用量:"$disk_user
echo "操作系统版本:"$sys_verson
echo "系统有多少个用户:"$user_total
echo "系统登录失败用户:"$lgoin_failed个
echo "本机的ip地址:"$ip_addr
echo "剩余内存百分比:"$mem_freept%