Wednesday, January 18, 2012

linux backspace and control C not working

______________________________________

mention 'stty intr ^C' in ~/.cshrc, then u may be able to do ctrl-c on optimus.
if the /home//.cshrc file is not present, add a new one.

 ______________________________________

Tuesday, November 15, 2011

Linux Monitoring tools

______________________________________

-  /Proc file system - Various Kernel Statistics
/proc file system provides detailed information about various hardware devices and other Linux kernel information. See Linux kernel /proc documentations for further details. Common /proc examples:
# cat /proc/cpuinfo
# cat /proc/meminfo

-  Nagios - Server And Network Monitoring
-  Cacti - Web-based Monitoring Tool
-  KDE System Guard - Real-time Systems Reporting and Graphing
-  Gnome System Monitor - Real-time Systems Reporting and Graphing

  • nmap - scan your server for open ports.
  • lsof - list open files, network connections and much more.
  • ntop web based tool - ntop is the best tool to see network usage in a way similar to what top command does for processes i.e. it is network traffic monitoring software. You can see network status, protocol wise distribution of traffic for UDP, TCP, DNS, HTTP and other protocols.
  • Conky - Another good monitoring tool for the X Window System. It is highly configurable and is able to monitor many system variables including the status of the CPU, memory, swap space, disk storage, temperatures, processes, network interfaces, battery power, system messages, e-mail inboxes etc.
  • GKrellM - It can be used to monitor the status of CPUs, main memory, hard disks, network interfaces, local and remote mailboxes, and many other things.
  • vnstat - vnStat is a console-based network traffic monitor. It keeps a log of hourly, daily and monthly network traffic for the selected interface(s).
  • htop - htop is an enhanced version of top, the interactive process viewer, which can display the list of processes in a tree form.
  • mtr - mtr combines the functionality of the traceroute and ping programs in a single network diagnostic tool.
 ______________________________________

Detailed Network Traffic Analysis (tcpdump)

______________________________________

The tcpdump is simple command that dump traffic on a network.

to display traffic info about DNS, enter:
# tcpdump -i eth1 'udp port 53'

To display all IPv4 HTTP packets to and from port 80, i.e. print only packets that contain data, not, for example, SYN and FIN packets and ACK-only packets, enter:
# tcpdump 'tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)'

To display all FTP session to 202.54.1.5, enter:
# tcpdump -i eth1 'dst 202.54.1.5 and (port 21 or 20'

To display all HTTP session to 192.168.1.5:
# tcpdump -ni eth0 'dst 192.168.1.5 and tcp and port http'

Use wireshark to view detailed information about files, enter:
# tcpdump -n -i eth1 -s 0 -w output.txt src or dst port 80
______________________________________

Real Time Network Statistics (iptraf)

______________________________________

The iptraf command is interactive colorful IP LAN monitor. It is an ncurses-based IP LAN monitor that generates various network statistics including TCP info, UDP counts, ICMP and OSPF information, Ethernet load info, node stats, IP checksum errors, and others. It can provide the following info in easy to read format:

Network traffic statistics by TCP connection
IP traffic statistics by network interface
Network traffic statistics by protocol
Network traffic statistics by TCP/UDP port and by packet size
Network traffic statistics by Layer2 address
Fig.02: General interface statistics: IP traffic statistics by network interface
Fig.03 Network traffic statistics by TCP connection

 ______________________________________

Display socket information (ss)

______________________________________
The ss command is used to dump socket statistics. It allows showing information similar to netstat command. It can display more TCP and state information than other tools. It is a new, incredibly useful and faster (as compare to netstat) tool for tracking TCP connections and sockets. SS can provide information about:
 -  All TCP sockets.
 -  All UDP sockets.
 -  All established ssh / ftp / http / https connections.
 -  All local processes connected to X server.
 -  All the tcp sockets in state FIN-WAIT-1 and much more.

Display Sockets Summary
List currently established, closed, orphaned and waiting TCP sockets, enter:
# ss -s

Display All Open Network Ports
# ss -l

Type the following to see process named using open socket:
# ss -pl

Find out who is responsible for opening socket / port # 4949:
# ss -lp | grep 4949

Display All TCP Sockets
# ss -t -a

Display All UDP Sockets
# ss -u -a

Display All Established SMTP Connections
# ss -o state established '( dport = :smtp or sport = :smtp )'

Display All Established HTTP Connections
# ss -o state established '( dport = :http or sport = :http )'

Find All Local Processes Connected To X Server
# ss -x src /tmp/.X11-unix/*

