Linux

Using awk with group by functionality

Thursday, August 12, 2010
By Steve

You can use the following example if you need to total numbers over a group in a given file. We first show our sample file… 14:30:57 oracle@emgrid01 ~ >cat list.txt steve:61 steve:14 becky:57 steve:19 jenna:69 stephen:57 maddie:54 jenna:53 abby:41 jenna:21 jenna:66 jenna:64 stephen:53 stephen:26 jenna:77 steve:46 maddie:39 steve:32 abby:77 jenna:97 …and then show the totals using awk… 14:30:59 oracle@emgrid01 ~ >awk -F ":" '{a+=$2} END {for (i in a) {print i,a}}' list.txt maddie 93 abby 118 jenna 447 becky 57 steve 172 stephen 136 14:31:01... »

Is memory allocated actually in use?

Thursday, May 13, 2010
By Steve

In an earlier article, we talked about actually initializing memory rather than just allocating it. This post will show how we can look at what is allocated in Linux, as well as when it shows as being in use and when it doesn’t. I found that memory will show up in pmap (really, pmap... »

Huge pages

Tuesday, May 11, 2010
By Steve

Huge Pages is a feature available in later Linux kernels that provides two important benefits: 1. Locks the memory available to huge pages, so it cannot be paged to disk 2. Make the TLB (translation lookaside buffer) much smaller on the processor, as the number of entries is much smaller. This is due to the fact the... »

Where is my close button?!!

Friday, April 30, 2010
By Steve

So I just updated to Ubuntu 10.4, and the first thing I noticed is the fact the close/minimize/maximize buttons were switched to the top left hand corner from the right corner. I have no clue why something as standard as that has to be changed, but I guess I’ll get used to it. »

logrotate configured by mere mortals

Sunday, February 28, 2010
By Steve

This will provide a way to implement log file rotations by a non-privileged users using the standard Linux logrotate infrastructure. For our test case, we set up a log file that looks similar to a “normal” log file we may want to periodically roll over. howards@howards:~$ i=1 howards@howards:~$ while ; do echo $(date)... »

memset example

Thursday, February 11, 2010
By Steve

This is just a quick note so I don’t forget. On linux, you can run what is below to actually *allocate* memory. If you don’t run a memset, the memory will not show as being used in the OS. int main() { int i = 1; while(i++ < 10) { ... »

Delete files older than another file

Wednesday, January 6, 2010
By Steve

Using the find command in *nix is very useful. You can specify that you would like to find files newer than another file, or older or newer than a certain time. You cannot (directly) find files older than another file. However, there is a simple step that allows you to do... »

sudo and LD_LIBRARY_PATH … never the twain shall meet

Thursday, October 8, 2009
By admin

While writing something for our operations support team to use when running a particular process, I found that sudo does not recognize a previously exported value for LD_LIBRARY_PATH. It also won’t use what is in the .bashrc or .profile for the user that owns the script being sudo’d. You also can’t use... »

Port checker

Monday, August 17, 2009
By Steve

This was useful when we testing a migration between database servers. import socket import sys for i in range(1,5): try: HOST = "foo" + str(i) PORT = 2484 print HOST + " " + str(PORT) sock = socket.socket() sock.connect((HOST, int(PORT))) ... »

Python based stress tester

Wednesday, July 22, 2009
By Steve

I often find myself building something in anticipation of needing it at some point.  This is one of those cases :)  Below is a template (a real working one for my needs) that you can edit to build a simple load testing tool.  We were having a performance problem with one SQL statement, and... »

Switch to our mobile site