zl程序教程

您现在的位置是:首页 >  系统

当前栏目

Linux下脚本实战之系统监控

Linux 实战 脚本 系统监控
2023-09-14 09:09:22 时间

Linux下脚本实战之系统监控

一、脚本要求

1.监控系统的CPU、内存、硬盘使用率

二、脚本内容

#!/bin/bash
##########################################################
#File Name:monitor.sh
#Version:V1.0
#Aurhor:
#Emali:
#Created Time:2021-05-03 12:45:32
#Description:
##########################################################


#! /bin/bash
DATETIME=$(date +%F" "%H%M)
IP=$(ifconfig bond0 |awk '/netmask/ {print $2}')
which vmstat &> /dev/null
if [ ! $? = 0 ];then
echo "vmstat command no found,please install the package!"
exit 10
elif [  $? = 0 ] ; then



## mem the state
TOTAL=$(free -m |awk '/Mem/ {print $2}')
USED=$(free -m |awk '/Mem/ {print $3}')
FREE=$(free -m |awk '/Mem/ {print $4+$6}')
if [ $FREE -lt 10