最新编辑,feixin那个完蛋了加了验证码不能登录啦feixin改版啦!
之前想用http post发飞信的,今天试了下发现这里根本发了以后提示已经再队列以后就没下文了
上面两个连接都试了完全不行...手机收不到
找到下面这个模拟飞信登陆的的方式给已经绑定手机飞信账号发短信。
代码也简单几十行,拿来稍微改了下直接可以用。
比研究飞信协议简单多啦-v-
上面那个是应该是从这个python脚本改成的shell版本
写这脚本是因为web的连接池跑几天后会出现取不出连接的故障,代码上还没找到问题,只能暂时在出现连接池无法取出连接的时候重启jboss解决
叫程序员写了个简单的jsp去连接池取连接,成功返回0失败返回1
下面就是我的轮询脚本,成功的时候写日志记录oracle连接池的打开数量,超过min连接数(就是LinkPollLong这个变量)的时候把所有连接打印出来(因为之前有出现过某个功能不走连接池自己开连接导致大量time_wait的问题)
注意,在crontab里会少很多环境变量,所以要启动jboss得在python里加上环境变量
附注:N个礼拜后终于找到错误的位置了,原来没走连接池的时候用的jdbc,释放连接池连接的方法都是关jdbc的。
后来换成连接池了还是在用jdbc的方法在关所以所有调用这个方法来关闭的连接都没关。
- #! /usr/bin/python
-
import urllib,urllib2,cookielib
-
import os,sys,time
-
import re
-
-
def fetion(msg):
-
url_login = ''
-
url_logout = ''
-
url_msg = ''
-
user = 'phone num'
-
password = 'pass'
-
loginstatus = '4'
-
arg_t = ''
-
cj = cookielib.LWPCookieJar()
-
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
-
urllib2.install_opener(opener)
-
args = {'pass':password, 'm':user,'loginstatus':loginstatus}
-
print 'Logining...'
-
req = urllib2.Request(url_login, urllib.urlencode(args))
-
jump = opener.open(req)
-
page = jump.read();
-
url = re.compile(r').findall(page)[0]
-
arg_t = re.compile(r't=(\d*)').findall(page)[0]
-
if url == '/im/login/login.action':
-
print "error"
-
return
-
sendmsg = urllib2.Request(url_msg, urllib.urlencode({'msg':msg}))
-
finish = urllib2.urlopen(sendmsg)
-
-
if finish.geturl == '' :
-
print 'Send Failed!'
-
else:
-
print 'Send Successfully'
-
logout = urllib2.Request(url_logout + arg_t)
-
response = urllib2.urlopen(logout)
-
# print 'Logout Successfully!'
-
#print response.read().decode('utf-8').encode('gbk')
-
-
-
def tryOraclePoll():
-
req = urllib2.Request('') #php or aspx
-
try:
-
response = urllib2.urlopen(req)
-
Status = response.read()
-
response.close()
-
return int(Status)
-
except:
-
return 2
-
-
-
-
def LogOra(logType=1,LinkPollLong=1):
-
command = '/bin/netstat -nat'
-
now = time.strftime('%Y-%m-%d %H:%M',time.localtime())
-
oraMark = re.compile(':1521 ')
-
f = open('/var/log/netlink.log','a')
-
if logType == 0:
-
output = os.popen(command)
-
netList = [ line for line in output.readlines() if oraMark.search(line)]
-
logdata = "==================Number of connections is [%d]\tat %s======================\n" % (len(netList),now)
-
if len(netList) > LinkPollLong:
-
f.write(logdata)
-
f.writelines(netList)
-
elif logType == 1:
-
f.write("+++++++++++++++++++++++++jboss restart\tat [%s]+++++++++++++++++++++++++++++\n" % now)
-
else:
-
f.write("-------------------------serve is down\tat [%s]------------------------------\n" % now)
-
f.write('\n\n')
-
f.close()
-
-
-
def restartJboss():
-
os.putenv('JAVA_HOME','/opt/jdk1.6.0_07')
-
os.putenv('JBOSS_HOME','/opt/jboss-4.2.3.GA')
-
os.putenv('JRE_HOME','/opt/jdk1.6.0_07/jre')
-
os.putenv('PATH','/opt/jdk1.6.0_07/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/opt/jdk1.6.0_07/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin')
-
os.putenv('CLASSPATH','.:/opt/jdk1.6.0_07/lib:/opt/jdk1.6.0_07/jre/lib')
-
# os.system('/bin/env')
-
os.system('/opt/jboss-4.2.3.GA/bin/shutdown.sh -S')
-
time.sleep(25)
- # os.system('killall -9 java')
-
os.system('(/opt/jboss-4.2.3.GA/bin/run.sh &)')
-
time.sleep(25)
-
Status = tryOraclePoll()
-
if Status != 0:
-
fetion("up up!!!server down!")
-
return 2
-
return 1
-
-
if __name__ == "__main__":
-
Status = tryOraclePoll()
-
if Status != 0:
-
Status = restartJboss()
-
LogOra(Status,100)
阅读(1684) | 评论(0) | 转发(0) |