-
Notifications
You must be signed in to change notification settings - Fork 0
/
sysstats-motd
27 lines (26 loc) · 1.42 KB
/
sysstats-motd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/sh
CPU=`cat /proc/cpuinfo | grep 'model name' | head -1 | cut -d':' -f2 | sed 's/^ *//'`
Memory=`free | grep Mem | awk '{printf "%.4f", $3/$2 * 100.0}'`
inet=`ifconfig | grep -A 1 eth0 | grep inet | cut -d ":" -f 3 | sed s/Mask//g`
cpuusage=`top -bn1 | grep "Cpu(s)" | cut -d ":" -f 2 | sed 's/^ *//'`
diskusage=`df -m | grep xvda1 | awk '{printf "%.4f", $3/$2 * 100.0}'`
diskfree=`df -m | grep xvda1 | awk {'print $3'}`
memfree=`free -m | grep Mem | awk '{print $4}'`
cores=`cat /proc/cpuinfo | grep -c processor`
release=`cat /proc/sys/kernel/osrelease`
instanceid=`curl --silent http://169.254.169.254/latest/meta-data/instance-id`
pubip=`curl --silent http://169.254.169.254/latest/meta-data/public-ipv4`
iamrole=`curl --silent http://169.254.169.254/latest/meta-data/iam/info | grep InstanceProfileArn | cut -d "/" -f 2 | sed 's/",//'`
secgroups=`curl --silent http://169.254.169.254/latest/meta-data/security-groups`
echo " "
echo " OS Release: "$release
echo " CPU: "$CPU" Cores:"$cores
echo " CPU usage: "$cpuusage
echo " "
echo " XVDA1 Usage: "$diskusage"% PublicIP: "$pubip
echo " XVDA1 Free: "$diskfree"M InstanceID: "$instanceid
echo " Memory Usage: "$Memory"% Hostname: "`hostname`
echo " Memory Free: "$memfree"M Eth0: "$inet
echo " IAM Role: "$iamrole
echo " Security Groups: "$secgroups
echo " "