t_onlineplot

From nat, 4 Years ago, written in Bash, viewed 311 times.
URL https://code.nat.moe/view/9590d372 Embed
Download Paste or View Raw
  1. #!/bin/bash
  2.  
  3. filter_log () {
  4.     next=0
  5.     while read line; do {
  6.         date="$(cut -d',' -f1 <<< "$line")"
  7.         [ $date -gt $next ] && {
  8.             echo "$date"
  9.             read m s <<< $(date -d @$date)
  10.             next=$(( $date + 3600 - 10#$min*60 - 10#$sec ))
  11.         }
  12.     }; done
  13. }
  14.  
  15. plot () {
  16.     i_="\033[7m"
  17.     n_="\033[0m"
  18.     echo -n '           '
  19.     for i in {0..23}; do [ $(($i%2)) -eq 0 ] && printf "%-4d" "$i"; done; echo
  20.     while read line; do {
  21.         date="$(cut -d',' -f1 <<< "$line")"
  22.         day="$(date -d @$date +%Y-%m-%d)"
  23.         [[ "$day_last" != "$day" ]] && {
  24.             [ ! -z "$day_last" ] && echo
  25.             day_last=$day
  26.             echo -n "$day "
  27.             [ -z "$day_last" ] && day_last=$day
  28.             ptr=0
  29.         }
  30.         hr="$(date -d @$date +%-H)"
  31.         let diff=$hr-$ptr
  32.         for ((i=0; i<$diff; i++)); do echo -n '  '; done
  33.         let ptr=$hr+1
  34.         echo -ne "$i_  $n_"
  35.     }; done
  36.     echo
  37. }
  38.  
  39. filter_log | plot

Replies to t_onlineplot rss

Title Name Language When
Re: t_onlineplot (BUGFIX) nat bash 4 Years ago.

Reply to "t_onlineplot"

Here you can reply to the paste above

captcha