0

I have one application like this:

filebench -f fileserver.f

and it output is:

Filebench Version 1.4.9.1
WARNING: Could not open /proc/sys/kernel/shmmax file!
It means that you probably ran Filebench not as a root. Filebench will not increase shared
region limits in this case, which can lead to the failures on certain workloads.
 3297: 0.000: Allocated 170MB of shared memory
 3297: 0.001: File-server Version 3.0 personality successfully loaded
 3297: 0.001: Creating/pre-allocating files and filesets
 3297: 0.007: Fileset bigfileset: 10000 files, 0 leafdirs, avg dir width = 20, avg dir depth = 3.1, 1240.757MB
 3297: 0.009: Removed any existing fileset bigfileset in 1 seconds
 3297: 0.009: making tree for filset /home/njupudi/workloads/bigfileset
 3297: 0.014: Creating fileset bigfileset...
 3297: 6.795: Preallocated 7979 of 10000 of fileset bigfileset in 7 seconds
 3297: 6.795: waiting for fileset pre-allocation to finish
 3301: 6.795: Starting 1 filereader instances
 3302: 6.796: Starting 50 filereaderthread threads
 3297: 8.183: Running...
 3297: 13.184: Run took 5 seconds...
 3297: 13.279: Per-Operation Breakdown
statfile1            4674ops      918ops/s   0.0mb/s      0.0ms/op     1575us/op-cpu [0ms - 0ms]
deletefile1          4674ops      918ops/s   0.0mb/s     12.0ms/op    13256us/op-cpu [0ms - 1170ms]
closefile3           4697ops      922ops/s   0.0mb/s      0.0ms/op     1601us/op-cpu [0ms - 0ms]
readfile1            4697ops      922ops/s 113.7mb/s      0.0ms/op     1720us/op-cpu [0ms - 0ms]
openfile2            4701ops      923ops/s   0.0mb/s      0.0ms/op     1778us/op-cpu [0ms - 20ms]
closefile2           4701ops      923ops/s   0.0mb/s      0.0ms/op     1544us/op-cpu [0ms - 0ms]
appendfilerand1      4701ops      923ops/s   7.3mb/s      1.4ms/op     2314us/op-cpu [0ms - 203ms]
openfile1            4714ops      926ops/s   0.0mb/s      0.0ms/op     1773us/op-cpu [0ms - 21ms]
closefile1           4714ops      926ops/s   0.0mb/s      0.0ms/op     1597us/op-cpu [0ms - 0ms]
wrtfile1             4714ops      926ops/s 116.4mb/s     21.4ms/op    10013us/op-cpu [0ms - 658ms]
createfile1          4724ops      928ops/s   0.0mb/s      0.1ms/op     1897us/op-cpu [0ms - 39ms]
 3297: 13.279: IO Summary: 51711 ops, 10153.731 ops/s, (922/1849 r/w), 237.8mb/s,    337us cpu/op,  11.6ms latency
 3297: 13.279: Shutting down processes

Here for initialization, the application takes around 2-3 seconds and then starts running. We can see in the output like this:

3297: 8.183: Running...

After this the application starts running for a specified time. Meanwhile, I want to start another application (more precisely a shell script) as soon as I see the "Running..." on the console. Is there any way to capture the output of console and compare it with "Running..." and then start shell script while this command is already running?

2
  • 1
    write a script to catch output of filebench -f fileserver.f and check the output contains Running , then call your shell script. Commented Apr 8, 2016 at 2:13
  • Actually, I want to constantly keep looking at the output of the command (as it grows over time) and then trigger another shell script based on particular string. I'm not sure how to do that when the application is still running. Commented Apr 8, 2016 at 2:20

1 Answer 1

3

This is @Rilwan's comment applied to a script you can use. Say you have the script called myrunningfilter:

#!/bin/bash

while read -r line; do
  echo $line
  if echo $line | grep -q ': Running...$'; then
    <run your script here>
  fi
done

You can either run your command by piping the output of your application:

filebench -f fileserver.f | ./myrunningfilter

Or if filebench produces its output on a logfile:

tail -F /var/log/filebench.log | ./myrunningfilter
Sign up to request clarification or add additional context in comments.

1 Comment

This worked for me in a similar situation. I was starting SQL Server in a custom Docker container and the load database script seemed to be firing too fast in some cases. I used that while loop in a bash function instead and called tail -F /tmp/sqllog.txt | wait_for_sql_ready. Posting for anyone else who comes across this in the future.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.