Skip to content

Instantly share code, notes, and snippets.

@kyberorg
Created January 14, 2014 12:33
Show Gist options
  • Save kyberorg/8417602 to your computer and use it in GitHub Desktop.
Save kyberorg/8417602 to your computer and use it in GitHub Desktop.
#!/usr/local/bin/bash
### Colors ###
END="\e[0m";
RED='\e[0;31m';
BLUE='\e[0;35m';
BROWN='\e[0;33m';
WHITE='\e[0;37m';
### Commands ###
#Hostname
host=`hostname -f`;
#IP Main NIC (adapt to system)
nic="eth0";
ip=`/sbin/ifconfig $nic | grep 'inet addr:'| cut -d: -f2 | awk '{ print $1}'`;
#User
user=`whoami`;
#Last login
llDate=`lastlog -u $user | grep $user | awk '{print $4,$5,$6,$7}'`; llSource=`lastlog -u $user$
ll=${llDate}' '${llSource}
#System info
kernel=`uname -r`;
la=`uptime | awk -F'load average:' '{ print $2 }'`;
#Uptime
rawUpt=`/usr/bin/cut -d. -f1 /proc/uptime`;
uptDays=$((${rawUpt}/60/60/24));
uptHours=$((${rawUpt}/60/60%24));
uptMins=$((${rawUpt}/60%60));
uptSec=$((${rawUpt}%60));
uptime=${uptDays}' Days '${uptHours}' Hours '${uptMins}' Minutes '${uptSec}' Seconds';
#Disk Usage
dPart="/";
tmpFile="/tmp/di";
dCmd=`df -h $dPart | grep -v "Size"` echo $dCmd > ${tmpFile};
dAvail=`cat ${tmpFile} | awk '{print $4}'`; dAll=`cat ${tmpFile} | awk '{print $2}'`;
dPercent=`cat ${tmpFile} | awk '{print $5}'`;
rm ${tmpFile};
disk='Currently '${dAvail}' of '${dAll}' is available at '${dPart}'('${dPercent}' used)';
#Memory Usage
mTotal=`free -m | grep "Mem" | awk '{print $2}'`
mUsed=`free -m | grep "Mem" | awk '{print $3}'`
mFree=`free -m | grep "Mem" | awk '{print $4}'`
mSwap=`free -m | grep "Swap" | awk '{print $3}'`
memory='Total: '${mTotal}' Used: '${mUsed}' Free: '${mFree}' Swap in use: '${mSwap};
#Hardware CPU
cpus=`cat /proc/cpuinfo | grep processor | wc -l`;
cpum=`cat /proc/cpuinfo | grep "model name" | uniq | sed -e 's/model name//' | sed -e 's/://'`;
cpu=${cpus}x${cpum};
[root@dev /usr/home/asm]# cat aa.sh
#!/usr/local/bin/bash
### Colors ###
END="\e[0m";
RED='\e[0;31m';
BLUE='\e[0;35m';
BROWN='\e[0;33m';
WHITE='\e[0;37m';
### Commands ###
#Hostname
host=`hostname -f`;
#IP Main NIC (adapt to system)
nic="eth0";
ip=`/sbin/ifconfig $nic | grep 'inet addr:'| cut -d: -f2 | awk '{ print $1}'`;
#User
user=`whoami`;
#Last login
llDate=`lastlog -u $user | grep $user | awk '{print $4,$5,$6,$7}'`; llSource=`lastlog -u $user$
ll=${llDate}' '${llSource}
#System info
kernel=`uname -r`;
la=`uptime | awk -F'load average:' '{ print $2 }'`;
#Uptime
rawUpt=`/usr/bin/cut -d. -f1 /proc/uptime`;
uptDays=$((${rawUpt}/60/60/24));
uptHours=$((${rawUpt}/60/60%24));
uptMins=$((${rawUpt}/60%60));
uptSec=$((${rawUpt}%60));
uptime=${uptDays}' Days '${uptHours}' Hours '${uptMins}' Minutes '${uptSec}' Seconds';
#Disk Usage
dPart="/";
tmpFile="/tmp/di";
dCmd=`df -h $dPart | grep -v "Size"` echo $dCmd > ${tmpFile};
dAvail=`cat ${tmpFile} | awk '{print $4}'`; dAll=`cat ${tmpFile} | awk '{print $2}'`;
dPercent=`cat ${tmpFile} | awk '{print $5}'`;
rm ${tmpFile};
disk='Currently '${dAvail}' of '${dAll}' is available at '${dPart}'('${dPercent}' used)';
#Memory Usage
mTotal=`free -m | grep "Mem" | awk '{print $2}'`
mUsed=`free -m | grep "Mem" | awk '{print $3}'`
mFree=`free -m | grep "Mem" | awk '{print $4}'`
mSwap=`free -m | grep "Swap" | awk '{print $3}'`
memory='Total: '${mTotal}' Used: '${mUsed}' Free: '${mFree}' Swap in use: '${mSwap};
#Hardware CPU
cpus=`cat /proc/cpuinfo | grep processor | wc -l`;
cpum=`cat /proc/cpuinfo | grep "model name" | uniq | sed -e 's/model name//' | sed -e 's/://'`;
cpu=${cpus}x${cpum};
#RAM
gRam=`free -g | grep "Mem" | awk '{print $2}' `;
mRam=`free -m | grep "Mem" | awk '{print $2}' `;
kRam=`free -k | grep "Mem" | awk '{print $2}' `;
ram=${gRam}' GB or '${mRam}' MB or '${kRam}' KB';
#HDD Info
devA="/dev/sda";
devB="/dev/sdb";
if [`id -u` -ne 0]; then
echo -e $BLUE'+++++++++++++++++++++++++++++++++++++++++++++++'$END;
echo -e $BROWN'
.______ .______ ______ ___ ___ ____ ____ .___________.
| _ \ | _ \ / __ \ \ \ / / \ \ / / | |
| |_) | | |_) | | | | | \ V / \ \/ / |---| |----|
| ___/ | / | | | | > < \_ _/ | |
| | | |\ \----.| `--' | / . \ | | __ | |
| _| | _| `._____| \______/ /__/ \__\ |__| (__) |__|
____ ____ _______ .______ .___________. _______ __ ___ ___
\ \ / / | ____|| _ \ | | / _____|| |/ / |__ \
\ \/ / | |__ | |_) | |---| |----|| | __ | / ______ | |
\ / | __| | / | | | | |_ | | < |______/ /
\ / | |____ | |\ \----.__ | | | |__| | | \ / /_
\__/ |_______|| _| `._____(__)|__| \______| |__|\__\ |____|
.______ __ __
| _ \ | | | |
| |_) | | | | |
| / | | | |
__| |\ \----|| `--' |
__|__| \______| \______/
'$END;
echo -e $BLUE'++++++++++++++++++:'${END} $WHITE'Connection Info'$END $BLUE':++++++++++++++'$EN$
echo -e $BLUE'+'$END' Hostname '$BLUE'='$END $BROWN $host $END;
echo -e $BLUE'+'$END' Main IP '$BLUE'='$END $BROWN $ip $END;
echo -e $BLUE'+'$END' User '$BLUE'='$END $BROWN $user $END;
echo -e $BLUE'+'$END' Last login '$BLUE'='$END $BROWN $ll $END;
echo -e $BLUE'++++++++++++++++++:'${END} $WHITE'System Info'$END $BLUE':++++++++++++++'$END;
echo -e $BLUE'+'$END' Kernel '$BLUE'='$END $BROWN $kernel $END;
echo -e $BLUE'+'$END' Load Average '$BLUE'='$END $BROWN $la $END;
echo -e $BLUE'+'$END' Uptime '$BLUE'='$END $BROWN $uptime $END;
echo -e $BLUE'+'$END' Memory in MB '$BLUE'='$END $BROWN $memory $END;
echo -e $BLUE'+'$END' Disk '$BLUE'='$END $BROWN $disk $END;
echo -e $BLUE'++++++++++++++++++:'${END} $WHITE'Hardware'$END $BLUE':+++++++++++++++++'$END;
echo -e $BLUE'+'$END' CPU '$BLUE'='$END $BROWN $cpu $END;
echo -e $BLUE'+'$END' Total Memory '$BLUE'='$END $BROWN $ram $END;
echo -e $BLUE'+++++++++++++++++++++++++++++++++++++++++++++++'$END;
else
echo -e $BROWN'WARNING! '${END}$WHITE'You are entering '${END}$RED'Root
mode'${END}$WHITE' be careful'${END};
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment