#!/bin/bash
#createdate: 2016-11-15
Date= ' date+%f ' "%h:%m"
ip= ' Ifconfigeth0 | awk '/inet addr/{print $} ' | Cut-d:-f2
`
Echo-e "\033[032mdate: $Date \nhost: $IP \n\033[0m"
echo-----------------CPU----------------
Cpu_us= ' Vmstat|awk ' {print $13} ' |sed-n ' $p '
Cpu_sy= ' Vmstat|awk ' {print $14} ' |sed-n ' $p '
Cpu_id= ' Vmstat|awk ' {print $} ' |sed-n ' $p '
Cpu_wa= ' Vmstat|awk ' {print $16} ' |sed-n ' $p '
cpu_sum=$ (($cpu _us+ $cpu _sy))
Cpu_info ()
{
Echo-e "\033[032mcpu_sum: $cpu _sum% (cpu_use:${cpu_us}%,cpu_system:${cpu_sy}%) \033[0m"
Echo-e "\033[032mcpu_idle:${cpu_id}\033[0m"
Echo-e "\033[032mcpu_wait:${cpu_wa}\033[0m"
}
Cpu_info;
If [$cpu _sum-ge];then
echo "CPU Utilization$cpu_sum" |mail-s "CPU Monitor" xxxxx.com
Fi
echo-----------------Mem-----------------
#Date = ' date+%f ' "%h:%m '
#IP = ' Ifconfigeth0 | awk '/inet addr/{print $} ' | cut-d:-f2 '
Total= ' Free-m |grep Mem | awk ' {print $} '
Use= ' Free-m|awk '/buffers\//{print $NF} '
free=$ (($Total-$Use))
#Total_cony = ' Echo-e | awk ' {print '} '
Echo-e "\033[032mtotal: ${total}m \nuse: ${use}m \nfree: ${free}m\033[0m"
echo-----------------IO------------------
Total= ' fdisk-l| grep "disk/dev/sd[a-z]" |awk ' {print $1$2$3 "GB"} '
Disk_use= ' Df-h|awk ' {print $ "=" $ $} ' | Sed ' 1d ' | Sed ' s/%/%/g '
Echo-e "\033[032mtotal: $Total \n$disk_use\n\033[0m"
:
650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M01/8A/39/wKiom1gq283iJff-AAA4pCBx728433.png-wh_500x0-wm_3 -wmp_4-s_2914856051.png "title=" Qq20161115173054.png "alt=" Wkiom1gq283ijff-aaa4pcbx728433.png-wh_50 "/>
There are shortcomings please put forward, thank you!!
This article from "All Technical Blog" blog, reproduced please contact the author!
Shell scripts to monitor CPU, memory, and hard disk utilization