-
-
Save AjeetK/f9ce269f69125437a7feefa4984c29df to your computer and use it in GitHub Desktop.
SystemStatsOverviewScript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
get_iostat(){ | |
echo "IOSTAT | Top 4 Device IO activity" | |
iostat -m |awk 'NR == 1 {next} {print}'| head -n 9 | |
} | |
get_vmstat(){ | |
echo "\n\nVMSTATS" | |
vmstat | awk ' END {print "No_process_waiting_for_CPU: " $1, "\nMemory_Idle: " $4, "\n\nSwapped_In_memory: " $9, "\nSwapped_Out_Memory: " $10, "\n\nCPU_time_runnning_user_code: " $15, "\nCPU_time_runnning_system_code: " $16, "\n\nInterupts_per_sec: " $13, "\nContext_switches_per_sec: " $14} '| column -t | |
} | |
get_basic_info(){ | |
echo "BASIC INFO" | |
echo "No of cores": `nproc` | |
echo "Uptime" | |
w | |
} | |
get_max_thread_running_proc(){ | |
echo "\n\nMax thread Running process[3rd column is number of threads]" | |
ps axo pid,ppid,nlwp,cmd | sort -nr| head -n 5 | |
} | |
get_highest_memory_proc(){ | |
echo "\n\nPROCESS WITH HIGEST MEMEORY" | |
ps aux| sort -rk 4,4 | head -n 5| awk '{print $2, $4, $11}'| column -t | |
} | |
get_highest_cpu_proc(){ | |
echo "\n\nPROCESS WITH HIGHEST CPU" | |
ps aux| sort -rk 3,3 | head -n 5| awk '{print $2, $3, $11}'| column -t | |
} | |
get_disk_stats(){ | |
echo "\n\nDISK USAGE" | |
df -Th | sort -rk 6| head -n 3| column -t | |
} | |
get_help(){ | |
printf "\n i: IOSTAT" | |
printf "\n d: DISK USAGE" | |
printf "\n s: Basic INFO" | |
printf "\n c: PROCESS WITH HIGHEST CPU" | |
printf "\n m: PROCESS WITH HIGEST MEMEORY" | |
printf "\n t: Max thread Running process" | |
printf "\n v: VMSTAT" | |
} | |
case $1 in | |
i) | |
get_iostat | |
;; | |
d) | |
get_disk_stats | |
;; | |
s) | |
get_basic_info | |
;; | |
c) | |
get_highest_cpu_proc | |
;; | |
m) | |
get_highest_memory_proc | |
;; | |
t) | |
get_max_thread_running_proc | |
;; | |
v) | |
get_vmstat | |
;; | |
h) | |
get_help | |
;; | |
help) | |
get_help | |
;; | |
"") | |
get_iostat | |
get_vmstat | |
get_disk_stats | |
get_simple_info | |
get_highest_memory_proc | |
get_highest_cpu_proc | |
get_max_thread_running_proc | |
;; | |
esac | |
printf "\n\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment