Skip to content

Instantly share code, notes, and snippets.

@5car1z
Last active September 9, 2017 13:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 5car1z/4668ab431b842281a65cd94ece795c69 to your computer and use it in GitHub Desktop.
Save 5car1z/4668ab431b842281a65cd94ece795c69 to your computer and use it in GitHub Desktop.
#! /usr/bin/env bash
# Initial
DROPLET_OS=`lsb_release -a | tail -n 3 | sed -n '1p' | awk '{$1=""; print substr($0,2)}'`
DROPLET_LOCAL_TIME=`timedatectl | sed -n '1p' | awk '{$1=""; print substr($0,8)}'`
DROPLET_TIMEZONE=`timedatectl | sed -n '4p' | awk '{$1=""; print substr($0,8)}'`
# Basic info
DROPLET_HOSTNAME=`uname -n`
DROPLET_IP=`wget -qO - ifconfig.co`
DROPLET_SPACE=`df -h /dev/vda1 | awk '{print $5}' | tail -n 1 | cut -c1`
# System load
DROPLET_MEMORY1=`free -t -m | grep Total | awk '{print $3" MB";}'`
DROPLET_MEMORY2=`free -t -m | grep "Mem" | awk '{print $2" MB";}'`
DROPLET_CPU=`top -bn 2 -d 0.01 | grep '^%Cpu' | tail -n 1 | awk '{print $2+$4+$6}'`
echo "Welcome user: $USER to host: $HOSTNAME" | cowthink -n
printf "
=======================================================================
- Distribution......: $DROPLET_OS
- Local Time........: $DROPLET_LOCAL_TIME
- Timezone..........: $DROPLET_TIMEZONE
=======================================================================
- Hostname..........: $DROPLET_HOSTNAME
- Droplet IP........: $DROPLET_IP
- Space Used........: $DROPLET_SPACE%%
=======================================================================
- CPU Usage.........: $DROPLET_CPU%%
- Memory Usage......: $DROPLET_MEMORY1 / $DROPLET_MEMORY2
=======================================================================
"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment