LINUX-monitor server status and linux Monitoring Server

Source: Internet
Author: User

LINUX-monitor server status and linux Monitoring Server

This document describes how to monitor the operating status of linux servers, including CPU, hard disk, memory, network interfaces, and motherboard.

How to monitor Hard Disks
  • Core Ideology
    Use command df.
  • Sample program
#! /Bin/bashIP = 'hostname-I 'hostname = 'hostname' disk _ sda2 = 'df-Ph | grep/dev/sda2 | awk' {print $5} '| cut -f 1-d "%" 'mailtitle = "server hard disk alert "; if ($ disk_sda2> 90) then MailContent = "Hi: <br> the SDA2 usage of the server $ HostName ($ IP) Hard Disk Partition has exceeded $ disk_sda2 %. Please handle it in time. "; Php sendEmail. php $ MailTitle $ MailContentfi
How to monitor memory
  • Core Ideology
    Use command free. Then, use the ps command to output the process occupying the first 10 of the memory.
    Note that the actual memory usage is 18880/64420 MB, and the memory allocation rate is 29298/64420 MB.
  • Sample program
#! /Bin/bashIP = 'hostname-I 'hostname = 'hostname' MAX _ mem = 70MAX_swap = 70 total = 'free-m | grep Mem | awk' {print $2 }' 'memory = 'free-m | grep Mem | awk' {print $3} ''locatedmen = 'free | awk'/Mem/{print int ($3/$2*(100 )} ''mem = 'free-m | awk'/-/{print $3} ''usedtotal = 'awk' BEGIN {printf int ('$ Mem'/'$ total ') * 100)} ''usedswap = 'free | awk'/Swap/{print $3} ''if [$ UsedSwap-gt 0]; then SWAP = 'free | awk'/Swap/{print Int ($3/$2*100)} ''else SWAP = 0 fiMailTitle = "server memory alarm "; if [$ Usedtotal-gt $ MAX_mem-o $ SWAP-gt $ MAX_swap]; then 'ps auxw | head-1; ps auxw | sort-rn-k4 | head-10> memory.txt 'mailcontent = "Hi: <br> & nbsp server $ HostName ($ IP) memory usage, please pay attention to it in time. <Br> & nbsp & nbspmemory usage has exceeded $ Usedtotal %, and swap usage has exceeded $ SWAP %. <Br> & nbsp & nbspmem (buffer + cache) system allocation $ memory & nbspMB ($ LocatedMen %), actual use of $ Mem & nbspMB ($ Usedtotal %) <br> &nbsp memory usage top10input see the attached memory.txt. "; Php sendEmail. php $ MailTitle $ MailContentfi
How to monitor CPU
To be continued.
How to monitor network interfaces
To be continued.
How to monitor the motherboard
To be continued.

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

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.