echo "$IP服務(wù)器用戶數(shù)已經(jīng)達(dá)到$users個,請及時處理。" | mail -s "$IP服務(wù)器用戶登錄數(shù)告警" XXXX@qq.com else
echo "$IP服務(wù)器當(dāng)前登錄用戶為$users個,情況正常">>/usr/monitor/performance/performance_$(date +%Y%m%d).log fi ###############################################################################
for dir in $tomcat_dir $mysql_dir $vsftp_dir $ssh_dir do process_count=$(ps -ef | grep "$dir" | grep -v grep | wc -l)
for service in tomcat mysql vsftp ssh do echo "$dir" |grep -q "$service" if [ $? -eq 0 ] then if [ $process_count -eq 0 ] then echo "$service is down at $(date +%Y%m%d%H:%M:%S)" >>/usr/monitor/process/process_$(date +%Y%m%d).log echo "$service is down at $(date +%Y%m%d%H:%M:%S)" | mail -s "$IP服務(wù)器 $service服務(wù)關(guān)閉告警" XXXX@qq.com else echo "$service is running at $(date +%Y%m%d%H:%M:%S)" >>/usr/monitor/process/process_$(date +%Y%m%d).log fi else continue fi done done ###############################################################################
流量分析腳本 ############################################################################### #!/bin/bash # TX=0; RX=0; MAX_TX=0; MAX_RX=0; while read line do a=`echo $line | grep "eth0" |awk '{print $3}'` if [ $a -ge 0 ] then TX=$a if [ $TX -ge $MAX_TX ] then MAX_TX=$TX fi fi b=`echo $line | grep "eth0" |awk '{print $7}'` if [ $b -ge 0 ] then RX=$b if [ $RX -ge $MAX_RX ] then MAX_RX=$RX fi fi done < /usr/monitor/network/network_$(date +%Y%m%d).log echo "最高上傳速度為 $MAX_TX kb/s at $(date +%Y%m%d)">>/usr/monitor/network/#log
echo "最高下載速度為 $MAX_RX kb/s at $(date +%Y%m%d)">>/usr/monitor/network/#log ############################################################################### 流量分析日志 /usr/monitor/network/#log