Check System Resources Unix

How to check my production machine and find out which application is using up the resources of the Unix machine?

Is there a way to display individual applications that are running and the percentage of resources they are taking up?

You can start by try to used the "process status" command: ps 

Doing a man ps might help. Typical command line flags are:

ps -ef 

ps -aux 

Take note that it depends on your system used.

---

There are free tools available to monitor and manage performance on UNIX systems.  UNIX has following major resource types that need to be monitored and tuned:

- CPU

- Memory

- Disk space

- Communications lines

- I/O Time

- Network Time

- Applications programs

Performance Components

The following are the major component where total system time goes:

User state CPU

The actual amount of time the CPU spends running the users program in the user state. It includes time spent executing library calls, but does not include time spent in the kernel on its behalf. 

System state CPU 

This is the amount of time the CPU spends in the system state on behalf of this program. All I/O routines require kernel services. The programmer can affect this value by the use of blocking for I/O transfers.

I/O Time and Network Time 

These are the amount of time spent moving data and servicing I/O requests

Virtual Memory Performance 

This includes context switching and swapping.

Application Program

Time spent running other programs - when the system is not servicing this application because another application currently has the CPU.

Performance Tools

In your Unix system, it provides the following important tools to measure and fine tune Unix system performance:

Command: nice/renice 

Run a program with modified scheduling priority

Command: netstat 

Print network connections, routing tables, interface statistics, masquerade connections, and multicast memberships

Command: time

Time a simple command or give resource usage

Command: uptime

System Load Average

Command: ps

Report a snapshot of the current processes.

Command: vmstat

Report virtual memory statistics

Command: gprof

Display call graph profile data

Command: prof

Process Profiling

Command: top

Display system tasks

---

top - 'top' is the linux command used to view the server's current utilization statistics (cpu and memory usage), breaking down each process and its utilization state.

To view the server's local resource utilization stats:

top

Sample output from command:

top - 07:00:06 up 16:48, 1 user, load average: 0.00, 0.00, 0.00

 Tasks: 38 total, 1 running, 37 sleeping, 0 stopped, 0 zombie

 Cpu(s): 0.0% user, 0.3% system, 0.0% nice, 99.7% idle

 Mem: 255972k total, 222280k used, 33692k free, 18328k buffers

 Swap: 1052248k total, 0k used, 1052248k free, 99960k cached
 

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ Command

 6505 bobby 15 0 968 968 796 R 0.3 0.4 0:00.04 top

 1 root 15 0 480 480 428 S 0.0 0.2 0:04.03 init

 2 root 16 0 0 0 0 S 0.0 0.0 0:00.00 keventd

 3 root 34 19 0 0 0 S 0.0 0.0 0:00.00 ksoftirqd_CPU0

 4 root 25 0 0 0 0 S 0.0 0.0 0:00.00 kswapd

 5 root 25 0 0 0 0 S 0.0 0.0 0:00.00 bdflush

 6 root 15 0 0 0 0 S 0.0 0.0 0:00.00 kupdated

 103 root 25 0 0 0 0 S 0.0 0.0 0:00.00 khubd

 1340 root 17 0 856 856 600 S 0.0 0.3 0:00.01 devfsd

 3606 root 25 0 0 0 0 S 0.0 0.0 0:00.00 kjournald

 4077 root 24 0 1420 1420 988 S 0.0 0.6 0:00.10 mysqld_safe

 4160 root 16 0 716 716 548 S 0.0 0.3 0:00.09 syslog-ng

 4190 mysql 16 0 5668 5668 2672 S 0.0 2.2 0:00.27 mysqld

 4195 root 17 0 1376 1376 1252 S 0.0 0.5 0:00.86 sshd

 4201 mysql 15 0 5668 5668 2672 S 0.0 2.2 0:00.06 mysqld

 4202 mysql 16 0 5668 5668 2672 S 0.0 2.2 0:00.04 mysqld

 4203 mysql 16 0 5668 5668 2672 S 0.0 2.2 0:00.00 mysqld

The processes are sorted, by default, from top down, with the top process utilizing the most CPU cycles.

This can be further sorted by M and P (for Memory and Processor usage, respectively).

You'll also want to take note of how much total memory is available on your system, and how much is currently being used. If all of your physical memory is being used, the system will begin to dip into swap space on the HDD, and this can cause iowait (disk access) to rise, further increasing the load on the system.

mysql and apache (httpd) are common culprits of load, and if either are responsible, you will need to make sure that they are optimized for both your traffic expectations and available system resources.

Once you are finished using the 'top' command, you can exit by simply hitting q (quit).

Unix

See Also
File Analysing Commands

Have a Unix Problem
Do you have a UNIX Question?

Unix Books :-
UNIX Programming, Certification, System Administration, Performance Tuning Reference Books

Return to : - Unix System Administration Hints and Tips

(c) www.gotothings.com All material on this site is Copyright.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
All product names are trademarks of their respective companies.
The site www.gotothings.com is in no way affiliated with or endorsed by any company listed at this site.
Any unauthorised copying or mirroring is prohibited.