轻量级监控平台之磁盘监控

轻量级监控平台之磁盘监控脚本

#!/bin/bash
#进程监控脚本
#功能需求: 上报当前服务的磁盘数据
. /etc/profile
. ~/.bash_profile

cd ~
pushurl="https://lightmonitorapi.test.cn/push/disk"

disk_total=$(df -hl| tail -n3 | awk '{print $2}' |  sed 's/G//g' | awk '{sum  = $1};END {print sum}')
#echo "总磁盘大小=$disk_total G"
diskuse=$(df -hl| tail -n3 | awk '{print $5}' |  sed 's/%//g' | awk '{sum  = $1};END {print sum}')
#echo "磁盘使用率=$diskuse%"


cd /opt
optuse=$(du -sh | awk '{print $1}')
cd /opt/web
optwebuse=$( du -sh | awk '{print $1}')
cd /opt/dsf
dsfuse=$( du -sh | awk '{print $1}')

optuseage=$(df -hl | grep '/opt' | awk '{print $5}')

ip=$(ip addr | grep 'BROADCAST' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d '/')

msg=$disk_total"G-"$diskuse"%-"$optuse"-"$optwebuse"-"$dsfuse"-"$optuseage

ticket=$(cat /opt/shell/ticket.txt)

curl $pushurl \
   -H "Accept: application/json" \
   -H 'Content-Type: application/json' \
   -d \ '{"ip": "'"${ip}"'", "ticket": "'"${ticket}"'", "data": "'"${msg}"'"}'

架构设计@工程设计@服务稳定性之路

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值