I am trying to create a script that will allow me to control CPU usage, memory usage, I / O usage and network usage. I currently have a script that should run the necessary commands on linux. Hopefully in the end I can run this every 15 minutes and then use specific information to analyze the data. Below is the script:
#!/bin/sh
OUTPUT="ServerPerf`date '+%d%m%y'`.out"
(
echo "=================================================="
echo " Script Starting Time : `date` "
echo "================================================="
echo " Disk I/O Status "
echo "================================================="
echo
iostat
echo
echo "================================================="
echo "##################################################"
echo " NETWORK TCP PARAMETERS STATUS "
echo "##################################################"
echo
echo
netstat -sp tcp
echo
echo " Processes List "
echo
ps -elf
echo
echo " END "
echo
echo "##################################################"
echo "##################################################"
echo " NETWORK CONNECTION PARAMETER "
echo "##################################################"
echo
echo
netstat -an
echo
echo
echo "##################################################"
echo " NETWORK TRAFFIC STATUS ON INTERFACES "
echo "##################################################"
echo
echo
netstat -i
echo
echo
echo "##################################################"
echo " SERVER MEMORY/CPU Utilization Report "
echo "##################################################"
echo
top -d1 -n 5
echo "=================================================="
echo " VMSTAT INFO "
echo "=================================================="
echo
vmstat 5 5
echo
echo "=================================================="
echo " Script Ending Time : `date` "
echo
echo "=================================================="
) >> $OUTPUT
Now I would like to extract useful data from these created files. There are several categories by which data can be sorted by the following parameters:
- Download Medium
- CPU idle percentage
- Kernel usage
- Memory usage
- Swap operation
I am trying to use these commands to create these 5 files and it seems to be difficult.
grep "load avg" /home/test/logs/ServerPerf180610.out | awk '{ print $6 }' | awk -F, '{ print $1 }' > load_avg.txt
grep "CPU states" /home/test/logs/ServerPerf180610.out | awk '{ print $3 }' | awk -F% '{ print $1 }' > cpu_idle.txt
grep "CPU states" /home/test/logs/ServerPerf180610.out | awk '{ print $7 }' | awk -F% '{ print $1 }' > cpu_kernel.txt
grep "Memory" /home/test/logs/ServerPerf180610.out | awk '{ print $5 }' | awk -FG '{ print $1 }' > memory_util.txt
grep "Memory" /home/test/logs/ServerPerf180610.out | awk '{ print $11 }' | awk -FG '{ print $1 }' > swap_util.txt
, . - , ?
.
,
UDPATE. :
http://www.queencitytech.com/ServerPerfRepo180610.out