Last active
October 10, 2015 12:37
-
-
Save mgalardini/3691059 to your computer and use it in GitHub Desktop.
CONTIGuator web tracking
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
class bcolors: | |
HEADER = '\033[95m' | |
OKBLUE = '\033[94m' | |
OKGREEN = '\033[92m' | |
WARNING = '\033[93m' | |
FAIL = '\033[91m' | |
ENDC = '\033[0m' | |
print '%sSingle job stats for CONTIGuator%s'%(bcolors.HEADER,bcolors.ENDC) | |
import redis | |
r = redis.Redis() | |
for reqID in r.zrange('contigjobs', 0, -1): | |
print bcolors.HEADER + reqID + bcolors.ENDC | |
for k,v in r.hgetall(reqID).iteritems(): | |
print '%s%s%s\t%s%s%s'%(bcolors.OKBLUE,k,bcolors.ENDC, bcolors.OKGREEN,v,bcolors.ENDC) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
class bcolors: | |
HEADER = '\033[95m' | |
OKBLUE = '\033[94m' | |
OKGREEN = '\033[92m' | |
WARNING = '\033[93m' | |
FAIL = '\033[91m' | |
ENDC = '\033[0m' | |
import redis | |
r = redis.Redis() | |
print '%sGeneral stats for CONTIGuator%s'%(bcolors.HEADER,bcolors.ENDC) | |
# Total number of jobs | |
total = r.zcard('contigjobs') | |
print '%sTotal jobs%s\t%s%d%s'%(bcolors.OKBLUE,bcolors.ENDC,bcolors.OKGREEN,total,bcolors.ENDC) | |
# Unique users | |
uni = r.scard('contiguator') | |
print '%sUnique users%s\t%s%d%s'%(bcolors.OKBLUE,bcolors.ENDC,bcolors.OKGREEN,uni,bcolors.ENDC) | |
# Unique emails | |
email = set([r.hget(req, 'email') for req in r.zrange('contigjobs', 0, -1)]) | |
print '%sUnique emails%s\t%s%d%s'%(bcolors.OKBLUE,bcolors.ENDC,bcolors.OKGREEN,len(email),bcolors.ENDC) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# More stuff here | |
# Redis tracking | |
try: | |
import redis | |
import time | |
r = redis.Redis() | |
# Unique users pot | |
r.sadd('contiguator', req.get_remote_host()) | |
# Specific job | |
r.zadd('contigjobs', reqID, time.time()) | |
r.hset(reqID, 'ip', req.get_remote_host()) | |
r.hset(reqID, 'cmd', cmd) | |
r.hset(reqID, 'date', time.asctime()) | |
r.hset(reqID, 'email', email) | |
except:pass | |
# More stuff here |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment