Posts

Showing posts from April, 2015

shell script to gather Server information (after login):

Image
It will shows the server information when login. # create a file 'server_info.sh' # copy and paste the below code. ========================================= #!/bin/bash wait () { echo -en  "Gathering server information..." a=1 while [ $a -le 20 ] do echo -ne "." sleep .1 a=`expr $a + 1` done } pause () {    echo "Press [ Enter ] to continue..."    read -p "$*" } raw_mem=$(cat /proc/meminfo  | grep 'MemTotal\|MemFree\|^Cached' | awk '{print $2}') me=$(echo $raw_mem |awk '{print $1}') tot=$((me/1024)) mef=$(echo $raw_mem |awk '{print $2}') fre=$((mef/1024)) mec=$(echo $raw_mem |awk '{print $3}') cac=$((mec/1024)) use=$((tot-fre)) ho=$(hostname) os=$(cat /etc/redhat-release) ker=$(uname -sr) curc=$(who | awk '{print $1}'| wc -l) lo=$(uptime| cut -f3,4,5 -d',') wait clear echo -e "\nSYSTEM INFORMATION!" echo -e "===================" echo -e "\nOS info:&