motd-gen

my motd scripts
git clone git://git.ckyln.com/~cem/motd-gen.git
Log | Files | Refs | README | LICENSE

50-systeminfo.motd (915B)


      1 storage() { 
      2         DISK="$1"; [ -z "$DISK" ] && DISK="/" 
      3         printf "$DISK: " 
      4         command 
      5         command df -h | grep "$DISK\$" | awk '{print $3}' | sed s/G// | tr -d '\n' 
      6         printf "/" 
      7         command df -h | grep "$DISK\$" | awk '{print $2}' | sed s/G/\ GB/ 
      8 } 
      9  
     10 ram() { 
     11         USED="$(command free -m | grep Mem: | awk '{print $3}')" 
     12         TOTAL="$(command free -m | grep Mem: | awk '{print $2}')" 
     13         printf "RAM: " 
     14         expr 100 \* "$USED" / "$TOTAL" | tr -d '\n' 
     15         printf "%%\\n" 
     16 } 
     17  
     18 ipv4() { 
     19         [ -z "$1" ] && return 1 
     20         IPV4="$(ip a show "$1" 2>/dev/null | grep 'inet ' | cut -d : -f 2 | awk '{print $2}' | cut -d / -f 1)" 
     21         [ -z "$IPV4" ] && return 1 
     22         printf "IP: $IPV4\\n" 
     23 } 
     24  
     25 printf "System information as of $(date +%a\ %d\ %b\ %Y\ %H:%M:%S):\\n\\n" 
     26 ipv4 eth0 
     27 ram 
     28 storage 
     29 uptime --pretty 
     30  
     31 printf "\\n" 
     32 
     33 # vim:filetype=sh