Collect Linux machine information.

Source: Internet
Author: User

#!/bin/bash#=======================================================================================#                FILE:     report.sh#              usage:     bash Report.sh#        DESCRIPTION:     Copy bash style guide and coding standard .#                          the default copy example is the current text . #                         dont.t find text on other directories .#             options:    see fuction  ' usage '   below #       requirements:    ---#                BUGS:    --- #              notes:     --- #             AUTHOR:     dr.-vision. simple (SP) .#             COMPANY:    China#             VERSION:    1.0#             CREATED:    01.22.2016 - 13:15:30#            revision:    01.23.2016#             PROJECT:    XXX#           copyritht:    copyright (c) 2002-2020 shell, all rights reserved#= ====================================================================================== #If  required,  additional information has to be added  (E.g copyright note,project  assignment). Host= ' hostname ' today= ' date +%y-%m-%d ' #DATE_TIME = ' #DETECT_PATH = '/var/log/chinacache ' #DETECT_LIST = " Detect.log detectorigin.log digrun.log "#FC_CACHE_LOG =" fc-cache.log.01012093sv.chn-gx-9-3sv.20160126201857.gz "#DATA_FILE =" ${data_path}/detectorigin.log "#DATA = ' awk   '!a[$2]++ '  ${DATA_FILE}|grep -E  ' no_detect|ip_bad|ip_down ' |awk  ' {print $2 ' \ t ' $4 } ' #DATA = ' awk  '!a[$2]++ '  ${data_file}|grep -v  "|awk  ' {print $2" \ T "$4}" #DATA_LOG = ' awk  '!a[$2]++ '  ${data_file}|grep -e   "No_detect|ip_bad|ip_down" |awk  ' {print $2} ' #echo  -e  ' ${data} ' |awk  ' {printf (" domain=%s; code=%s ", $1,$2)} ' #echo   $domain   $codeDOMAIN _path="/usr/local/squid/etc "domain_file=" $ {domain_path}/domain.conf "today=" ' date +%y-%m-%d ' "log_file="/tmp/$0_${today}.log "DOMAIN=" ' Cat -An  /usr/local/squid/etc/domain.conf|awk  ' {print $1,$2,$12} ' "#RCMS  infonameid="/http/ ad.41.cn "node=" SH "# disk usedccm=" ' df -th|sed  ' 1d;/ /! n;s/\n//;s/ \+/ /; ' | nl|awk  ' {print $1} ' "Data=" ' df -th|sed  ' 1d;/ /! n;s/\n//;s/ \+/ /; ' | NL ' "used=" used= "5" iowait= "iowait=" 0.1 "#Disk  write iowddata=" ' Iostat -x |sed -e   ' 1,5d ' |nl|sed  ' 1d;/ /! n;s/\n//;s/ \+/ /; ' | awk  ' {print $1} ' "wdwait=" ' IOSTAT -X |SED -E  ' 1,5d ' |nl|sed  ' 1d;/ /! n;s/\n//;s/ \+/ /; ' ' "#DOMAIN =" www.xxx.com "count=" 3 "#   function comments#===   function      ====================================================================#           NAME:    Record Info.        #   description:    record sth info .#  parameter  1:    ---#============================================= ==========================================function record_login_ping {    printf   "\e[32m #############  is generating a report on whether the device will be logged on is available  ##############\e[0m\n"  ${used}>>${log_ file}    device_info= ' Curl ${rcmsapi_url} '     printf  '%s\n '  ${device_info}    }function record_disk_used {    printf  "\e[32m #############  is generating a hard drive using more than%%%s reports  #### ##########\e[0m\n " ${USED}>>${LOG_FILE}    printf " \e[32m ########### ##  is generating a hard drive using more than%%%s report  ##############\e[0m\n " ${USED}for id in ${CCM}do     eval  ' echo -e  ' ${data} "|awk -vid= $id   ' {if ($1==id)  print " Name= "$"; type= "$"; size= "$4" used= "$ $" avail= "$6" use= "$7";d mount= "$8}"     if [[   "$id"  ==  " ]];then        echo " $id  is  null,check failed "        exit 1     fi    disk_used=$ (echo  "${use}" |awk -f%  ' {if ($1> ' $USED ') print  $1} ')     if [[  "${disk_used}"  !=  " ]];then          printf  "\e[31m id:%s \t \e[0m\tused:%s \t \e[0m mount:\e[33m  %s\e[0m\n "  $id  ${use} ${dmount} >>${LOG_FILE}         printf  "\e[31m id:%s \t \e[0m\tused:%s \t \e[0m mount:\e[ 33m %s\e[0m\n "  $id  ${use} ${dmount}     fidone}function  record_disk_io {    printf  "\e[32m #############  is generating HDD write delay report  #### ##########\e[0m\n " >>${LOG_FILE}    printf " \e[32m #############   Generating HDD Write delay report  ##############\e[0m\n " for id in ${WDDATA}do      eval  ' echo -e  ' ${wdwait} ' |awk -vid= ' ${id} '   ' {if ($1==id)  printf (" device=%s;rrqm=%s;wrqm=%s;rs=%s;ws=%s;rsecs=%s;wsecs=%s;avgrqsz=%s;svqqusz=%s;await=%s;svctm=%s;util=%s; ", $2,$ 3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13} "if [[ " $id " == " " ]];then        echo   "$id  is null,check failed"         exit 1fi# echo  "device= $device  rrqm= $rrqm  wrqm= $wrqm  rs= $rs  ws= $ws  rsecs= $rsecs  wsecs =%s avgrqsz= $avgrqsz   #svqqusz = $svqqusz  await= $await  svctm= $svctm  util= $util "wio_wait= $ (echo  "${await}" |awk  ' {if ($1> ' $IOWAIT ') print $1} ') if [[  "${wio_wait}"  !=   " ]];then printf " \e[31m id:%s \t \e[0m\tdevice name:\e[33m%s \ T \e[0m write_io_wait (ms): \e[33m %s\e[0m\n "  $id  ${device} ${wio_wait} > >${LOG_FILE}printf  "\e[31m id:%s \t \e[0m\tdevice name:\e[33m%s \t \e[0m  write_io_wait (ms): \e[33m %s\e[0m\n "  $id  ${device} ${wio_wait} fidone}function  record_ping_time {    printf  "\e[32m #############  is in the%s to cache Latency report  ############## \e[0m\n " ${HOST}>>${LOG_FILE}    printf " \e[32m #############  is Delay report for%s to cache  ##############\e[0m\n " ${host}    data= ' ping ${domain} - C ${count} '     echo  ' ${data} ' |tail -n 2    echo   "${data}" |tail -n 2 >> "${log_file}"}function record_log {     printf  "################ start #############\n" >${LOG_FILE}     printf  "domain\tstatus\turl\t\n" >>${log_file}    for domain in   ' echo  ' ${data_log} '     do         #echo   "$domain"         eval  ' echo -e  "${data}" |awk  -vdomain= "${domain}"  ' {if ($1==domain)  printf ("domain=%s;code=%s", $1,$2)} '           #echo   $domain   $code          #eval   ' awk - Vdomain= "${domain}"   ' {if ($1==domain)  printf ("domain=%s;url=%s", $1,$11)} '  ${domain_file} '          url=$ (echo -e  ' echo -e  "$DOMAIN" |grep ${ Domain} ' |awk -f ': "  ' {print $2} ')         echo " domain= $domain \tcode=${code}\turl= ' echo  $url |awk -f ":"   "{print $2}" ' "         # awk -vdomain= "${domain}"   ' {if ($1==domain)  printf  "url =%s ", $11} '  " ${domain_file} "        echo -e " ${domain}\t ${code}\t${url} ">>${LOG_FILE}    done    printf " ########## ###### end #############\n ">>${LOG_FILE}    printf " \e[32m ################ parse  Log finished #############\e[0m\n "    printf " \e[32m  Detection result save path: Detect  file:${log_file} \e[0m\n "    }#   section comments#-------- -------------------------------------------------------------------------------#   define  shell main .#--------------------------------------------------------------------------------------- #Record_Disk_Used #record_ping_time#record_upper_time#record_disk_io#record_login_ping#if [[ -f  ${data_file} ]];then#   record_log#else#       printf   "\e[32m ################ parse log [ failed ]##############\e[0m\n" > >${LOG_FILE}#       printf  "\e[32m ################ parse  log [&nbsp Failed ]##############\e[0m\n "#       exit 1#fi#    line end comments

This article is from the "focus on background design" blog, make sure to keep this source http://xleft.blog.51cto.com/955567/1895788

Collect Linux machine information.

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.