List All The Tcp Sockets in State FIN-WAIT-1
List all the TCP sockets in state -FIN-WAIT-1 for our httpd to network 202.54.1/24 and look at their timers:
# ss -o state fin-wait-1 '( sport = :http or sport = :https )' dst 202.54.1/24
 ______________________________________

Find total mem used by a program/process (pmap)

______________________________________
You can find the memory used by a program (process) by looking into /proc directory or using standard command such as ps or top. However, you must calculate all memory usage by hand i.e. add Shared Memory + mapped file + total virtual memory size of the process + Resident Set Size + non-swapped physical memory used by process.

To display process mappings, type
$ pmap pid
$ pmap 3724

The -x option can be used to provide information about the memory allocation and mapping types per mapping. The amount of resident, non-shared anonymous, and locked memory is shown for each mapping:

$ pmap -x 3526 
______________________________________

Linux Multiple Processor stats (mpstat)

______________________________________

The mpstat command displays output activities for each available processor, processor 0 being the first one. Global average activities among all processors are also reported. The mpstat command can be used both on SMP and UP machines, but in the latter, only global average activities will be printed.
         # mpstat -P ALL.
Where, -P cpu | ALL option indicate the processor number for which statistics are to be reported. cpu is the processor number. Note that processor 0 is the first processor. The ALL keyword indicates that statistics are to be reported for all processors.

Output:
Linux 2.6.9-55.ELsmp (server.xyz.com)     06/11/2007
04:13:29 PM  CPU   %user   %nice %system %iowait    %irq   %soft   %idle    intr/s
04:13:29 PM  all    5.63    0.01    2.33    0.85    0.01    0.10   91.06   2255.03
04:13:29 PM    0    5.74    0.00    2.17    0.88    0.01    0.15   91.05   1170.16
04:13:29 PM    1    5.53    0.01    2.49    0.83    0.01    0.06   91.07   1084.87

The report generated by the mpstat command has the following format:
CPU: Processor number. The keyword all indicates that statistics are calculated as averages among all processors.
%user: Show the percentage of CPU utilization that occurred while executing at the user level (application).
%nice: Show the percentage of CPU utilization that occurred while executing at the user level with nice priority.
%system: Show the percentage of CPU utilization that occurred while executing at the system level (kernel). Note that this does not include the time spent servicing
interrupts or softirqs.
%iowait: Show the percentage of time that the CPU or CPUs were idle during which the system had an outstanding disk I/O request.
%irq: Show the percentage of time spent by the CPU or CPUs to service interrupts.
%soft: Show the percentage of time spent by the CPU or CPUs to service softirqs. A softirq (software interrupt) is one of up to 32 enumerated software interrupts
which can run on multiple CPUs at once.
%idle: Show the percentage of time that the CPU or CPUs were idle and the system did not have an outstanding disk I/O request.
intr/s: Show the total number of interrupts received per second by the CPU or CPUs.

Display five reports of global statistics among all processors at two second intervals, enter:
# mpstat 2 5

Display five reports of statistics for all processors at two second intervals, enter:
# mpstat -P ALL 2 5

______________________________________

Collect and Report System Activity (sar)

______________________________________


you don’t have to do anything data is collected and stored in /var/log/sa location using sa1 and sa2 scripts. It is part of sadc - System activity data collector tools.

The sadc command samples system data a specified number of times ( count ) at a specified interval measured in seconds ( interval ). It writes in binary format to the specified output file.

The sa1 command is a shell procedure variant of the sadc command and handles all of the flags and parameters of that command. The sa1 command collects and store binary data in the /var/log/sa/sadd file, where the dd parameter indicates the current day. The interval and count parameters specify that the record should be written count times at interval seconds.

The sa1 command is designed to be started automatically by the cron command. Type the following command to list files:

# ls /var/log/sa
Output:
sa13  sa14  sa15  sa16  sa17  sa18  sa19  sa20  sa21  sar12  sar13  sar14  sar15  sar16  sar17  sar18  sar19  sar20

How do I copy log files?
You can copy all these logs files using ssh/scp or ftp to another computer. You can run use sar command to read binary raw data files, enter
            # sar -f sa13
Output:
Linux 2.6.9-55.ELsmp (monster.labs.nixcraft.in)     05/13/2007
12:00:02 AM       CPU     %user     %nice   %system   %iowait     %idle
12:10:01 AM       all     19.75      0.00      2.29      7.49     70.48
12:20:01 AM       all      2.28      0.00      0.27      0.06     97.39
12:30:01 AM       all      2.58      0.00      0.32      0.07     97.02
12:40:02 AM       all     16.05      0.00      3.12     13.48     67.36
12:50:01 AM       all     10.78      0.00      1.20      3.61     84.41
01:00:01 AM       all      2.42      0.00      0.29      0.30     96.99


