shell脚本运维发送微信消息 | 您所在的位置:网站首页 › Linux发送信息到微信 › shell脚本运维发送微信消息 |
#!/bin/bash # 监控ElasticSearch服务器运行状态,若服务器停止运行则发送微信消息通知 # 脚本及配置文件config.json运行位置 根据实际目录修改 cd /root/Desktop # 系统信息 Date=`date +%Y-%m-%d` Date_time=`date "+%Y-%m-%d %H:%M:%S"` Host_name=`hostname` IP_addr=`ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|tr -d "addr:"` # 微信token获取接口参数 Grant_type="client_credential" # 微信平台申请的APPID Appid="*******************************" # 微信平台申请的APP密码 Secret="****************************************" # 微信平台发送消息token获取的地址,需要在微信平台上设置ip白名单才能获取 GURL="https://api.weixin.qq.com/cgi-bin/token?grant_type=$Grant_type&appid=$Appid&secret=$Secret" # 获取微信token # 获取微信访问token # 返回的token结果json数据为 # { # "access_token": "40_MYUor |
CopyRight 2018-2019 实验室设备网 版权所有 |