需求:
获得的Active_MQ的url数字,本次获的数等于今次减去上一次的数目
#!/bin/bash
curl -u root:root 192.168.1.1:1111/admin/xml/queues.jsp > /usr/local/script/activemq_url_after.txt 2> /dev/null
AFTER=`head -4411 /usr/local/script/activemq_url_after.txt | tail -1 | awk -F'"' '{print $2}'`
BEFORE=`cat /usr/local/script/activemq_url_before.txt`
expr $AFTER - $BEFORE
echo $AFTER > /usr/local/script/activemq_url_before.txt
监控游戏用户金币获得
#!/usr/bin/env python
import os,subprocess,sys
for i in range (0,9):
mytask=subprocess.Popen("mysql -uroot -p123456 -h 192.168.1.1 -e 'SELECT * FROM pjb0.UserScoreHistory%s WHERE CURDATE() = `Date` AND ScoreId = 1 AND IncNum > 1000000;'" % i,shell=True,stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
stdstr= mytask.stdout.read()
if 'ERROR' in stdstr:
print 0
sys.exit()
num=os.popen("mysql -uroot -p123456 -h 192.168.1.1 -e 'SELECT * FROM pjb0.UserScoreHistory%s WHERE CURDATE() = `Date` AND ScoreId = 1 AND IncNum > 1000000;' | wc -l" % i)
output = num.read()
n=output.strip('\n')
if n > 0:
print n
sys.exit()
print 0