监控服务器状态发送给 Incoming Webhooks

#!/bin/bash  

STATE=`top -b -n 1 | grep 'B Mem'`
URL='https://hook.bearychat.com/=bwGFg/incoming/xxxxxxxxxx'
TIME=$(date "+%Y-%m-%d %H:%M:%S")
curl ${URL} -H 'Content-Type: application/json' -d '{"text": "腾讯云服务器状态","attachments": [{"title": "内存 '"${TIME}"'","text":"'"${STATE}"'","color": "#ffa500"}]}'

清理 buff/cache

sync && echo 1 > /proc/sys/vm/drop_caches
sync && echo 2 > /proc/sys/vm/drop_caches
sync && echo 3 > /proc/sys/vm/drop_caches

开机执行 shell 脚本

vim /etc/rc.d/rc.local
# 添加
sh /root/sh/auto.sh

在 centos 7 中,/etc/rc.d/rc.local 文件的权限被降低了,开机的时候执行在自己的脚本是不能起动一些服务的,执行下面的命令可以文件标记为可执行的文件

chmod +x /etc/rc.d/rc.local 

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注