Extract thoughput value from JMeter log file I use JMeter for load testing and want to report error on CI pipeline when application though put is less than 1/sec. JMeter logs summary of results as - 

2017/01/17 01:57:00 INFO  - jmeter.reporters.Summariser: summary +    103 in 00:00:30 =    3.4/s Avg:  2937 Min:    48 Max:  7962 Err:     0 (0.00%) Active: 2 Started: 10 Finished: 8 
2017/01/17 01:57:00 INFO  - jmeter.reporters.Summariser: summary =  12218 in 01:00:03 =    3.4/s Avg:  2942 Min:    20 Max: 27317 Err:     1 (0.01%)
2017/01/17 01:57:00 INFO  - jmeter.reporters.Summariser: summary +      1 in 00:00:00 =   66.7/s Avg:  3227 Min:  3227 Max:  3227 Err:     0 (0.00%) Active: 0 Started: 10 Finished: 10 
2017/01/17 01:57:00 INFO  - jmeter.reporters.Summariser: summary =  12219 in 01:00:03 =    3.4/s Avg:  2942 Min:    20 Max: 27317 Err:     1 (0.01%)  


Herein I would capture the last line and if value of throughput is less than 1 (which is 3.4/s in the current example) then it would be reported as error. Here is the script I wrote to capture value of throughput - 

grep "meter.reporters.Summariser: summary" test.log | tail -1 | awk '{print $12}' | cut -d "." -f1


and it gets me 3 which is ok. How can I improve this script?
You are using here four different tools: grep, tail, awk and cut to do the following:


select lines
get the last one
print a given field of that one
extract the integer part of that field


This is clear and it works. However, using four processes is a bit of overkill, since all of these can be performed one-handedly via awk:

awk '/meter.reporters.Summariser: summary/ {rec=$12} END{printf "%d\n", rec}' file



/meter.reporters.Summariser: summary/ {rec=$12}
When reading from the file, /pattern/ will match those lines containing the "pattern". If this happens, the action within {} is performed. In this case, it consists in storing the 12th field.
But wait, weren't we looking for the last line in which this occurs? Yes, and this is exactly what we are doing by overwriting rec every time the pattern happens: last time it is written, it will store the definitive result.
END{printf "%d\n", rec}
Once all lines have been processed, red will have the desired value on the form 3.4/s. We just want the 3 to appear, so we could do some string triming similar to the one you did with cut. However, we can also use awk's printf() to use Format-Control Letters to just print the integer part of it. This will also print 0 if rec is empty:

$ awk 'BEGIN {printf "%s\n", "3.4/s"}'
3.4/s
$ awk 'BEGIN {printf "%d\n", "3.4/s"}'
3
$ awk 'BEGIN {printf "%d\n", ""}'
0



Of course, you could also add the threshold logic in the script.