Skip to content

Instantly share code, notes, and snippets.

@ramn
Created July 21, 2014 08:15
Show Gist options
  • Select an option

  • Save ramn/540e463def0c5c650c69 to your computer and use it in GitHub Desktop.

Select an option

Save ramn/540e463def0c5c650c69 to your computer and use it in GitHub Desktop.
Calc and plot durations from log file
#!/bin/bash
# Given a logfile with pairwise loglines when an event starts, and when it finishes,
# this script plots the duration for the events.
# Feed me a log file with rows like these:
# 2014-07-21 07:50:03,440 INFO Begin job
# 2014-07-21 07:52:50,530 INFO End job
# 2014-07-21 08:00:03,044 INFO Begin job
# 2014-07-21 08:02:02,548 INFO End job
cut -d ' ' -f 1,2 | grep -Po '^[^,]*' | xargs -ID date -d "D" +"%s" | xargs -n2 | \
while read A; do echo "2k $A r - 60 /p" | dc; done | gnuplot -e "plot '-' with lines" -p
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment