阅读背景:

阿里云ECS主机自定义进程监控

来源:互联网 
PYTHON脚本下载地址:https://imgs-storage.cdn.aliyuncs.com/help/jiankong/cms_post.sh?spm=5176.7738831.2.2.bELgkj&file=cms_post.sh
shell脚本下载地址:https://imgs-storage.cdn.aliyuncs.com/help/jiankong/cms_post.sh?spm=5176.7738831.2.2.bELgkj&file=cms_post.sh
#!/bin/bash

#--------------------------------------------

#PATH用来获取运行命令的路径

export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/java/bin

#VAUL用来获取监控存活数值或状态

export VAUL=$(ps -ef |grep mysql |grep -w 'usr\/local/mysql\/bin\/mysqld' |grep -v 'grep'|awk '{print $2}' |wc -l)

# HOSTS用来获取你的主机名

export HOSTS=$(hostname)

#1脚本位置

#2命名空间中的数字串-即是用户的aliuid

#3即是用户创建监控项时填写的名称

#4字段信息结合监控项,表示具体业务字段的实际意义

#这里需要注意,字段的值一定要与脚本中字段的值一致,否则即使监控的值触发了你的报警规则,状态依然是正常的。(我用的字段信息是主机名,因为我的业务和主机名是一样的,hosts后面的是那个业务报警的状态,自己定义的)

# 1 2 3 4

/usr/local/cloudmonitor/script/cms_post.sh 1421981683758115 test_web $VAUL dubbo=$HOSTS-dubbo-stop
chmod 777 /usr/local/cloudmonitor/script/cms_post.sh

chmod 777 /usr/local/cloudmonitor/script/dubbo_chenk.sh
* * * * * /bin/bash /usr/local/cloudmonitor/script/tomcat_dubbo_check.sh >/dev/null 2>&1

分享到: