邮件报警脚本
vi alertscripts/sendmail.sh
#!/bin/bash
messages=echo $3 | tr '\r\n' '\n'
subject=echo $2 | tr '\r\n' '\n'
echo "${messages}" | mail -s "${subject}" $1 >>/tmp/sendmail.log 2>&1
微信报警脚本
vi alertscripts/weixin.py
#!/usr/bin/env python
#coding:utf-8
import socket,sys
if len(sys.argv) == 1:
print "参数错误!"
sys.exit(1)
else:
message = sys.argv[1]
s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
host = '116.62.20.104'
port = 1111
try:
s.connect((host,port))
s.send('0,,,,'+message)
date = s.recv(1024)
print date.decode('utf-8')
except Exception as err:
print err
print "api连接错误"
sys.exit(1)
s.close()
本文转自yzy121403725 51CTO博客,原文链接:http://blog.51cto.com/lookingdream/2052007,如需转载请自行联系原作者