To see network counter, enter:
# sar -n DEV | more

To display the network counters from the 24th:
# sar -n DEV -f /var/log/sa/sa24 | more

You can also display real time usage using sar:
# sar 4 5

Sample Outputs:
Linux 2.6.18-128.1.14.el5 (www03.nixcraft.in) 06/26/2009
06:45:12 PM       CPU     %user     %nice   %system   %iowait    %steal     %idle
06:45:16 PM       all         2.00        0.00      0.22         0.00         0.00        97.78
06:45:20 PM       all         2.07        0.00      0.38         0.03         0.00        97.52
06:45:24 PM       all         0.94        0.00      0.28         0.00         0.00        98.78
06:45:28 PM       all         1.56        0.00      0.22         0.00         0.00        98.22
06:45:32 PM       all         3.53        0.00      0.25         0.03         0.00        96.19
Average:             all          2.02        0.00      0.27         0.01         0.00        97.70

 ______________________________________

Linux Virtual Memory PAGESIZE

______________________________________

Most modern operating systems have their main memory divided into pages. It allows better utilization of memory. A page is a fixed length block of main memory, that is contiguous in both physical memory addressing and virtual memory addressing. Kernel swap and allocates memory using pages

To display size of a page in bytes, enter:
$ getconf PAGESIZE
OR
$ getconf PAGE_SIZE

Output:
4096

 ______________________________________

Linux Memory Usage (free)

______________________________________

The best way to find out RAM information is open a terminal and type the following command:
$ free -m
OR
$ free -mt

Output:
                  total          used        free      shared    buffers   cached
Mem:          2008       1837        170          0          50        963
-/+ buffers/cache:        822       1185
Swap:         1027          0         1027

free command print the total amount of free and used physical and swap memory in the system, as well as the buffers used by the Linux kernel. You can pass following options

-b switch displays the amount of memory in bytes
-k switch (set by default) displays it in kilobytes
-m switch displays it in megabytes.
-t switch displays a line containing the totals.
-o switch disables the display of a "buffer adjusted" line. If the -o option is not specified, free subtracts buffer memory from the used memory and adds it to the free memory reported.
-s switch activates continuous polling delay seconds apart. You may actually specify any floating point number for delay, usleep(3) is used for microsecond resolution delay times.

______________________________________

processes in Linux (ps)

______________________________________
ps command will report a snapshot of the current processes.

To select all processes use the -A or -e option:
# ps -A

ps is just like top but provides more information.

Show Long Format Output
# ps -Al

To turn on extra full mode (it will show command line arguments passed to process):
# ps -AlF

To See Threads ( LWP and NLWP)
# ps -AlFH

To See Threads After Processes
# ps -AlLm

Print All Process On The Server
# ps ax
# ps axu

Print A Process Tree
# ps -ejH
# ps axjf
# pstree

Print Security Information
# ps -eo euser,ruser,suser,fuser,f,comm,label
# ps axZ
# ps -eM

See Every Process Running As User
# ps -U -u u

Set Output In a User-Defined Format
# ps -eo pid,tid,class,rtprio,ni,pri,psr,pcpu,stat,wchan:14,comm
# ps axo stat,euid,ruid,tty,tpgid,sess,pgrp,ppid,pid,pcpu,comm
# ps -eopid,tt,user,fname,tmout,f,wchan

Display Only The Process IDs of Lighttpd
# ps -C lighttpd -o pid=

OR
# pgrep lighttpd

OR
# pgrep -u vivek php-cgi

Display The Name of PID 55977
# ps -p 55977 -o comm=

Find Out The Top 10 Memory Consuming Process
# ps -auxf | sort -nr -k 4 | head -10

Find Out top 10 CPU Consuming Process
# ps -auxf | sort -nr -k 3 | head -10
 ______________________________________

Linux logged in user ( w )

______________________________________

w command displays information about the users currently on the machine, and their processes.
# w
# w username

Sample Outputs:

 17:58:47 up 5 days, 20:28,  2 users,  load average: 0.36, 0.26, 0.24
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
root         pts/0    10.1.3.145       14:55    5.00s  0.04s  0.02s vim /etc/resolv.conf
root         pts/1    10.1.3.145       17:43    0.00s  0.03s  0.00s w

 ______________________________________

Memory, Paging, System Activity, Hardware and System Information (vmstat)

______________________________________

