Linux Login Display System Information script

Source: Internet
Author: User

#!/bin/bash date= ' date  "+%f %t" ' head= "system information as of:  $date"  kernel= ' uname -r ' hostname= ' echo  $HOSTNAME '   #Cpu  loadload1= ' Cat /proc/loadavg  | awk  ' {print $1} ' load5= ' cat /proc/loadavg | awk  ' {print $2} ' Load15= ' cat /proc/loadavg | awk  ' {print $3} '   #System  uptimeuptime= ' cat  /proc/uptime | cut -f1 -d. ' Updays=$ ((uptime/60/60/24)) uphours=$ ((uptime/60/60%24)) upmins=$ ((uptime/60%60)) upsecs=$ ((uptime%60)) up_lastime= ' date -d  ' $ (awk -f.  ' {print $ 1} '  /proc/uptime '  second ago " +"%y-%m-%d %h:%m:%s "'   #Memory  usagemem_usage= ' free -m | awk  '/mem:/{total=$2} /buffers\/cache/ {used=$3} end { printf ("%3.2f%%", used/total*100)} '   #Processesprocesses = ' ps aux | wc -l ' Zombie_ Processes= ' Ps axo stat&nbsP;|grep z |wc -l '   #Flavorcpus = ' CAT&NBSP;/PROC/CPUINFO&NBSP;|GREP&NBSP;PROCESSOR&NBSP;|WC  -l ' mem= ' cat /proc/meminfo |grep memtotal|awk  ' {print $2/1024/1024+0.9} ' |cut  -d. -f1 ' #disk = ' lsblk -l |grep -w vd[a-z] |sed  ' s/G//g ' |awk  ' {sum +=$4} end {print sum} ' disk= ' lsblk -l |grep -w vd[a-z] |sed  ' s/G/ /g ' |awk  ' {print $4} ' |awk  ' begin{fs= ' \ n '; Rs= ""; ors= ""}{for (x=1;x<=nf;x++) {print  "-" $x "G"} print  "\ n"} '   #Userusers = ' users |  wc -w ' user= ' whoami '   #System  fs usagefilesystem=$ (df -hp | awk  '/ ^\/dev/{print $6} ')   #InterfacesINTERFACES =$ (ip -4 ad | grep  ' state  '  | awk -f ":"   '!/^[0-9]*: ?lo/ {print $2} ')   echoecho -e   "\t\033[34m* $head \033[0m" printf  "\ n" printf  "\ T" kernel version:\t%s\n "  $kernelprintf  " \ T "" hostname:\t%s\n "  $hostnameprintf  " \ T "" system load:\t %s %s %s\n "  $load 1,  $load 5,  $load 15printf " \ T "" system uptime:\t%s "D,"   %s "H,"  %s "M,"  %s "S" \ n "  $upDays   $upHours   $upMins   $upSecsprintf  " \ T "" Login  users:\t%s\t\twhoami:\t%s\n "  $users   $USERprintf  " \ T "" Processes:\t%s\t\tzombie proce : \t%s\n "  $processes   $zombie _processesprintf " \ T "" flavor size:\t%sc_%sg%s\tmemory  usage:\t%s\n "  $cpus   $mem   $disk   $mem _usageprintf " \ n "printf " \ T "" filesystem\ Tusage\t\ttotal\n "for f in  $Filesystem  do    usage=$ (df -hP  | awk  ' {if ($NF = = "' $f '" ")  print $5} ')     total=$ (df -hp |  awk  ' {if ($NF = = "' $f" ")  print $2} ')      echo -e " \t$ F\t\t$usage\t\t$total "&Nbsp;doneprintf  "\ n" printf  "\ T" "interface\tmac address\t\tip address\n" for i in   $INTERFACES  do    mac=$ (ip ad show dev  $i  | grep   "Link/ether"  | awk  ' {print $2} ')     ip=$ (ip ad show  dev  $i  | awk  '/inet / {print $2} '  |awk  ' begin{fs= ' \ n '; Rs= ""; ors= ""}{for (x=1;x<=nf;x++) {print  $x "\ t"} print  "\ n"} ')     echo  -e   "\e[1;31m\t" $i "\t\t" $MAC "\t$ip\e[0m"  doneecho


For displaying system information after a user logs on

Linux Login Display System Information script

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.