Score:1

Running tshark and find in parallel + strict time-sorted output

tm flag

I'm trying to obtain debug output of

  1. what "find" does
  2. compared to what happens on the network (tshark)

Therefore I want to run these commands in parallel and have output meticulously sorted by time.

I do this:

{
stdbuf -oL tshark -tad -l -n -s 9999 host x | ts '[TSRK %Y-%m-%d %H:%M:%.S]' &
sleep 5
stdbuf -oL find . -type d 2>&1 | ts '[FIND %Y-%m-%d %H:%M:%.S]' &
} >/root/out

Major problem: Tshark output is lagging

# stdbuf -oL tshark -tad -l -n | ts '[TSRK %Y-%m-%d %H:%M:%.S]'
[TSRK 2021-08-18 17:40:56.206744]     2 2021-08-18 17:40:55.477802058 00:04:96:xx:xx:xx → ff:ff:ff:ff:ff:ff ARP 64 Who has 172.31.x.x? Tell 172.31.x.x

Compare the timestamp of ts ([TSRK 2021-08-18 17:40:56.206744]) to the one of tshark (2021-08-18 17:40:55.477802058)

Output is lagging behind. The combined log outputs the result of find before showing the output of tshark. While - clearly - network activity must precede the result of find.

I've also tried parallel

parallel --line-buffer ::: \
'stdbuf -oL tshark -tad -l -n -s 9999 host x | ts "[TSRK %Y-%m-%d %H:%M:%.S]" ' \
'stdbuf -oL find . -type d | ts "[FIND %Y-%m-%d %H:%M:%.S]" ' \
>/root/outpar

but the outer tool doesn't seem to fix what's obviously wrong with the inner tool... The result is the same.

How do I do this correctly?

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.