vmstat command reports information about processes, memory, paging, block IO, traps, and cpu activity. However, a real advantage of vmstat command output - is to the point and (concise) easy to read/understand. The output of vmstat command use to help identify system bottlenecks. Please note that Linux vmstat does not count itself as a running process.

Here is an output of vmstat command from my enterprise grade system:

$ vmstat -S M

Output:
procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu----
r  b   swpd   free   buff  cache   si   so    bi    bo   in    cs us sy id wa
3  0      0   1963    607   2359    0    0     0     0    0     1 32  0 68  0

Where,
The fist line is nothing but six different categories. The second line gives more information about each category. This second line gives all data you need.
-S M: vmstat lets you choose units (k, K, m, M) default is K (1024 bytes) in the default mode. I am using M since this system has over 4 GB memory. Without -M option it will use K as unit

$ vmstat
Output:

procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu----
r  b   swpd   free   buff  cache   si   so    bi    bo   in    cs us sy id wa
3  0      0 2485120 621952 2415368  0    0     0     0    0     1 32  0 68  0

Field Description For Vm Mode
(a) procs is the process-related fields are:
       r: The number of processes waiting for run time.
       b: The number of processes in uninterruptible sleep.
(b) memory is the memory-related fields are:
       swpd: the amount of virtual memory used.
       free: the amount of idle memory.
       buff: the amount of memory used as buffers.
       cache: the amount of memory used as cache.
(c) swap is swap-related fields are:
       si: Amount of memory swapped in from disk (/s).
       so: Amount of memory swapped to disk (/s).
(d) io is the I/O-related fields are:
       bi: Blocks received from a block device (blocks/s).
       bo: Blocks sent to a block device (blocks/s).
(e) system is the system-related fields are:
       in: The number of interrupts per second, including the clock.
       cs: The number of context switches per second.
(f) cpu is the CPU-related fields are:
       These are percentages of total CPU time.

us: Time spent running non-kernel code. (user time, including nice time)
sy: Time spent running kernel code. (system time)
id: Time spent idle. Prior to Linux 2.5.41, this includes IO-wait time.
wa: Time spent waiting for IO. Prior to Linux 2.5.41, shown as zero.

As you see the first output produced gives averages data since the last reboot. Additional reports give information on a sampling period of length delay. You need to sample data using delays i.e. collect data by setting intervals. For example collect data every 2 seconds (or collect data every 2 second 5 times only):

$ vmstat -S M 2
   OR
$ vmstat -S M 2 5

Output:
procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu----
r  b   swpd   free   buff  cache   si   so    bi    bo   in    cs us sy id wa
3  0      0   1756    607   2359    0    0     0     0    0     1 32  0 68  0
3  0      0   1756    607   2359    0    0     0     0 1018    65 38  0 62  0
3  0      0   1756    607   2359    0    0     0     0 1011    64 37  0 63  0
3  0      0   1756    607   2359    0    0     0    20 1018    72 37  0 63  0
3  0      0   1756    607   2359    0    0     0     0 1012    64 37  0 62  0
3  0      0   1756    607   2359    0    0     0     0 1011    65 38  0 63  0
3  0      0   1995    607   2359    0    0     0     0 1012    62 35  2 63  0
3  0      0   1731    607   2359    0    0     0     0 1012    64 34  3 62  0
3  0      0   1731    607   2359    0    0     0     0 1013    72 38  0 62  0
3  0      0   1731    607   2359    0    0     0     0 1013    63 37  0 63  0
This is what most system administrators do to identify system bottlenecks. I hope all of you find vmstat data is concise and easy to read.

 ______________________________________

Linux CPU Usage (top)

______________________________________

$ top

You can see Linux CPU utilization under CPU stats. The task’s share of the elapsed CPU time since the last screen update, expressed as a percentage of total CPU time. In a true SMP environment (multiple CPUS), top will operate in number of CPUs. Please note that you need to type q key to exit the top command display.

The top command produces a frequently-updated list of processes. By default, the processes are ordered by percentage of CPU usage, with only the "top" CPU consumers shown. The top command shows how much processing power and memory are being used, as well as other information about the running processes.

Hot Key  Usage
t          Displays summary information off and on.
m          Displays memory information off and on.
A         Sorts the display by top consumers of various system resources. Useful for quick identification
                of performance-hungry tasks on a system.
f          Enters an interactive configuration screen for top. Helpful for setting up top for a specific task.
o          Enables you to interactively select the ordering within top.
r          Issues renice command.
k          Issues kill command.
z          Turn on or off color/mono
______________________________________

Linux Disk Utilization (iostat)

