硬盘监控脚本钉钉告警

1 钉钉告警提示

蒲公英硬盘使用率告警

主机ip:x.x.x.x

主机名称:localhost.localdomain

目录路径:/dev/vda1

硬盘使用率:91% 已大于设定的值90%

2 思路准备

 获取本地磁盘目录

df -h

3 编写脚本

vim /root/hard_disk_usage.sh

#!/bin/bash
#chkconfig:2345 80 90
#decription:hard_disk_usage autostart

DIR_LIST=("/dev/vda1" "/dev/vda2" "/dev/vdb1" "/dev/vdb2")
HOST=`curl ip.sb`
HOSTNAME=`echo $(hostname)`
hard_disk_usage=90%
function SendMessageToDingding(){
        url="https://oapi.dingtalk.com/robot/send?access_token=xxxxxxxxxx"
        UA="Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/535.24 (KHTML, like Gecko) Chrome/19.0.1055.1 Safari/535.24"

        res=`curl -XPOST -s -L -H "Content-Type:application/json" -H "charset:utf-8" $url -d

你可能感兴趣的:(脚本,监控)