Skip to content

Instantly share code, notes, and snippets.

@ssp
Created January 23, 2012 16:47
Show Gist options
  • Save ssp/1664199 to your computer and use it in GitHub Desktop.
Save ssp/1664199 to your computer and use it in GitHub Desktop.
pazpar2 log analysis
# Try to grep rough usage information from a pazpar2 log:
# Count how often each service has been initialised and
# add a + to the service name if pz:allow is used.
# Both for current and archived logs
cat pazpar2.log | grep "command=init" | sed "s/.*search.pz2?command=init&service=\([-a-zA-Z0-9]*\)/\1/g" | sed "s/.pz:allow.*/+/g" | sort | uniq -c
zcat pazpar2.log.2.gz | grep "command=init" | sed "s/.*search.pz2?command=init&service=\([-a-zA-Z0-9]*\)/\1/g" | sed "s/.pz:allow.*/+/g" | sort | uniq -c
# Turn into a simplistic JSON file for CouchDB import
echo '{"docs":[' > couch.json; cat pazpar2.log | grep "command=\(init\|search\)" | sed "s/\(.*\) pazpar2 .*search.pz2?\(.*\)/{\"date\":\"\1\",\"request\":\"\2\"},/g" >> couch.json; echo ']}' >> couch.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment