detail.sh 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #!/bin/bash
  2. clear
  3. TEXT='\033[30;107;2m'
  4. INFO='\033[97;44m'
  5. WARNING='\033[97;43m'
  6. ERROR='\033[97;41m'
  7. SUCCESS='\033[97;42m'
  8. GREEN='\033[92m'
  9. YELLOW='\033[93m'
  10. RESET='\033[0m'
  11. if [[ "$EUID" -ne 0 ]]; then
  12. echo -e "\033[1;31m Anda tiada kebenaran untuk menjalankan skrip ini! \033[0m"; exit 1
  13. fi
  14. function sysinfo {
  15. # Reading CPU model
  16. cname=$( awk -F: '/model name/ {name=$2} END {print name}' /proc/cpuinfo | sed 's/^[ \t]*//;s/[ \t]*$//' )
  17. # Reading amount of CPU cores
  18. cores=$( awk -F: '/model name/ {core++} END {print core}' /proc/cpuinfo )
  19. # Reading CPU frequency in MHz
  20. freq=$( awk -F: ' /cpu MHz/ {freq=$2} END {print freq}' /proc/cpuinfo | sed 's/^[ \t]*//;s/[ \t]*$//' )
  21. # Reading total memory in MB
  22. tram=$( free -m | awk 'NR==2 {print $2}' )
  23. # Reading Swap in MB
  24. vram=$( free -m | awk 'NR==4 {print $2}' )
  25. # Reading system uptime
  26. up=$( uptime | awk '{ $1=$2=$(NF-6)=$(NF-5)=$(NF-4)=$(NF-3)=$(NF-2)=$(NF-1)=$NF=""; print }' | sed 's/^[ \t]*//;s/[ \t]*$//' )
  27. # Reading operating system and version (simple, didn't filter the strings at the end...)
  28. opsy=$( cat /etc/issue.net | awk 'NR==1 {print}' ) # Operating System & Version
  29. arch=$( uname -m ) # Architecture
  30. lbit=$( getconf LONG_BIT ) # Architecture in Bit
  31. hn=$( hostname ) # Hostname
  32. kern=$( uname -r )
  33. # Output of results
  34. echo
  35. echo -e " ========================== "
  36. echo -e " System Info "
  37. echo -e " -------------------------- "
  38. echo -e " Processor: $cname"
  39. echo -e " CPU Cores: $cores"
  40. echo -e " Frequency: $freq MHz"
  41. echo -e " Memory: $tram MB"
  42. echo -e " Swap: $vram MB"
  43. echo -e " Uptime: $up"
  44. echo -e ""
  45. echo -e " OS: $opsy"
  46. echo -e " Arch: $arch ($lbit Bit)"
  47. echo -e " Kernel: $kern"
  48. echo -e " Hostname: $hn"
  49. echo
  50. }
  51. sysinfo