1 钉钉提示信息
业务内存告警
主机ip:xxxx
主机名称:xxx
服务名称:crontab_search
进程pid:20510
占用内存:525 MB大于500 MB
服务已运行时间:4-00:27:41
服务开始时间:2020-05-11-15:19
2 思路准备
获取本地所有业务服务名称
获取进程pid
#service_pid=`pgrep -f $i` #模糊匹配
service_pid=`ps -ef | grep -w $i | egrep -v grep | awk '{print $2}'` #精确匹配
时间格式转换准备
3 编写脚本
vim mem_check.sh
#!/bin/bash
#chkconfig:2345 80 90
#decription:mem_check autostart
SERVICE_NAME=("crontab_crawler_basketball" "crontab_crawler_basketball_index" "crontab_crawler_football" "crontab_crawler_football_animation" "crontab_crawler_football_betfair" "crontab_crawler_football_index" "crontab_crawler_football_live" "crontab_crawler_history" "crontab_proxypool")
HOS