标签:邮件报警 ++ ace password 工作 yum work pac pts
显示统计占用系统内存最多的进程,并排序。[root@localhost ~]# ps -eo uid,pid,ppid,tty,time,cmd,%mem --sort=-%mem|head
UID PID PPID TT TIME CMD %MEM
107 3007 1 ? 00:03:57 /usr/libexec/qemu-kvm -name 29.2
0 3120 1 ? 00:00:05 /usr/bin/python2 /usr/share 1.6
0 983 1 ? 00:00:01 /usr/sbin/libvirtd 0.8
0 980 1 ? 00:00:00 /usr/bin/python -Es /usr/sb 0.4
999 716 1 ? 00:00:00 /usr/lib/polkit-1/polkitd - 0.3
0 744 1 ? 00:00:00 /usr/sbin/NetworkManager -- 0.2
0 1448 976 ? 00:00:06 sshd: root@pts/1 0.1
0 727 1 ? 00:00:00 /usr/bin/VGAuthService -s 0.1
0 728 1 ? 00:00:04 /usr/bin/vmtoolsd 0.1
#!/bin/bash
#ping server
Prefix=$(echo {1..255})
Server_ip="192.168.0."
for i in $Prefix;do
ping -c1 ${Server_ip}.$i &>/dev/null
if [ $? -ne 0 ];then
echo "${Server_ip}.$i ping fail"
else
echo "${Server_ip}.$1 ping success"
fi
done
#!/bin/bash
Server_ip="192.168.0."
y=1
while [ $y -le 255 ];do
ping -c1 ${Server_ip}.$y &>/dev/null
if [ $? -ne 0 ];then
echo "${Server_ip}.$y ping fail"
else
echo "${Server_ip}.$y ping success"
fi
let y++
done
[root@localhost ~]# crontab -l
30 1 * * 1-5 /usr/bin/tar -Jcf etcbak-`date -d "-1 day" +%Y-%m-%d-%H`.tar.xz /etc &> /dev/null
yum install mailx -y
vim /etc/mail.rc
set from=********@163.com smtp=smtp.163.com
set smtp-auth-user=********@163.com smtp-auth-password=***** smtp-auth=login
systemctl restart mailx
2 编写检测脚本
Disk_apace=$(df -h |sed -nr ‘s,^/dev/sd.*[ ]+(.*)%.*,\1,p‘ |sort -nr |head -1)
if [ $Disk_apace -gt 80 ];then
mail -s "磁盘利用率高于80%" orange1035@163.com
fi
3 写入计划任务
[root@localhost ~]# crontab -e
10 * * * * /usr/bin/bash /server/scripts/check_dask.sh &>/dev/nul
标签:邮件报警 ++ ace password 工作 yum work pac pts
原文地址:https://blog.51cto.com/12514160/2516006