Thursday, November 27, 2008

Performance Tuning on Linux

Measuring Disk I/O
watch --interval 0.5 iostat
Measuring Memory Usage
top or ps aux or pmap
Measuring Video Memory
lspci -v | more
Measuring Network Throughput

netstat
netstat -i inet : displays amount of traffic on all network interface.
watch --interval 1 netstat -i inet : display network traffic every second
ifconfig : # of packets and # of bytes from a particular interface.
netstat -t : displays TCP traffic.
netstat -u : displays UDP traffic.
netstat --protocol=ip : displays all IP(IPv4) connections.
netstat --protocol=ip6 : displays all IPv6 connections.
lsof
lsof -i4 : displays processes having IPv4 connections.
lsof -i6 : displays processes having IPv6 connections.
lsof -i tcp : displays applications with TCP sockets.
lsof -i udp : displays apps with UDP sockets.

Sunday, November 9, 2008

Get Started with...

Commands for PostgreSQL:
connect to the database: psql -d -U
list databases: psql -l
list tablespaces: \db
list all the tables: \d
create schema: create schema
create table: create table
How to write an application in C:
1) you will need a C compiler
2) you will need a make , a tool which actually invokes compiler ( and linker ).
C API consists of two components:
1) a set of header files
This contains data type definitions and function prototype. In other words, the header files describe the API to C compiler.
2) an object code library
This contains actual implementation for each function contained in the API.

So when you use a library, you have to include the lib*.h header file within your c code( using #include directive). You will also need to link your program against the object library.

How to load a library:
sudo gedit /etc/ld.so.conf
sudo ldconfig