Shell rules

Recently in Nettigo I’m busy with learning Chef. Oh, we are small company (in terms of number of servers), so, when finally I had some practice witch Chef I stated I don’t need it :) At least, as full-blown tool, with knife, Chef server (both self hosted and as service).

What I find useful is Chef in local mode, Capistrano and Kitchen. At least this is what I found interesting for me. My goal is not to get fully automated server provisioning, deployment and configuration. I need reliable way to do deployments in repeatable way. I’m moving my application to new server and planning for some microservices inside. This is meant for me to be more reliable deployment way than old – write down all steps when I did created production environment.

Ok, this only a background for this one liner in shell:

tm=30;a=`du -sk|cut -f 1`;sleep $tm;b=`du -sk|cut -f 1`;let c=\(b-a\)/tm;echo $c

I’m deploying my web application once to VirtualBox and sometimes to real server. When creating my Rails application, I need to restore all downaloadable content like images, datasheets, etc. If I do deploy to VirutalBox instance fastest way is to copy it from backup on my laptop. When I do deploy to host in Internet to use data from backup stored on other server. To speed up downloading I have tested different network options (doesn’t matter what one). I needed way to compare how fast are data downloaded. Data downloaded are different files copied from different locations in background. So I did simple ‘oneliner’ shown above to calculate how much data was downloaded and saved to disk in given time and calculate speed in kB/s. Looks ugly, but anybody who remember Perl can not say that ;)


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.