#! /Bin/bashrm-rftop100 # delete the file top-d300-n1-b that contains the last record | awk & #39; {if ($9 & gt; = 100 & amp; $12 ~ /Linux/) print $2 & quot; @ centoscn.com & quot ;}& #39; & gt; top100 # output top information once in text format, and
#! /Bin/bash
Rm-rf top100
# Deleting an object that contains the previous record
Top-d 300-n 1-B | awk '{if ($9 >=100 & $12 ~ /Linux/) print $2 "@ centoscn.com"} '> top100
# Output the top information once in text format, and extract all user names whose cpu usage is 100% and whose process name is linux. convert the user name to the Mail address and store the top of the files.
While read mailaddress
Do
Echo "your uml cpu usage on server $ HOSTNAME is 100%. please kill and restart it in time! If the problem persists, contact the IT department! "| Mail-s" UML exception alert "$ mailaddress
Done <top100
# Read the email addresses listed in the top of the file one by one and send alarm emails.
Ps: You have simply completed the requirements and can improve it more completely and reliably!