Advertisement
ujiajah1

check_system.sh

May 15th, 2016
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.18 KB | None | 0 0
  1. #! /bin/bash
  2. # unset any variable which system may be using
  3.  
  4. # clear the screen
  5. clear
  6.  
  7. while getopts iv name
  8. do
  9.         case $name in
  10.           i)iopt=1;;
  11.           v)vopt=1;;
  12.           *)echo "Invalid arg";;
  13.         esac
  14. done
  15.  
  16. echo "Hai! Hello World"
  17. echo "Check_system_server by puji ermanto_bonbinnet"
  18.  
  19. if [[ $# -eq 0 ]]
  20. then
  21. {
  22.  
  23. # Cek Apakah Koneksi Internet Mati atau Tidak
  24. ping -c 1 google.com &> /dev/null && echo -e '\E[32m'"Internet:  Connected" || echo -e '\E[32m'"Internet:  Disconnected"
  25.  
  26. # cek type OS
  27. os=$(uname -o)
  28. echo -e '\E[32m'"Operating System Type :"  $os
  29.  
  30. # Cek Nama Release Version
  31. cat /etc/os-release | grep 'NAME\|VERSION' | grep -v 'VERSION_ID' | grep -v 'PRETTY_NAME' > /tmp/osrelease
  32. echo -n -e '\E[32m'"OS Name :"   && cat /tmp/osrelease | grep -v "VERSION" | cut -f2 -d\"
  33. echo -n -e '\E[32m'"OS Version :"  && cat /tmp/osrelease | grep -v "NAME" | cut -f2 -d\"
  34.  
  35. # Cek Architecture
  36. architecture=$(uname -m)
  37. echo -e '\E[32m'"Architecture :"  $architecture
  38.  
  39. # Cek Kernel Release
  40. kernelrelease=$(uname -r)
  41. echo -e '\E[32m'"Kernel Release :"  $kernelrelease
  42.  
  43. # Cek hostname
  44. echo -e '\E[32m'"Hostname :"  $HOSTNAME
  45.  
  46. # Cek Internal IP
  47. internalip=$(hostname -I)
  48. echo -e '\E[32m'"Internal IP :"  $internalip
  49.  
  50. # Cek DNS
  51. nameservers=$(cat /etc/resolv.conf | sed '1 d' | awk '{print $2}')
  52. echo -e '\E[32m'"Name Servers :"  $nameservers
  53.  
  54. # Cek Logged In Users
  55. who>/tmp/who
  56. echo -e '\E[32m'"Logged In users :"  && cat /tmp/who
  57.  
  58. # Cek RAM and SWAP Usages
  59. free -h | grep -v + > /tmp/ramcache
  60. echo -e '\E[32m'"Ram Usages :"
  61. cat /tmp/ramcache | grep -v "Swap"
  62. echo -e '\E[32m'"Swap Usages :"
  63. cat /tmp/ramcache | grep -v "Mem"
  64.  
  65. # Cek Disk Usages
  66. df -h| grep 'Filesystem\|/dev/sda*' > /tmp/diskusage
  67. echo -e '\E[32m'"Disk Usages :"  
  68. cat /tmp/diskusage
  69.  
  70. # Cek Load Average
  71. loadaverage=$(top -n 1 -b | grep "load average:" | awk '{print $10 $11 $12}')
  72. echo -e '\E[32m'"Load Average :"  $loadaverage
  73.  
  74. # Cek System Uptime
  75. tecuptime=$(uptime | awk '{print $3,$4}' | cut -f1 -d,)
  76. echo -e '\E[32m'"System Uptime Days/(HH:MM) :"  $tecuptime
  77.  
  78. # Remove Temporary Files
  79. rm /tmp/osrelease /tmp/who /tmp/ramcache /tmp/diskusage
  80. }
  81. fi
  82. shift $(($OPTIND -1))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement