본문 바로가기
Programing/shell programing

배너 스크립트

배너 스크립트

=> 배너를 생성하여 단순하게 서버 접속시 실시간 상태를 알려 줄 수 있도록 함
(단순히... 스터디를 위해 예전에 했던것인데... 어설프다... 지금보면...)

[root@localhost ~]$ cat /etc/banner.sh 


#!/bin/sh
###################################
# written by C.Y.YOON
# File nae : banner.sh 
# date: 2012. 02. 27. (수) 10:03:00 KST
####################################

MEM_TOT=`free | grep Mem | awk '{print $2}'`
MEM_USED=`free | grep Mem | awk '{print $3}'`
MEM_FREE=`free | grep Mem | awk '{print $4}'`
MEM_CNT=$(($MEM_TOT/100*60))


SWA_TOT=`free | grep Swa | awk '{print $2}'`
SWA_USED=`free | grep Swa | awk '{print $3}'`
SWA_FREE=`free | grep Swa | awk '{print $4}'`
SWA_CNT=$(($MEM_TOT/100*60))

echo -e "\n###########mem memory########### "

echo -e "total memory : \t  $MEM_TOT"
echo -e "used  memory : \t  $MEM_USED"

if [ $MEM_CNT -gt $MEM_USED ]; then
echo -e "free  memory : \t \e[1;32;40m $MEM_FREE   \e[0m \n"
else
echo -e "free  memory : \t \e[1;31;40m $MEM_FREE   \e[0m \n"
fi

echo -e "###########swap memory###########"

echo -e "total memory : \t  $SWA_TOT"
echo -e "used  memory : \t  $SWA_USED"

if [ $SWA_CNT -gt $SWA_USED ]; then
echo -e "free  memory : \t \e[1;32;40m $SWA_FREE   \e[0m \n"
else
echo -e "free  memory : \t \e[1;31;40m $SWA_FREE   \e[0m \n"
fi


echo -e "###########disk free###########"
df




반응형