Adding Custom Run-Time Entries to JMeter Log

When test is running I want to add some entries to JMeter Log:

 import org.apache.jorphan.logging.LoggingManager;  
 import org.apache.log.Logger;  
 Logger LOG = LoggingManager.getLoggerFor("My Tag");  
 LOG.info("My message");  

This would generate the following entries on JMeter console:

...
2016/01/27 18:25:06 INFO - jmeter.threads.JMeterThread: Thread started: Thread Group 1-1
2016/01/27 18:25:06 INFO - My Tag: My message
2016/01/27 18:25:06 INFO - jmeter.threads.JMeterThread: Thread is done: Thread Group 1-1
...

Adding Custom Run-Time Entries to JMeter Log

Shell Cheatsheet

Assigning Variables

#!/bin/sh
length=80
chapter=chap # no spaces
title="Greetings from Space" # with spaces
empty= # empty variable
size=$length

Displaying Variables

#!/bin/sh
echo $length # 80
echo length=$length # length=80
echo this is $title # this is Greetings from Space
echo ${chapter}5 # chap5 - to display with no space between variable and other parts of string

Special Variables

#!/bin/sh
$? # exit status of the last command
$$ # process number of the current shell
$! # process number of the last background command
$0 # filename of the current script
$# # number of arguments
$n # arguments (n = 1, 2, ...)
$@ # equivalent of $1 $2 ... $n
$* # same as $@

Special Symbols and Escaping

  • Double quotes escape special characters, except for $, `, \c (c = any character)
  • Single quotes escapes $ as well
  • Backslash escapes single character
  • Combinations with backsllash:
    • \n – new line
    • \c – stay on the same line
    • \t – tab

#!/bin/sh
echo * # equivalent to ls (print out current dir)
echo "*" # prints *
echo "$length" # prints 80 - $ is not escaped by double quotes
echo '$length' # prints $length
echo \$length # prints $length - escapes single character

Reverse quotes (`command`) – run command:

#!/bin/sh
echo today is `date` # shows today's date
users=`who | wc -l`
echo $users # displays number of users logged in

Arguments Shift

#!/bin/sh
# script called like this:
# thisscript hello world
a=$1; shift
b=$1
echo $b $a # world hello

Operators

&& - second command will only run if the first one was successful
|| - second command runs only if first one fails

#!/bin/sh
test -d ~/b && echo "b is directory" # will show "b is directory" only if b is directory
test -f ~/b || echo "b is not file, therefore b is directory" # equivalent to above

For and list

#!/bin/sh
for i in here there everywhere # list
do
   echo $i
done
# will print 
# > here
# > there
# > everywhere

Lists are separated by ; or new line

If-else

#!/bin/sh
if [condition1]
then
    echo "condition 1"
else
    echo "condition 2"
fi

# or
if [condition1]; then
    echo "condition 1"
else
    echo "condition 2"
fi
Conditions
  • -a - and
  • -o - or
  • -gt - greater then
  • -lt - less then
  • -eq - equal
  • -ne - not equal
  • -ge - greater or equal
  • -le - less or equal

#!/bin/sh
if [ $i -gt 7 -a $i -le 99] #$i between 7 and 99

While and Until

#!/bin/sh
# While
while [condition]; do
  [command]
done

# Until
until [condition]; do
  [command]
done

Case

#!/bin/sh
case $i
in
  1) continue;;
  2) echo $i
     continue;;
  3) break;;
esac

Arithmetic Operations (expr)

#!/bin/sh
n=0
n=$n+1
echo $n # prints 0+1 - treats as string by default

n=0
n=`expr $n+1`
echo $n # prints 1

n=`expr 2+3`
echo $n # prints 5
expr 5 "*" 6 # 30
Shell Cheatsheet

How to calculate and print number of files in each subfolder of the current folder on Linux

find . -type d | while read DIR; do find $DIR -type f | printf "%-8s %s\n" $(wc -w) $DIR; done | sort -nr

That is: find all subdirectories of current directory; for each subdirectory, find all files, and print file count and path. Finally it sorts the result to show folders with most files on top
Note that the first entry is the folder itself. Also this script omits soft links and does not count sub-folders as files.

For example:

[someone@somewhere]# cd /etc/X11/
[someone@somewhere]# find . -type d | while read DIR; do find $DIR -type f | printf "%-8s %s\n" $(wc -w) $DIR; done | sort -nr
10 .
7 ./xinit
3 ./xinit/xinitrc.d
0 ./xorg.conf.d
0 ./xinit/Xclients.d
0 ./fontpath.d
0 ./applnk

How to calculate and print number of files in each subfolder of the current folder on Linux

Google Map / Earth icons

A copy from this site. Because I use it often.

Pushpins: http://maps.google.com/mapfiles/kml/pushpin/

Paddles: http://maps.google.com/mapfiles/kml/paddle/

Style

Style -lv

Style _maps

Track Directions: http://earth.google.com/images/kml-icons/track-directional/

Miscellaneous Google map Icons : http://maps.google.com/mapfiles/ms/icons/

Add .shadow for shadow version of most icons e.g. POI.shadow.png

Google Map / Earth icons

Infographic Tools

Tableau Public
Requires tool download (Windows only) and creation of the account, and allows to publish charts online, as well as store them as PDF or image. Very powerful set of graphs, and ability to create a dashboard. Allows to load data set from many different sources.

Infogr.am
Requires to create an account (Facebook / Twitter login can be used). Good selection of charts (data can be imported from Excel spreadsheets), which can also be wrapped into a few themes (and can contain graphical text, images and charts). Simple intuitive UI. No graphs or trees, however, and no option to export (can only publish online).

Easel.ly
Requires to create an account. You can choose a theme from many different templates, or create a new one from scratch.  Shapes are a central piece of the design, and can create many different forms: from tree and graph to a diagram. Presentations can also contain images and graphic text, but no ability to create charts based on data. Can be published online or exported as JPG.

Many Eyes
IBM site, based on Cognos, that allows to visualize data sets. Site design, and user experience in general are quite outdated, clumsy and slow (Java applets are used to render charts). However has a decent set of chart types, diagrams, and maps. Result can be published online or exported as PNG.

Charts Bin
Requires to create an account. Allows to upload and visualize location-based data. Has a few options, and user interface is not very smooth. However what’s valuable is the ability to create interactive maps with data, allows to publish or download it as PNG.

Infographic Tools