Fungsi awal untuk tampilan MOTD
This commit is contained in:
9
templates/etc/motd.j2
Normal file
9
templates/etc/motd.j2
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
===========================================================
|
||||
= Disediakan oleh Diskominsta Kota Magelang. =
|
||||
= =
|
||||
= Untuk info lebih lanjut, hubungi : =
|
||||
= Telp : 0293-360990 =
|
||||
= eMail: admin@magelangkota.go.id =
|
||||
===========================================================
|
||||
|
||||
36
templates/etc/update-motd.d/20-banner.j2
Normal file
36
templates/etc/update-motd.d/20-banner.j2
Normal file
@@ -0,0 +1,36 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Reset
|
||||
Color_Off=$(printf '\033[0m') # Text Reset
|
||||
|
||||
# Bold
|
||||
BBlack=$(printf '\033[1;30m') # Black
|
||||
BRed=$(printf '\033[1;31m') # Red
|
||||
BGreen=$(printf '\033[1;32m') # Green
|
||||
BYellow=$(printf '\033[1;33m') # Yellow
|
||||
BBlue=$(printf '\033[1;34m') # Blue
|
||||
BPurple=$(printf '\033[1;35m') # Purple
|
||||
BCyan=$(printf '\033[1;36m') # Cyan
|
||||
BWhite=$(printf '\033[1;37m') # White
|
||||
|
||||
# Bold High Intensty
|
||||
BIBlack=$(printf '\033[1;90m') # Black
|
||||
BIRed=$(printf '\033[1;91m') # Red
|
||||
BIGreen=$(printf '\033[1;92m') # Green
|
||||
BIYellow=$(printf '\033[1;93m') # Yellow
|
||||
BIBlue=$(printf '\033[1;94m') # Blue
|
||||
BIPurple=$(printf '\033[1;95m') # Purple
|
||||
BICyan=$(printf '\033[1;96m') # Cyan
|
||||
BIWhite=$(printf '\033[1;97m') # White
|
||||
|
||||
echo
|
||||
echo -e "${BRed},---. ,---.${BYellow} ____ ${BGreen} .-${BIYellow}_${BGreen}'''-. ${BBlue} .-''-. ${BWhite} .---. ${BPurple} ____ ${BYellow},---. .--.${BRed} .-${BIYellow}_${BRed}'''-. "
|
||||
echo -e "${BRed}| \ / |${BYellow} .' __ \`.${BGreen} '${BIYellow}_( )_${BGreen} \ ${BBlue} .'${BIWhite}_ _ ${BBlue} \ ${BWhite} | ${BIPurple},_${BWhite}| ${BPurple} .' __ \`. ${BYellow}| \ | |${BRed} '${BIYellow}_( )_${BRed} \ "
|
||||
echo -e "${BRed}| , \/ , |${BYellow}/ ' \ \\${BGreen}|${BIYellow}(_ o _)${BGreen}| ' ${BBlue} / ${BIWhite}( \` )${BBlue} '${BIPurple},-./ ) ${BPurple} / ' \ \\${BYellow}| , \ | |${BRed}|${BIYellow}(_ o _)${BRed}| ' "
|
||||
echo -e "${BRed}| |\\${BIYellow}_ ${BRed} /| |${BYellow}|___| / |${BGreen}. ${BIYellow}(_,_)${BGreen}/___| ${BBlue}. ${BIWhite}(_ o _)${BBlue} |${BIPurple}\ '_ '\`) ${BPurple} |___| / |${BYellow}| |\\${BICyan}_${BYellow} \| |${BRed}. ${BIYellow}(_,_)${BRed}/___| "
|
||||
echo -e "${BRed}| ${BIYellow} _( )_${BRed}/ | |${BYellow} _.-\` |${BGreen}| | .-----.${BBlue}| ${BIWhite}(_,_)${BBlue}___|${BIPurple} > (_) ) ${BPurple} _.-\` |${BYellow}| ${BICyan}_( )_${BYellow}\ |${BRed}| | .-----. "
|
||||
echo -e "${BRed}| ${BIYellow}(_ o _)${BRed} | |${BYellow}.' ${BICyan}_${BYellow} |${BGreen}' \ '- .''${BBlue} \ .---.${BIPurple}( . .-' ${BPurple} .' ${BIRed}_${BPurple} |${BYellow}| ${BICyan}(_ o _)${BYellow} |${BRed}' \ '- .' "
|
||||
echo -e "${BRed}| ${BIYellow} (_,_)${BRed} | |${BYellow}| ${BICyan}_( )_${BYellow} |${BGreen} \ \`-'\` |${BBlue} \ \`-' /${BIPurple} \`-'\`-'${BWhite}|___ ${BPurple}| ${BIRed}_( )_${BPurple} |${BYellow}| ${BICyan}(_,_)${BYellow}\ |${BRed} \ \`-'\` | "
|
||||
echo -e "${BRed}| | | |${BYellow}\ ${BICyan}(_ o _)${BYellow} /${BGreen} \ / ${BBlue} \ / ${BWhite} | \\${BPurple}\\ ${BIRed}(_ o _)${BPurple} /${BYellow}| | | |${BRed} \ / "
|
||||
echo -e "${BRed}'--' '--'${BYellow} '.${BICyan}(_,_)${BYellow}.' ${BGreen} \`'-...-' ${BBlue} \`'-..-' ${BWhite} \`--------\`${BPurple} '.${BIRed}(_,_)${BPurple}.' ${BYellow}'--' '--'${BRed} \`'-...-' ${Color_Off}"
|
||||
echo
|
||||
29
templates/etc/update-motd.d/30-sysinfo.j2
Normal file
29
templates/etc/update-motd.d/30-sysinfo.j2
Normal file
@@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
|
||||
# get load averages
|
||||
IFS=" " read LOAD1 LOAD5 LOAD15 <<<$(cat /proc/loadavg | awk '{ print $1,$2,$3 }')
|
||||
# get free memory
|
||||
IFS=" " read USED FREE TOTAL <<<$(free -htm | grep "Mem" | awk {'print $3,$4,$2'})
|
||||
# get processes
|
||||
PROCESS=`ps -eo user=|sort|uniq -c | awk '{ print $2 " " $1 }'`
|
||||
PROCESS_ALL=`echo "$PROCESS"| awk {'print $2'} | awk '{ SUM += $1} END { print SUM }'`
|
||||
PROCESS_ROOT=`echo "$PROCESS"| grep root | awk {'print $2'}`
|
||||
PROCESS_USER=`echo "$PROCESS"| grep -v root | awk {'print $2'} | awk '{ SUM += $1} END { print SUM }'`
|
||||
# get processors
|
||||
PROCESSOR_NAME=`grep "model name" /proc/cpuinfo | cut -d ' ' -f3- | awk {'print $0'} | head -1`
|
||||
PROCESSOR_COUNT=`grep -ioP 'processor\t:' /proc/cpuinfo | wc -l`
|
||||
|
||||
W="\e[0;39m"
|
||||
G="\e[1;32m"
|
||||
|
||||
echo -e "
|
||||
${W}system info:
|
||||
$W Distro......: $W`cat /etc/*release | grep "PRETTY_NAME" | cut -d "=" -f 2- | sed 's/"//g'`
|
||||
$W Kernel......: $W`uname -sr`
|
||||
|
||||
$W Uptime......: $W`uptime -p`
|
||||
$W Load........: $G$LOAD1$W (1m), $G$LOAD5$W (5m), $G$LOAD15$W (15m)
|
||||
$W Processes...:$W $G$PROCESS_ROOT$W (root), $G$PROCESS_USER$W (user), $G$PROCESS_ALL$W (total)
|
||||
|
||||
$W CPU.........: $W$PROCESSOR_NAME ($G$PROCESSOR_COUNT$W vCPU)
|
||||
$W Memory......: $G$USED$W used, $G$FREE$W free, $G$TOTAL$W total$W"
|
||||
41
templates/etc/update-motd.d/40-disks.j2
Normal file
41
templates/etc/update-motd.d/40-disks.j2
Normal file
@@ -0,0 +1,41 @@
|
||||
#!/bin/bash
|
||||
|
||||
# config
|
||||
max_usage=90
|
||||
bar_width=50
|
||||
# colors
|
||||
white="\e[39m"
|
||||
green="\e[1;32m"
|
||||
red="\e[1;31m"
|
||||
dim="\e[2m"
|
||||
undim="\e[0m"
|
||||
|
||||
# disk usage: ignore zfs, squashfs & tmpfs
|
||||
mapfile -t dfs < <(df -H -x zfs -x squashfs -x tmpfs -x devtmpfs --output=target,pcent,size | tail -n+2)
|
||||
printf "\ndisk usage:\n"
|
||||
|
||||
for line in "${dfs[@]}"; do
|
||||
# get disk usage
|
||||
usage=$(echo "$line" | awk '{print $2}' | sed 's/%//')
|
||||
used_width=$((($usage*$bar_width)/100))
|
||||
# color is green if usage < max_usage, else red
|
||||
if [ "${usage}" -ge "${max_usage}" ]; then
|
||||
color=$red
|
||||
else
|
||||
color=$green
|
||||
fi
|
||||
# print green/red bar until used_width
|
||||
bar="[${color}"
|
||||
for ((i=0; i<$used_width; i++)); do
|
||||
bar+="="
|
||||
done
|
||||
# print dimmmed bar until end
|
||||
bar+="${white}${dim}"
|
||||
for ((i=$used_width; i<$bar_width; i++)); do
|
||||
bar+="="
|
||||
done
|
||||
bar+="${undim}]"
|
||||
# print usage line & bar
|
||||
echo "${line}" | awk '{ printf("%-31s%+3s used out of %+4s\n", $1, $2, $3); }' | sed -e 's/^/ /'
|
||||
echo -e "${bar}" | sed -e 's/^/ /'
|
||||
done
|
||||
Reference in New Issue
Block a user