______________________________________

iostat -d -x interval count

-d : Display the device utilization report (d == disk)
-x : Display extended statistics including disk utilization
interval : It is time period in seconds between two samples . iostat 2 will give data at each 2 seconds interval.
count : It is the number of times the data is needed . iostat 2 5 will give data at 2 seconds interval 5 times

eg. Output:

Linux 2.6.18-53.1.4.el5 (moon.nixcraft.in)   12/17/2007
Device:         rrqm/s   wrqm/s   r/s   w/s   rsec/s   wsec/s avgrq-sz avgqu-sz   await  svctm  %util
sda               1.10    39.82  3.41 13.59   309.50   427.48    43.36     0.17   10.03   1.03   1.75
sdb               0.20    18.32  1.15  6.08   117.36   195.25    43.22     0.51   71.14   1.26   0.91
Device:         rrqm/s   wrqm/s   r/s   w/s   rsec/s   wsec/s avgrq-sz avgqu-sz   await  svctm  %util
sda               0.00   108.40  1.40 64.40    49.60  1382.40    21.76     0.04    0.67   0.44   2.92
sdb               0.00    37.80  0.00 245.20     0.00  2254.40     9.19    28.91  108.49   1.08  26.36
Device:         rrqm/s   wrqm/s   r/s   w/s   rsec/s   wsec/s avgrq-sz avgqu-sz   await  svctm  %util
sda               0.00    97.01  1.00 57.29    39.92  1234.33    21.86     0.03    0.58   0.50   2.89
sdb               0.00    38.32  0.00 288.42     0.00  2623.55     9.10    32.97  122.30   1.15  33.27

Where,
rrqm/s : The number of read requests merged per second that were queued to the hard disk
wrqm/s : The number of write requests merged per second that were queued to the hard disk
r/s : The number of read requests per second
w/s : The number of write requests per second
rsec/s : The number of sectors read from the hard disk per second
wsec/s : The number of sectors written to the hard disk per second
avgrq-sz : The average size (in sectors) of the requests that were issued to the device.
avgqu-sz : The average queue length of the requests that were issued to the device
await : The average time (in milliseconds) for I/O requests issued to the device to be served. This includes the time spent by the requests in queue and the time spent servicing them.
svctm : The average service time (in milliseconds) for I/O requests that were issued to the device
%util : Percentage of CPU time during which I/O requests were issued to the device (bandwidth utilization for the device). Device saturation occurs when this value is close to 100%.
______________________________________

Friday, October 28, 2011

Basic Networking commands on Linux/Unix

______________________________________
• finding host/domain name and IP address - hostname
• test network connection – ping
• getting network configuration – ifconfig
• Network connections, routing tables, interface statistics – netstat
• query DNS lookup name – nslookup
• communicate with other hostname – telnet
• outing steps that packets take to get to network host – traceroute
• view user information – finger
• checking status of destination host - telnet

hostname
hostname with no options displays the machines host name
hostname –d displays the domain name the machine belongs to
hostname –f displays the fully qualified host and domain name
hostname –i displays the IP address for the current machine

ping
It sends packets of information to the user-defined source. If the packets are received, the destination device sends packets back. Ping can be used for two purposes
1. To ensure that a network connection can be established.
2. Timing information as to the speed of the connection.

If you do ping www.yahoo.com it will display its IP address. Use ctrl+C to stop the test.

ifconfig
View network configuration, it displays the current network adapter configuration. It is handy to determine if you are getting transmit (TX) or receive (RX) errors.

Bringing down a network interface with ifconfig
[root@morgan]# ifconfig eth0 down

Bringing up an Ethernet interface with ifconfig[root@morgan]# ifconfig eth0 192.168.99.14 netmask 255.255.255.0 up
[root@morgan]# ifconfig eth0

netstat
Most useful and very versatile for finding connection to and from the host. You can find out all the multicast groups (network) subscribed by this host by issuing "netstat -g"
netstat -nap | grep port will display process id of application which is using that port
netstat -a or netstat –all will display all connections including TCP and UDP
netstat --tcp or netstat –t will display only TCP connection
netstat --udp or netstat –u will display only UDP connection
netstat -g will display all multicast network subscribed by this host.

nslookup
If you know the IP address it will display hostname. To find all the IP addresses for a given domain name, the command nslookup is used. You must have a connection to the internet for this utility to be useful.
E.g. nslookup blogger.com

traceroute
A handy utility to view the number of hops and response time to get to a remote system or web site is traceroute. Again you need an internet connection to make use of this tool.

