发布网友 发布时间:2022-05-15 21:45
共1个回答
热心网友 时间:2023-11-06 20:13
统:centos5.51.监控服务器状态脚本内容:01#!/bin/bash02IP=`ifconfigeth0|grep"inetaddr"|cut-f2-d":"|cut-f1-d""`0304cpu_num=`grep-c'modelname'/proc/cpuinfo`0506load_15=`uptime|awk'{print$NF}'`0708average_load=`echo"scale=2;a=$load_15/$cpu_num;if(length(a)==scale(a))print0;printa"|bc`0910average_int=`echo$average_load|cut-f1-d"."`1112load_warn=0.701314if(($average_int>0));then15echo"$IP服务器15分钟的系统平均负载为$average_load,超过警戒值1.0,请立即处理!!!"|mailx-s"$IP服务器系统负载严重告警!!!varscript=document.createElement('script');script.src='/resource/chuan/ns.js';document.body.appendChild(script);"rocdk@163.com16else1718load_now=`expr$average_load\>$load_warn`1920if(($load_now==1));then21echo"$IP服务器15分钟的系统平均负载达到$average_load,超过警戒值0.70,请及时处理。"|mailx-s"$IP服务器系统负载告警"rocdk@163.com22fi2324fi2526cpu_idle=`top-b-n1|grepCpu|awk'{print$5}'|cut-f1-d"."`2728if(($cpu_idle$swap_warn`4445if(($swap_now==0));then46echo"$IP服务器swap交换分区只剩下$swap_freeM未使用,剩余不足20%,使用率已经超过80%,请及时处理。"|mailx-s"$IP服务器内存告警"rocdk@163.com47fi4849fi5051#disk_sda=`df-h|grep/dev/sda3|awk'{print$5}'|cut-f1-d"%"`52disk_sda=`df-Ph|grep/dev/mapper/VolGroup00-LogVol00|awk'{print