Skip to content

Instantly share code, notes, and snippets.

@phatduckk
phatduckk / tail_profile.py
Created August 3, 2011 02:24 — forked from bwmcadams/tail_profile.py
Tail the Slow Query Log on MongoDB
#!/usr/bin/python
# Connects to localhost, 27017 by default
import sys
import pymongo
import time
if len(sys.argv) < 2:
print >> sys.stderr, "Usage: ./tail_profile.py <dbName> [hostname] [port]"
sys.exit(-1)
function parse_git_branch {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
GREEN="\[\033[1;32m\]"
YELLOW="\[\033[1;33m\]"
WHITE="\[\033[0;0m\]"
PS1="[\u@\h [$GREEN\W$YELLOW\$(parse_git_branch)$WHITE]\$ "
// Pageview/click analytics in Cassandra?
pageAnalytics = {
"come.foo/index.html" : { // super column family
"pageviews": { // Super Column family
"someuuid" : {"cookie": "OH HAI", "url": "come.foo/index.html", "layout": 47, "ip": "1.2.3.4"},
"someuuid2" : {"cookie": "OH HAI", "url": "come.foo/index.html", "layout": 47, "ip": "1.2.3.4"},
},
"clicks": { // Super Column family
"someuuid" : {"cookie": "OH HAI", "target": "http://interiorcrocodilealligator.com/", "layout": 47, "ip": "1.2.3.4", "x" : 120, "y": 375},