Using iostat you can monitor disk load on a specific device.
iostat -dx {device name} 2 10
Examples:
iostat -dx /dev/sdc 2 10
The 2 is the interval and the 10 is the number of iterations. So you will see stats every 2 seconds for 10 iterations.
Using iostat you can monitor disk load on a specific device.
iostat -dx {device name} 2 10
Examples:
iostat -dx /dev/sdc 2 10
The 2 is the interval and the 10 is the number of iterations. So you will see stats every 2 seconds for 10 iterations.
The following is handy if you need to delete files older than X on a Linux server. I like to run the find command first before actually moving or deleting the files. Just to make sure the files I want to remove are returned from the find command.
find /fullpath -mtime +4 -ls
The -ls flag will list out the details of the file so you can verify that the mtime parameter returns the right files.
find /fullpath -mtime +4 -ls -exec mv {} /destination ;After you verify that the find command returns the files you want then you are ready to use the -exec flag on the find command to actually execute the move/delete. I also like to use full path here on the find command, just to make sure I move the right files.
vmstat = virtual memory stats
Procs
Shows you if there are processes blocking your system from running smoothly. The b column shows processes in sleep state. If these numbers are high then you have some waiting processes and may have some problems.
Example r = 5 means that 5 processes are currently waiting to execute. When the CPU is pegged at 100% the severity of the CPU starvation wont be reflected in the percentage of CPU utilization but the run queue will clearly show the impact as processes back up in the queue
b can be used to show CPU power…if the value is constantly greater than zero then you may have a CPU bottleneck. Use ps to list out the most CPU intensive processes.
Memory
Swap
If you have a lot of activity in so it may indicate that you need more physical ram. the system is constantly paging memory out to disk. you need to take these stats over a period of time to get a feel for how your system performs.
If the values are constnaly greater than 0 then you have a memory issue. use ps to find out the most memory intensive processes.
IO
System
CPU
If us is high there is a possibility that some of the user initiated processes are consuming high CPU
If wa is high then there is an issue with the disk storage subsystem and you can use iostat to find sources of I/O contention.
This procedure can be vastly different than the steps below. This is just a quick overivew on how to add a new disk to Linux.
Patitioning
#list devices
fdisk -l
#invoke fdisk for the desired drive
fdisk /dev/[device]
#Create a new partion
Command (m for help): n
#Select primary partition and size to use the entire disk
Command (m for help): p
Partition number (1-4): 1
First cylinder (1-1305): 1
Last cylinder or +size or +sizeM or +sizeK (1-1305): 1305
#Commit changes
Command (m for help): w
Formatting
#show existing file systems (for finding the fs type if you are just duplicating existing configuration)
df -hT
#find block size of a file system
tune2fs -l /dev/[partition name] | grep ‘Block size’
#mkfs.ext3 -b [block size] /dev/[partition name]
Mounting
#First create a mount point
mkdir /u01
#then mount it
mount /dev/[partiton name] /u01
#verify the fs is writeable
touch /u01/test.file ; ls /u01
#set the partition to be mounted on boot by adding a line to /etc/fstab. This is the example fstab file…
#/dev/VolGroup00/LogVol00 / ext3 defaults 1 1
#LABEL=/boot /boot ext3 defaults 1 2
#tmpfs /dev/shm tmpfs defaults 0 0
#devpts /dev/pts devpts gid=5,mode=620 0 0
#sysfs /sys sysfs defaults 0 0
#proc /proc proc defaults 0 0
#/dev/VolGroup00/LogVol01 swap swap defaults 0 0
vi /etc/fstab
/dev/[partition name] /u01 ext3 defaults 0 3
So that took longer than it should. There is a command called whatis that gives you a single line description of a command:
whatis grep
grep (1) - print lines matching a pattern
grep (1p) - search a file for a pattern
grep (rpm) - The GNU versions of grep pattern matching utilities
A nice little tool to use. I just installed CentOS 5 in a VM and noticed that all my whatis commands were returning nothing appopriate…I quickly found the makewhatis command on some articles but could not locate it for CentOS 5 at first. Finally found the location:
/usr/sbin/makewhatis
This command builds the database and now my whatis commands are working.
#Top (X) Memory Consumers
#just change the head command to see more, this will show you top 10
ps -auxf | sort -nr -k 4 | head -10
#Top (X) CPU Consumers
#just change the head command to see more, this will show you top 10
ps -auxf | sort -nr -k 3 | head -10
#uptime:
uptime
output: current time, how long system has been running, how many users are logged in, system load averages for past 1, 5, and 15 minutes
#Version info
uname -a
cat /etc/redhat-release
cat /etc/issue