Skip to content

Instantly share code, notes, and snippets.

@mrbuk
Created June 22, 2016 12:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrbuk/8b8fbff0fcbe7b458036eb0b882e9e36 to your computer and use it in GitHub Desktop.
Save mrbuk/8b8fbff0fcbe7b458036eb0b882e9e36 to your computer and use it in GitHub Desktop.
Check log output for skipped lines
# when checking cf logs invoke with
# awk '{print $4}' log-example.out | egrep '^[0-9]+' | sort -n | python script.py
#
import sys
def checkLineConsistency(previous, current):
if previous[0]+1 != current[0]:
print "Inconsistency between line %d ('%d') and %d ('%d')" % (previous[1], previous[0], current[1], current[0])
f = sys.stdin
counter = 0
previous = None
for line in f:
if not line:
#EOF
break
counter += 1
current = (int(line), counter)
if previous:
checkLineConsistency(previous, current)
# store next as previous for next run
previous = current
print "Total lines: %d" % counter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment