menampilkan informasi mesin

Login kedalam shell linux ,

#touch .bash_profile

copy paste script dibawah ini , save as. ( silahkan relogin ulang untuk melihat hasilnya)

#Menampilkan informasi mesin
#antitrust – PT.SDS @ 2014
#mailto anti.trust30@yahoo.com.sg

### alias string command
let upSeconds=”$(/usr/bin/cut -d. -f1 /proc/uptime)”
let secs=$((${upSeconds}%60))
let mins=$((${upSeconds}/60%60))
let hours=$((${upSeconds}/3600%24))
let days=$((${upSeconds}/86400))
UPTIME=`printf “%d days, %02dh%02dm” “$days” “$hours” “$mins” `
netaddress=`hostname -i`

#### get the load averages
read one five fifteen rest < /proc/loadavg

###compute Available Free Memory
MemFreeMB=$(cat /proc/meminfo | grep MemFree | awk {‘print int($2/1000)’})
MemBuffMB=$(cat /proc/meminfo | grep Buffers | awk {‘print int($2/1000)’})
MemCachMB=$(cat /proc/meminfo | grep ^Cached | awk {‘print int($2/1000)’})
AvailMemMB=$(($MemFreeMB + $MemBuffMB + $MemCachMB))

####Hostname and dnsinfo
dnsips=$(sed -e ‘/^$/d’ /etc/resolv.conf | awk ‘{if (tolower($1)==”nameserver”) print $2}’)

####Network Information
devices=$(netstat -i | cut -d” ” -f1 | egrep -v “^Kernel|Iface|lo”)
total=$(wc -w <<<${devices})

####IP address Info
ipshow=

#### result command
echo ”
Kondisi Mesin $netaddress :
===========================
Uptime………….: ${UPTIME}
Load Averages……: ${one}, ${five}, ${fifteen} (1, 5, 15 min)
Running Processes..: `ps ax | wc -l | tr -d ” “` process handling
CPU…………….:`top -b -d1 -n1|grep -i ‘Cpu(s)’ |cut -d: -f2 |cut -d@ -f1 |head -1`
Model Processor….:`cat /proc/cpuinfo |grep ‘model name’ /proc/cpuinfo | cut -d: -f2 |cut -d@ -f1 |head -1`
Memory………….: “$AvailMemMB”MB (Available) / `cat /proc/meminfo | grep MemTotal | awk {‘print int($2/1000)’}`MB (Total)
Free Disk Space….: `df -P -BM | grep -E -m 1 ‘^/dev/sda1 ‘ | awk ‘{print $4 }’ | awk -F ‘.’ ‘{ print $1 }’` on /dev/sda1

Hostname And DNS Information :
==============================
Hostname ……….: `hostname -s`
DNS domain ……..: `hostname -d`
FQDN …………..: `hostname -f`
Net Address …….: `hostname -i`
DNS IP …………: ${dnsips}

Hostname And DNS Information :
==============================
Network Interfaces : “$total” found
IP Address Info …:
`ip -4 address show`
Network Routing …:
`netstat -nr`
Interface traffic .:
`netstat -i`

User Login and Lastlog :
========================
Who is Online …..:
`who -H`
Last login ……..:
`last`

Generate Information by Sigit Afandhi

, ,

Leave a Reply