finger
View user information, displays a user’s login name, real name, terminal name and write status.

telnet
Connects destination host via telnet protocol, if telnet connection establish on any port means connectivity between two hosts is working fine.
telnet hostname port will telnet hostname with the port specified. Normally it is used to see whether host is alive and network connection is fine or not.

Remove a Static Network Route and Add a static host route

# route del -net 192.168.98.0 netmask 255.255.255.0 gw 192.168.99.1
# route add -net 192.168.98.42 netmask 255.255.255.255 gw 192.168.99.1
# route add -host 192.168.98.42 gw 192.168.99.1
SIOCADDRT: File exists

# route -n
Kernel IP routing table
Destination         Gateway            Genmask                Flags   Metric Ref    Use Iface
192.168.99.0      0.0.0.0               255.255.255.0        U         0      0           0     eth0
192.168.98.42   192.168.99.1      255.255.255.255    UGH   0      0           0     eth0
127.0.0.0           0.0.0.0                255.0.0.0                U         0      0           0     lo
0.0.0.0               192.168.99.254  0.0.0.0                    UG      0      0           0     eth0
_____________________________________

Basic Network Commands on Windows prompt

______________________________________
arp -a
This tool handles the resolution of a IP to a physical address. The command gives a list of IPs and physical addresses on your local network.

ipconfig /all
This is the main network tool. Using without parameters gives you basic information about your network. With the all parameters, a more detailed information about DNS, DHCP, and other network settings appears.

ipconfig /renew
This command renews the IP that a DHCP server has assigned to your computer. This is the command that Windows uses when it tells you that is trying to solve a problem with the network.
ipconfig /flushdns
Your computer has a table with the names of computers and their corresponding IP addresses. This command will remove all the entries on that table. It’s very useful if you change your DNS servers.
ipconfig /displaydns
This command display the content of the table we were talking before.
netstat -nab
With this basic command, you can know every open port on your computer and the executable that has the port opened. In Windows 7 this command needs Administration rights (Click Start, type cmd, right click cmd.exe and click Run as administrator.)
netstat -r
Display the routing table.
ping
The easiest way to know if one of your computers is connected to the network.
tracert
Informs about the route to a remote host. The problem about tracert is that this uses a specific port that can be blocked in the route.

If you want to know if you can establish a connection between you and a router port use:
Elikfulkerson. Tcp ping.
This is an incredible light and useful tool.
pathping
A better version of tracert that gives you statics about packet lost and latency.
nslookup
With this tool you can check your DNS servers. For example, imagine you are experiencing a problem with your current DNS and it cannot resolve the address www.mintywhite.com. You can test it with nslookup and use other DNS servers to try to resolve the address.

This program can inform about a PC name given his IP address.
______________________________________

Tuesday, August 30, 2011

DSLR Photography

______________________________________
Aperture : closely related to eye balls. One can think of it as Iris in the eye balls,
Its a component inside of the lens that lets more light in depending on whether you are opening it or closing it. For example when the sun comes out we kind of close of eyes to reduce the amount of light in and when there is less light outside we open eyes wide to let the light come in.
Aperture also affects "Depth of Field". Depth of field is how deeply in the picture the things are in focus. If the aperture is very wide the depth of field is going to be very short and vice verse.
Thus aperture controls the amount of light coming in and the depth of field while taking picture.
-----------------
Shutter Speed :
Shutter is a mechanical object inside the camera that works just like manual shutters. It opens and closes while taking photos. The speed with which it closes and opens allows less or more light to come in.
If the shutter speed is fast like it opens up and closes very fast, we can take a very sharp picture while the object is in movement, like a humming bird with its wings open while its flying.
But if the shutter speed is slow then picture captures the motion and we can get the blur of the motion in the picture.
Thus shutter speed affects how much light gets in and how much motion blur is captured.
-----------------
ISO / Film Speed / Sensitivity:
 How fast the sensor absorbs the light. It affects the quality of the picture. The faster it captures it more grains we are going to see in the picture or more pixels in the picture. Slowest is 100 and 1600 to 3200 is like faster now a days.
Keep it low in the ISO to get a better quality and only use as necessary.

 -  Shoot manual mode always
 -  Find the subject or isolate the subject and photograph that
 -  get 50 mm 1.8 lens (1.8 is very wide aperture, it helps in giving nice depth of field )
-----------------
Photography in Lighting (Sun) :
 -  being in shade always gives a nice picture
 -  Lower or lowest ISO speed (100)
 -  aperture open wide (1.8)
 -  shutter speed to be pretty fast (200)

