Hello,
I'm trying to create a script that will allow me to monitor CPU Utilization, Memory Utilization, I/O Utilization, and Network Utilization. Currently, I have a script that should run the necessary commands on linux. Hopefully in the end, I'll be able to run this every 15 or so 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'd like to take useful data from these files that are created. There are a few categories that the data can be sorted into:
- Load Average
- CPU Idle Percentage
- Kernel Utilization
- Memory Utilization
- Swapping activity
I'm trying to use these commands to generate these 5 files and seem to be having difficulty.
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
While these commands run the output files are just empty. Does anyone know why I'm unable to generate these files?
I really appreciate your help.
Thank you, Aaron
UDPATE: Here is a copy of the output file: http://www.queencitytech.com/ServerPerfRepo180610.out