Archive for the ‘Performance Tune’ Category


Note

          below testing Server load commands and script only for testing not recommended for Live production server & dont executed in Physical server Hardware may fail try in VMware and Cloud servers.

 

Download rpm – https://rpmfind.net/linux/rpm2html/search.php?query=stress

Install stress rpm – rpm -ivh stress-xxx-.rpm

 

Stress.sh

#!/bin/bash
m=M
MEM=$(free -m | grep ‘Mem:’ | awk ‘{print $7}’)
fmem=$(echo “$MEM*0.95” | bc)
fmem=$( printf “%.0f” $fmem )
CPU=$(grep -c ^processor /proc/cpuinfo)
FCPU=$((CPU-1))
stress –cpu $FCPU -m 1 –vm-bytes $fmem$m –timeout 300

 

Monitor Load using below script

#cat Monitor_load.sh
#!/bin/bash
MEMORY=$(free -m | awk ‘NR==2{printf “%.2f%%\t\t\n”, $3*100/$2 }’)
CPU=$(top -d 0.5 -b -n2 | grep “Cpu(s)”|tail -n 1 | awk ‘{print $2 + $4+ $6}’)
echo “Memory Usage = ${MEMORY}”
echo “CPU Usage = ${CPU}”

 

useful commands during High Server Load testing

top

uptime
free -m
sar -r
sar 5 5


top command

Screenshot_59

Screenshot_58

Show Processes Sorted by any Top Output Column – Press O and Press M

Screenshot_60

Display Selected User in Top Output Using top -u

Screenshot_61

Screenshot_62

Display Only Specific Process with Given PIDs Using top -p

Screenshot_64

Screenshot_63

Display All CPUs / Cores in the Top Output – Press 1 (one)

Screenshot_65

Refresh Unix Top Command Output On demand (or) Change Refresh Interval Press d

Screenshot_66

 Highlight Running Processes in the Linux Top Command Output – Press z

Screenshot_67

Split Top Output into Multiple Panels – Press A

Screenshot_68

Sort by CPU Utilization Press shift + p

Screenshot_69

Save Top Command Results press shift +w

Screenshot_70


Screenshot_51

 

Screenshot_52

 

Screenshot_53

 

Screenshot_54

 

Screenshot_55

 

Screenshot_56


mpstat – Display basic info

 

Screenshot_47

 

 mpstat – Display CPU statistics of individual CPU (or) Core

 

Screenshot_48

 

mpstat – display statistics information of a particular CPU (or core)

Screenshot_49

 

 

mpstat Version

Screenshot_50


uptime command in Linux 

System Time:

This displays the time the system clock shows in 24 hour format:

System Uptime:

This shows you how long the system has been running for.  It will state “up” and then give a timeframe.  In this example picture the system has been running for 5 Hours 21 Minutes.  The time will keep track of hours and minutes.  Once a 24 hour period has past will then keep track of uptime by the number of days, hours and minutes.  Whenever a server is rebooted this timer is reset back to zero.

Number of Users Logged In:

This statistic shows you how many active users are logged into your system at a time.  Pending on the function of the system and if multiple people access it, it’s common to see more than just 1 user.

Load Average:

The load average is the actual usage being put on the server.  This number is signified anywhere from 0.0 up through whole numbers.  Each decimal point can be calculated to a percentage (ie. .01 equals 1% load average). The 3 numbers correspond with the load average for a given time frame during a 1 minute, 5 minute and 15 minute interval.  The lower the load average the better your system will perform.
Screenshot_45
Screenshot_46

1.When i install my operating system 

 

Screenshot_38

2.find Last reboot and date

 

Screenshot_39

 

 

3. Logged information about Particular user

Screenshot_40

 

4.find who are  all still logged in

 

Screenshot_42

5.find who logged in particular terminal

 

Screenshot_43

 

6. find out who was logged in bad attempts

 

Screenshot_44

 

 


1. List all Open Files with lsof Command

 

Screenshot_27

Sections and it’s values are self-explanatory. However, we’ll review FD & TYPE columns more precisely.

FD – stands for File descriptor and may seen some of the values as:

  1. cwd current working directory
  2. rtd root directory
  3. txt program text (code and data)
  4. mem memory-mapped file

Also in FD column numbers like 1u is actual file descriptor and followed by u,r,w of it’s mode as:

  1. r for read access.
  2. w for write access.
  3. u for read and write access.

TYPE – of files and it’s identification.

  1. DIR – Directory
  2. REG – Regular file
  3. CHR – Character special file.
  4. FIFO – First In First Out

2. List User Specific Opened Files

 

Screenshot_28

 

3. Find Processes running on Specific Port

 

Screenshot_29

 

4. List Only IPv4 & IPv6 Open Files

 

Screenshot_30

 

Screenshot_31

 

5. List Open Files of TCP Port ranges 1-1024

 

Screenshot_32

 

6. Exclude User with ‘^’ Character

Screenshot_33

 

7. Find Out who’s Looking What Files and Commands?

 

Screenshot_34

 

8. List all Network Connections

 

Screenshot_35

 

9. Search by PID

Screenshot_36

10. List all TCP or UDP connections

Screenshot_37