If you are in the front of the sun, (eg.  camera >>>  subject    <<<<   sun   )   turn on flash. That balances the light on the subject that comes from other side and that comes from the camera. Another thing to do is to cover up the lens using hand.

If the light fall directly on the sun (eg. sun >>>>>  camera >>>> subject  ) . Don't let the photographers shadow on the subject.
-----------------
White Balance :

Various Light sources:
Sun
Tungsten (regular light bulb)
Halogen lighting
Flash lighting (camera flash)
Shade (like being in the shade in sun)

These all the light sources have different color temperature. Film has a different temperature situations to balance the color in different light sources. These modes can be set in the camera according to the signs shown in the picture above.







 ______________________________________

Thursday, August 25, 2011

Linux and Unix find command

______________________________________

Linux and Unix find command

Quick links
About find
Finds one or more files assuming that you know their approximate filenames.
Syntax
find path expressions
pathA path name of a starting point in the directory hierarchy.
-atime nTrue if the file was accessed n days ago. The access time of directories in path is changed by find itself.
-cpio deviceAlways true; write the current file on device in cpio format (5120-byte records).
-ctime nTrue if the file's status was changed n days ago.
-depthAlways true; causes descent of the directory hierarchy to be done so that all entries in a directory are acted on before the directory itself. This can be useful when find is used with cpio to transfer files that are contain edin directories without write permission.
-exec commandTrue if the executed command returns a zero value as exit status. The end of command must be punctuated by an escaped semicolon. A command argument {} is replaced by the current path name.
-followAlways true; causes symbolic links to be followed. When following symbolic links, find keeps track of the directories visited so that it can detect infinite loops; for example, such a loop would occur if a symbolic link pointed to an ancestor. This expression should not be used with the -type l expression.
-fstype typeTrue if the filesystem to which the file belongs is of type type .
-group gnameTrue if the file belongs to the group gname. If gname is numeric and does not appear in the /etc/group file, it is taken as a group ID.
-inum nTrue if the file has inode number n.
-linksTrue if the file has n links.
-localTrue if the file system type is not a remote file system type as defined in the /etc/dfs/fstypes file. nfsis used as the default remote filesystem type if the/etc/dfs/fstypes file is not present.
-lsAlways true; prints current path name together
with its associated statistics. These include
(respectively):
  • inode number
  •  size in kilobytes (1024 bytes)
  •  protection mode
  • number of hard links
  • user
  • group
  • size in bytes
  • modification time.
