본문 바로가기
일하다가??

motd 시스템 정보.

by 램쥐뱅 2019. 7. 24.

ubuntu 에서는 motd 관련 landscape-common 과 같은 기본적인 시스템정보를 보여줄수있는 패키지를 제공해준다.

 

centos 와 같이 지원해주지 않는 환경에서 시스템정보를 로그인시 바로 간단히 볼 수있게 기본스크립트를 잘 정리해놓은 글이있어 참고를 위해 퍼와서 수정.

 

#!/bin/bash
#Simple motd script for Centos 5/6/7

b=`tput bold`
n=`tput sgr0`
echo "Checking for system updates:"
while ps aux | grep -e [y]um > /dev/null; do echo -n .;sleep 1; done &
up=`yum -e0 -d0 check-update | awk '{print $1}'`
reset
echo -e "${b}Hostname:${n} `hostname` \t\t IP address: `/sbin/ifconfig ens192 | grep -Fe inet | awk '{print $2}' | head -n 1`"
echo -e "${b}CPU load:${n} `cat /proc/loadavg | cut -d" " -f1-3`"
echo -e "${b}Uptime:${n} `uptime | cut -d" " -f 4-7 | cut -d"," -f1-2`"
echo -e "Free memorry: `cat /proc/meminfo | grep MemFree | awk {'print int($2/1000)'}` MB \t\t Total memory: `cat /proc/meminfo | grep MemTotal | awk {'print int($2/1000)'}` MB"
SwapTotal=$(cat /proc/meminfo | grep SwapTotal | awk '{print int($2)}')
SwapFree=$(cat /proc/meminfo | grep SwapFree | awk '{print int($2)}')
SwapUsed=$((SwapTotal-SwapFree))
echo -e "${b}Swap Used:${n} ${SwapUsed} Kib" 
echo -e "${b}Available updates:${n} `if [[ ! -n "${up}" ]]; then echo "system up-to-date"; else echo $up; fi`\n"
echo -e "Proccess number: `cat /proc/loadavg | cut -d"/" -f2| cut -d" " -f1`\n"
echo -e "${b}Active sessions:${n} `w | tail -n +2`"

 

 

 

 

 

 

 

 

 

 

참고 : https://superuser.com/questions/919962/landscape-sysinfo-for-centos

 

 

 

댓글