轻量级监控平台之服务监控

轻量级监控平台之服务监控脚本

#!/bin/bash
#进程监控脚本
#功能需求: 上报机器内所有服务名称,集群名称

. /etc/profile
. ~/.bash_profile

pushurl="https://lightmonitorapi.test.cn/push/service"

cd /opt/service/deploy/
msg=""
for s  in $(ls)
do
   msg=$msg"$s-0\n"
done
cd /opt/web/
for s in $(ls)
do
  msg=$msg"$s-1\n"
done

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

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

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

posted @ 2019-11-22 10:05  程序男  阅读(218)  评论(0编辑  收藏  举报