#!/bin/sh
SYS_V=`uname`
if [ $SYS_V = "Linux" ];
then
#Memory
##Mem_Total
MEM_SUM_STR=`grep MemTotal /proc/meminfo |awk '{print $2}'`
MEM_SUM_GB=`awk 'BEGIN{print '$MEM_SUM_STR'/'1048576'}'`
MEM_SUM=`awk 'BEGIN{print '$MEM_SUM_GB'+'0.5'}'`
MEM_SUM=""MEM_SUM=""${MEM_SUM%.*}""GB""
echo $MEM_SUM
##Mem_used
MEM_FREE_STR=`grep MemFree /proc/meminfo |awk '{print $2}'`
MEM_USED_GB=`awk 'BEGIN{print '$MEM_SUM_GB'-('$MEM_FREE_STR'/'1048576')}'`
MEM_USED=`awk 'BEGIN{print '$MEM_USED_GB'/'$MEM_SUM_GB'*'100'}'`
MEM_USED="MEM_USED="${MEM_USED%.*}"%"
echo $MEM_USED
#Cpu
CPU_FREE_STR=`top -b -n 1 | grep -w Cpu`
CPU_FREE_STR=`echo ${CPU_FREE_STR%id*}`
echo $CPU_FREE_STR
CPU_FREE_STR=`echo ${CPU_FREE_STR##*,}`
echo $CPU_FREE_STR
CPU_FREE=${CPU_FREE_STR%.*}
echo $CPU_FREE
CPU="CPU=""$((100-$CPU_FREE))""%"
echo $CPU
#Disk
##Disk_used
DISK_USED=`df -h|sed -n '2p'|awk '{print $3}'`
UNIT=${DISK_USED:0-1:1}
if [ $UNIT = "T" ];
then
DISK_USED=${DISK_USED%T}
DISK_USED=`awk 'BEGIN{print '$DISK_USED'*'1000'}'`
DISK_USED=$DISK_USED"GB"
fi
DISK_USED="DISK_USED="$DISK_USED
echo $DISK_USED
##Disk_sum
DISK_SUM=`df -h |sed -n '2p'|awk '{print $2}'`
UNIT=${DISK_SUM:0-1:1}
if [ $UNIT = "T" ];
then
DISK_SUM=${DISK_SUM%T}
DISK_SUM=`awk 'BEGIN{print '$DISK_SUM'*'1000'}'`
DISK_SUM=$DISK_SUM"G"
fi
DISK_SUM="DISK_SUM="$DISK_SUM
echo $DISK_SUM
#User
VH_NUM=`ls -lt /data/home/|awk '{print $3}'| grep -v "root/|admin/|nobody"|wc -l`
VH_NUM="VH_NUM="$(($VH_NUM-1))
echo $VH_NUM|tr -d ' '
#Print
echo -e "$CPU/n""$MEM_SUM/n""$MEM_USED/n""$DISK_SUM/n""$DISK_USED/n""$VH_NUM" > /data/home/sys_usedinfo.txt
hname=`hostname|awk -F . '{print $1}'`
echo $hname
mv /data/home/sys_usedinfo.txt /data/home/"$hname".txt
echo "Linux"
else
#Memory
##Mem_Total
MEM_SUM_STR=`top -b -n 1|grep -w Swap|awk '{print $2}'`
MEM_SUM_STR=${MEM_SUM_STR%M}
MEM_SUM_GB=`awk 'BEGIN{print '$MEM_SUM_STR'/'1024'}'`
MEM_SUM=`awk 'BEGIN{print '$MEM_SUM_GB'+'0.5'}'`
MEM_SUM=""MEM_SUM=""${MEM_SUM%.*}""GB""
echo $MEM_SUM
##Mem_used
MEM_FREE_STR=`top -b -n 1 | grep -w Mem|awk '{print $12}'`
MEM_FREE_STR=${MEM_FREE_STR%M}
MEM_USED_STR=$(($MEM_SUM_STR-$MEM_FREE_STR))
MEM_USED_GB=`awk 'BEGIN{print '$MEM_USED_STR'/'1024'/'$MEM_SUM_GB'*'100'}'`
MEM_USED=""MEM_USED=""${MEM_USED_GB%.*}""%""
echo $MEM_USED
#Cpu
CPU_FREE_STR=`top -d 2 | grep ^CPU|awk '{print $10}'`
CPU_FREE="${CPU_FREE_STR%.*}"
CPU="CPU=""$((100-$CPU_FREE))""%"
echo $CPU
#Disk
##Disk_used
DISK_USED=`df -h |grep /data|awk '{print $3}'`
DISK_USED="DISK_USED="$DISK_USED
##Disk_sum
DISK_SUM=`df -h |grep /data|awk '{print $2}'`
DISK_SUM="DISK_SUM="$DISK_SUM
echo $DISK_SUM
echo $DISK_USED
#User
VH_NUM=`ls -lt /data/home/|awk '{print $3}'| grep -v "root/|admin/|nobody"|wc -l`
VH_NUM="VH_NUM="$(($VH_NUM-1))
echo $VH_NUM|tr -d ' '
#Print
echo -e "$CPU/n""$MEM_SUM/n""$MEM_USED/n""$DISK_SUM/n""$DISK_USED/n"|tr -d ' ' > /data/home/sys_usedinfo.txt
hname=`hostname|awk -F . '{print $1}'`
echo $hname
mv /data/home/sys_usedinfo.txt /data/home/"$hname".txt
echo "Unix"
fi
#
SYS_V=`uname`
if [ $SYS_V = "Linux" ];
then
#Memory
##Mem_Total
MEM_SUM_STR=`grep MemTotal /proc/meminfo |awk '{print $2}'`
MEM_SUM_GB=`awk 'BEGIN{print '$MEM_SUM_STR'/'1048576'}'`
MEM_SUM=`awk 'BEGIN{print '$MEM_SUM_GB'+'0.5'}'`
MEM_SUM=""MEM_SUM=""${MEM_SUM%.*}""GB""
echo $MEM_SUM
##Mem_used
MEM_FREE_STR=`grep MemFree /proc/meminfo |awk '{print $2}'`
MEM_USED_GB=`awk 'BEGIN{print '$MEM_SUM_GB'-('$MEM_FREE_STR'/'1048576')}'`
MEM_USED=`awk 'BEGIN{print '$MEM_USED_GB'/'$MEM_SUM_GB'*'100'}'`
MEM_USED="MEM_USED="${MEM_USED%.*}"%"
echo $MEM_USED
#Cpu
CPU_FREE_STR=`top -b -n 1 | grep -w Cpu`
CPU_FREE_STR=`echo ${CPU_FREE_STR%id*}`
echo $CPU_FREE_STR
CPU_FREE_STR=`echo ${CPU_FREE_STR##*,}`
echo $CPU_FREE_STR
CPU_FREE=${CPU_FREE_STR%.*}
echo $CPU_FREE
CPU="CPU=""$((100-$CPU_FREE))""%"
echo $CPU
#Disk
##Disk_used
DISK_USED=`df -h|sed -n '2p'|awk '{print $3}'`
UNIT=${DISK_USED:0-1:1}
if [ $UNIT = "T" ];
then
DISK_USED=${DISK_USED%T}
DISK_USED=`awk 'BEGIN{print '$DISK_USED'*'1000'}'`
DISK_USED=$DISK_USED"GB"
fi
DISK_USED="DISK_USED="$DISK_USED
echo $DISK_USED
##Disk_sum
DISK_SUM=`df -h |sed -n '2p'|awk '{print $2}'`
UNIT=${DISK_SUM:0-1:1}
if [ $UNIT = "T" ];
then
DISK_SUM=${DISK_SUM%T}
DISK_SUM=`awk 'BEGIN{print '$DISK_SUM'*'1000'}'`
DISK_SUM=$DISK_SUM"G"
fi
DISK_SUM="DISK_SUM="$DISK_SUM
echo $DISK_SUM
#User
VH_NUM=`ls -lt /data/home/|awk '{print $3}'| grep -v "root/|admin/|nobody"|wc -l`
VH_NUM="VH_NUM="$(($VH_NUM-1))
echo $VH_NUM|tr -d ' '
echo -e "$CPU/n""$MEM_SUM/n""$MEM_USED/n""$DISK_SUM/n""$DISK_USED/n""$VH_NUM" > /data/home/sys_usedinfo.txt
hname=`hostname|awk -F . '{print $1}'`
echo $hname
mv /data/home/sys_usedinfo.txt /data/home/"$hname".txt
echo "Linux"
else
#Memory
##Mem_Total
MEM_SUM_STR=`top -b -n 1|grep -w Swap|awk '{print $2}'`
MEM_SUM_STR=${MEM_SUM_STR%M}
MEM_SUM_GB=`awk 'BEGIN{print '$MEM_SUM_STR'/'1024'}'`
MEM_SUM=`awk 'BEGIN{print '$MEM_SUM_GB'+'0.5'}'`
MEM_SUM=""MEM_SUM=""${MEM_SUM%.*}""GB""
echo $MEM_SUM
##Mem_used
MEM_FREE_STR=`top -b -n 1 | grep -w Mem|awk '{print $12}'`
MEM_FREE_STR=${MEM_FREE_STR%M}
MEM_USED_STR=$(($MEM_SUM_STR-$MEM_FREE_STR))
MEM_USED_GB=`awk 'BEGIN{print '$MEM_USED_STR'/'1024'/'$MEM_SUM_GB'*'100'}'`
MEM_USED=""MEM_USED=""${MEM_USED_GB%.*}""%""
echo $MEM_USED
#Cpu
CPU_FREE_STR=`top -d 2 | grep ^CPU|awk '{print $10}'`
CPU_FREE="${CPU_FREE_STR%.*}"
CPU="CPU=""$((100-$CPU_FREE))""%"
echo $CPU
#Disk
##Disk_used
DISK_USED=`df -h |grep /data|awk '{print $3}'`
DISK_USED="DISK_USED="$DISK_USED
##Disk_sum
DISK_SUM=`df -h |grep /data|awk '{print $2}'`
DISK_SUM="DISK_SUM="$DISK_SUM
echo $DISK_SUM
echo $DISK_USED
#User
VH_NUM=`ls -lt /data/home/|awk '{print $3}'| grep -v "root/|admin/|nobody"|wc -l`
VH_NUM="VH_NUM="$(($VH_NUM-1))
echo $VH_NUM|tr -d ' '
echo -e "$CPU/n""$MEM_SUM/n""$MEM_USED/n""$DISK_SUM/n""$DISK_USED/n"|tr -d ' ' > /data/home/sys_usedinfo.txt
hname=`hostname|awk -F . '{print $1}'`
echo $hname
mv /data/home/sys_usedinfo.txt /data/home/"$hname".txt
echo "Unix"
fi
#