Linux system monitoring shell script

Source: Internet
Author: User

The code below, implements some common monitoring variables of the Linux system, shares to everybody @. [Email protected]

#=============================# #Filename=system_monitor.SH#Author: foxsir#date: .- Geneva- the#=============================##!/bin/SHClearif[[$#-eq0 ]] Then#Define Variable reset_terminal reset_terminal=$ (tput sgr0) #Check os Type os=$(uname-o)Echo-E'\e[36m' "Operating System Type:"$Reset _terminal $OS #check OS realease Version and Name os_name=$(Cat/etc/issue |grep "Server")    Echo-E'\e[36m' "Operating System realease Version:"$Reset _terminal $OS _name#check Architecture Architecture=$(uname-m)Echo-E'\e[36m' "Operating System Architecture:"$Reset _terminal $Architecture #check Kernel realease kernel_realease=$(uname-R)Echo-E'\e[36m' "Operating System Kernel realease:"$Reset _terminal $Kernel _realease#check Hostname Hostname=$(hostname)    Echo-E'\e[36m' "Operating System Hostname:"$Reset _terminal $Hostname #check Internal IP internal_ip=$(hostname-I)Echo-E'\e[36m' "Operating System Internal IP:"$Reset _terminal $Internal _ip#check External IP external_ip=$ (curl-s http://Ipecho.net/plain)    Echo-E'\e[36m' "Operating System External IP:"$Reset _terminal $External _ip#check DNS DNS=$(Cat/etc/resolv.conf |grep "/<nameserver[]+"|awk '{print $NF}')    Echo-E'\e[36m' "Operating System DNS:"$Reset _terminal $DNS #checkifconnected to the Internet Or notPing-C2 www.baidu.com &>/dev/NULL&&Echo-E'\e[36m' "internet:connected"||Echo '\e[36m' "internet:failed"#Check logged in UsersW.H.O.>/tmp/W.H.O.    Echo-E'\e[36m' "Operating System lgged in Users:"$Reset _terminal &&Cat/tmp/W.H.O.    RM-f/tmp/W.H.O.#Check OS Memory useragesEcho-E'\e[36m' "Operating System Memory userages:"$Reset _terminal $ (Cat/proc/meminfo |awk '/^memtotal/{memtotal=$2}/^memfree/{memfree=$2}end {print (memtotal-memfree)/1024, "M"}') #Check App Memory useragesEcho-E'\e[36m' "App Memory userages:"$Reset _terminal $ (Cat/proc/meminfo |awk '/^memtotal/{memtotal=$2}/^memfree/{memfree=$2}/^buffers/{buffers=$2}/^cached/{cached=$2}end {print ( memtotal-memfree-buffers-cached)/1024, "M"}') #Check OS loadaverageEcho-E'\e[36m' "Operating System loadaverage:"$Reset _terminal $ (top-n1b |grep "Load Average"|awk '{print $ (NF-2) $ (NF-1) $NF}') #Check OS diskaverageEcho-E'\e[36m' "Operating System diskaverage:"$Reset _terminal $ (DF-HP |grep-ve"%%|tmpfs"|awk '{print $1,$5}') #Check OS RuntimeEcho-E'\e[36m' "Operating System Runtime:"$Reset _terminal $ (top-n1b |grep "Load Average"|awk-F"[ ,]+" '{print $}')fi

Linux system monitoring shell script

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.