If the file is a special file the size field will instead contain the major and minor device numbers.
If the file is a symbolic link the pathname of the linked-to file is printed preceded by `->'. The format is identical to that of ls -gilds ls Note: Formatting is done internally, without executing the ls program.
-mountAlways true; restricts the search to the file system containing the directory specified. Does not list mount points to other file systems.
-mtime nTrue if the file's data was modified n days ago.
-name patternTrue if pattern matches the current file name.  Normal shell file name generation characters (see sh) may be used. A backslash (\) is used as an escape character within the pattern. The pattern should be escaped or quoted when find is invoked from the shell.
-ncpio deviceAlways true; write the current file on device in cpio -c format (5120 byte records).
-newer fileTrue if the current file has been modified more recently than the argument file.
-nogroupTrue if the file belongs to a group not in the /etc/group file.
-nouserTrue if the file belongs to a user not in the /etc/passwd file.
-ok commandLike -exec except that the generated command line is printed with a question mark first, and is executed only if the user responds by typing y.
-perm [-]modeThe mode argument is used to represent file mode bits. It will be identical in format to the operand described in chmod, and will be interpreted as follows. To start, a template will be assumed with all file mode bits cleared. An op symbol of:
+will set the appropriate mode bits in the template;
-will clear the appropriate bits;
=will set the appropriate mode bits, without regard to the contents of process' file mode creation mask.
The op symbol of - cannot be the first character of mode; this avoids ambiguity with the optional leading hyphen. Since the initial mode is all bits off, there are not any symbolic modes that need to use - as the first character.
If the hyphen is omitted, the primary will evaluate as true when the file permission bits exactly match the value of the resulting template.
Otherwise, if mode is prefixed by a hyphen, the primary will evaluate as true if at least all the bits in the resulting template are set in the file permission bits.
-perm [-]onumTrue if the file permission flags exactly match the octal number onum seechmod). If onum is prefixed by a minus sign (-), only the bits that are set in onum are compared with the file permission flags, and the expression evaluates true if they match.
-printAlways true; causes the current path name to be printed.
-pruneAlways yields true. Do not examine any directories or files in the directory structure below the pattern just matched. If -depth is specified, -prune will have no effect.
-size n[c]True if the file is n blocks long (512 bytes per block). If n is followed by a c, the size is in
bytes.
-type cTrue if the type of the file is c, where c is b, c, d, D, f, l, p, or s for block special file, character special file, directory, door, plain file, symbolic link, fifo (named pipe), or socket, respectively.
-user unameTrue if the file belongs to the user uname . If uname is numeric and does not appear as a login name in the /etc/passwd file, it is taken as a user ID.
-xdevSame as the -mount primary.
When using find to determine files modified within a range of time, one must use the ?time argument before the -print argument; otherwise, find will give all files.
Examples
find -name 'mypage.htm'
In the above command the system would search for any file named mypage.htm in the current directory and any subdirectory.
find / -name 'mypage.htm'
In the above example the system would search for any file named mypage.htm on the root and all subdirectories from the root.
find -name 'file*'
In the above example the system would search for any file beginning with file in the current directory and any subdirectory.
find -name '*' -size +1000k
In the above example the system would search for any file that is larger then 1000k.
find . -size +500000 -print
Next, similar to the above example, just formatted differently this command would find anything above 500MB. ______________________________________

Thursday, June 16, 2011

SNMP ( Simple Network Management Protocol )

______________________________________


In typical SNMP uses, one or more administrative computers called managers have the task of monitoring or managing a group of hosts or devices on acomputer network. Each managed system executes, at all times, a software component called an agent which reports information via SNMP to the manager.
Essentially, SNMP agents expose management data on the managed systems as variables. The protocol also permits active management tasks, such as modifying and applying a new configuration through remote modification of these variables. The variables accessible via SNMP are organized in hierarchies. These hierarchies, and other metadata (such as type and description of the variable), are described by Management Information Bases(MIBs).
An SNMP-managed network consists of three key components:
  • Managed device
  • Agent — software which runs on managed devices
  • Network management system (NMS) — software which runs on the manager
managed device is a network node that implements an SNMP interface that allows unidirectional (read-only) or bidirectional access to node-specific information. Managed devices exchange node-specific information with the NMSs. Sometimes called network elements, the managed devices can be any type of device, including, but not limited to, routersaccess serversswitchesbridgeshubsIP telephonesIP video cameras, computer hosts, and printers.
An agent is a network-management software module that resides on a managed device. An agent has local knowledge of management information and translates that information to or from an SNMP specific form.
network management system (NMS) executes applications that monitor and control managed devices. NMSs provide the bulk of the processing and memory resources required for network management. One or more NMSs may exist on any managed network.


SNMP itself does not define which information (which variables) a managed system should offer. Rather, SNMP uses an extensible design, where the available information is defined by management information bases (MIBs). MIBs describe the structure of the management data of a device subsystem; they use a hierarchical namespace containing object identifiers (OID). Each OID identifies a variable that can be read or set via SNMP.

The SNMP agent receives requests on UDP port 161. The manager may send requests from any available source port to port 161 in the agent. The agent response will be sent back to the source port on the manager. The manager receives notifications (Traps and InformRequests) on port 162. 

Management Information Base (MIB)
is a virtual database used for managing the entities in a communications network.

The MIB hierarchy can be depicted as a tree with a nameless root, the levels of which are assigned by different organizations. The top-level MIB OIDs belong to different standards organizations, while lower-level object IDs are allocated by associated organizations. This model permits management across all layers of the OSI reference model, extending into applications such as databasesemail, and the Java reference model, as MIBs can be defined for all such area-specific information and operations.
A managed object (sometimes called a MIB object, an object, or a MIB) is one of any number of specific characteristics of a managed device. Managed objects are made up of one or more object instances (identified by their OIDs), which are essentially variables.
Two types of managed objects exist:
  • Scalar objects define a single object instance.
  • Tabular objects define multiple related object instances that are grouped in MIB tables.
An example of a managed object is atInput, which is a scalar object that contains a single object instance, the integer value that indicates the total number of input AppleTalk packets on a router interface.
An object identifier (or object ID or OID) uniquely identifies a managed object in the MIB hierarchy.


GETRetrieve data from a network node
GETNEXTRetrieve the next element from a network node
(more on this later)
SETSend configuration or control commands to a network node
TRAPA network node can send a notification to the management station
INFORMAn acknowledged trap (network nodes can try and send it again if no acknowledgement is received)

Note: With Fedora / Redhat the packages to install would be net-snmp-utils (client) and net-snmp (server) and with Debian / Ubuntu the packages are snmp (client) and snmpd (server).




 ______________________________________