Abnormal process check and alert script

Source: Internet
Author: User

Abnormal process check and alert script

#! /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!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.