Memory stats on Linux

Did you ever wonder what the VIRT, RES and SHR memory figures in top on Linux are supposed to tell you?

Here we go:

  • VIRT – How much memory the process is able to access at the moment.
  • RES – How much memory the process is actually using at the moment. This is the value you should probably be looking at and corresponds with the %MEM column.
  • SHR – How much of the VIRT memory is shareable.

Continue here if you want more details:
http://mugurel.sumanariu.ro/linux/the-difference-among-virt-res-and-shr-in-top-output

A peek at the man page top might also help:

VIRT -- Virtual Memory Size (KiB)
 The total amount of virtual memory used by the task. It includes all code, data and shared libraries plus pages that have
 been swapped out and pages that have been mapped but not used.

RES -- Resident Memory Size (KiB)
 The non-swapped physical memory a task is using.

SHR -- Shared Memory Size (KiB)
 The amount of shared memory available to a task, not all of which is typically resident. It simply reflects memory that
 could be potentially shared with other processes.

AdWords conversion tracking from AngularJS

Inspired by a blog post of Zain Zafar, I implemented my own version of a Google AdWords conversion tracking from AngularJS.

Load the AdWords code from your HTML file:

<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion_async.js"></script>

Then add the AdWords service to your Angular app:

angular.module('adWordsApp').factory('GoogleAdWordsService', function ($window) {
    return {
        sendBookingConversion: function (conversion_id, conversion_language, conversion_label, conversion_value, conversion_currency) {
        	var data = {
        			google_conversion_id: conversion_id,
        			google_conversion_language: conversion_language,
        			google_conversion_format: "3",
        			google_conversion_color: "ffffff",
        			google_conversion_label: conversion_label,
        			google_conversion_value: conversion_value,
        			google_conversion_currency: conversion_currency,
        			google_remarketing_only: false
        	};
        	//alert('call conversion: ' + JSON.stringify(data));
        	$window.google_trackConversion(data);
        }
    };
});

The last thing is to call the service from your controller when the conversion happens:

GoogleAdWordsService.sendBookingConversion(12345, 'de', 'TheLabel', 130, 'CHF');

 

Debug network traffic on a Linux server

Use the following shell command to print all traffic from and to the given IP:

/usr/sbin/tcpdump -n -i any host 10.254.52.59

This will print something like this:

15:46:29.272434 IP 10.254.52.59 > 10.254.252.237: ICMP echo request, id 1, seq 857, length 40
15:46:29.272469 IP 10.254.252.237 > 10.254.52.59: ICMP echo reply, id 1, seq 857, length 40
15:46:34.265170 IP 10.254.52.59 > 10.254.252.237: ICMP echo request, id 1, seq 858, length 40
15:46:34.265204 IP 10.254.252.237 > 10.254.52.59: ICMP echo reply, id 1, seq 858, length 40
15:46:39.265504 IP 10.254.52.59 > 10.254.252.237: ICMP echo request, id 1, seq 859, length 40
15:46:39.265539 IP 10.254.252.237 > 10.254.52.59: ICMP echo reply, id 1, seq 859, length 40

This can be quite handy if you need to debug network issues.