Dariusz on Software Quality & Performance


Computers's helping hand

Filed under: en — Tags: — dariusz.cieslak @



Self-signed SSL certificate HOWTO

Filed under: en — Tags: , , — dariusz.cieslak @

logo_sslSSL is used for (1) encrypting HTTP traffic and for (2) authentication server against browser's database of trusted certificates. Generating SSL certificate properly is important if you want your customer to use https properly. It costs few bugs per year, but your customers won't have any warnings in browser before SSL session (purpose number 2).

However, for internal applications, self-signed certificate may be a sufficient solution (purpose 1 only). You will find below a minimal commands to generate local SSL certificate (accept default values when asked for data on stdin):

mkdir -p /etc/lighttpd/ssl/local
cd /etc/lighttpd/ssl/local
openssl genrsa -passout pass:1234 -des3 -out server.key 1024
openssl req -passin pass:1234 -new -key server.key -out server.csr
cp server.key server.key.org
openssl rsa -passin pass:1234 -in server.key.org -out server.key
openssl x509 -req -in server.csr -signkey server.key -out server.crt
cat server.key server.crt > server.pem

Then lighttpd installation:

$SERVER["socket"] == "<YOUR_IP_ADDRESS>:443" {
ssl.engine = "enable"
ssl.pemfile = "/etc/lighttpd/ssl/local/server.pem"
ssl.ca-file = "/etc/lighttpd/ssl/local/server.crt"

Then you have to accept server certificate in your browser and voila!


Check current network bandwidth used on a Linux/Unix box

Filed under: en — Tags: , — dariusz.cieslak @

Sometimes you need to quickly measure current bandwidth used by your Linux box and don't have dedicated command installed. You can use standard /proc/ file entries to get that info from the system.

Example of a embedded device with a TS stream as an input:

( cat /proc/net/dev; sleep 1; cat /proc/net/dev; ) | awk '/eth0/ { b=$1; sub(/eth0:/,"",b); if(bp){ print (b-bp)/1024/1024, "MB/s" }; bp=b }'
1.00053 MB/s


NAND kernel driver activity visualisation

Filed under: en — Tags: , — dariusz.cieslak @

Just found: an interesting method to check how your NAND driver (and filesystem kernel module) behave during massive write operations. I've added additional printk-s() to NAND driver kernel module write() call and collected data during filling all available filesystem space.

Output dmesg logs have been preprocessed and offset call parameter has been presented as a graph using gnuplot (horizontally: write number, vertically: offset):


What can we see from that graph:

  • some writes at offset 0 – typically dangerous as might overwrite bootloader area, I've added them intentionally in this graph by reflashing bootloader manually
  • with missing space wear levelling is less efficient – right part of the graph
  • we can see that catalog location (blocks with filesystem metadata) is moved dynamically across all space to avoid multiple writes to the same location (NAND specific), we see the location has been changed ~6 times during whole operation (probably relocation is done after every 2000 write operations)
  • two different partitions are visible (one at ~60M, one at ~10M)


join() in AWK scripting language

Filed under: en — Tags: , , — dariusz.cieslak @

AWK is small but very useful Unix scripting language that is mainly aimed at text files filtering and modification. If you're on embedded device you might expect bigger brothers (as Perl / Python) are not available, but AWK is usually shipped with busybox (= small).

One of missing functionalities is join() function (the opposite of splitting string by regular expression). One can implement it pretty easily, however:

function join(array, sep,
   result, i)
        if (sep == "")
                sep = " "
        else if (sep == SUBSEP) # magic value
                sep = ""
        result = array[1]
        for (i = 2; i in array; i++)
                result = result sep array[i]
        return result


split(s, arr, "|")
output = join(arr, "|")

As a result input string s will have the same contents as output. The function is useful for scripted modification of CSV files.

Older Posts »

Powered by WordPress