Created
June 22, 2016 12:32
-
-
Save mrbuk/8b8fbff0fcbe7b458036eb0b882e9e36 to your computer and use it in GitHub Desktop.
Check log output for skipped lines
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
# 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