#!/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/xxx" #DETECT_LIST="detect.log detectorigin.log digRun.log" #FC_CACHE_LOG="xxx.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 "200"|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 $code DOMAIN_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 INFO NAMEID="http://ad.41.cn" NODE="SH" # Disk Used CCM="`df -Th|sed '1d;/ /!N;s/\n//;s/ \+/ /;'|nl|awk '{print $1}'`" DATA="`df -Th|sed '1d;/ /!N;s/\n//;s/ \+/ /;'|nl`" USED="85" USED="5" IOWAIT="300" IOWAIT="0.1" #Disk Write IO WDDATA="`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 ############# 正在生成将要登录设备是否可用的报告 ##############\e[0m\n" ${USED}>>${LOG_FILE} DEVICE_INFO=`curl ${RCMSAPI_URL}` printf "%s\n" ${DEVICE_INFO} } function Record_Disk_Used { printf "\e[32m ############# 正在生成硬盘使用超过%%%s的报告 ##############\e[0m\n" ${USED}>>${LOG_FILE} printf "\e[32m ############# 正在生成硬盘使用超过%%%s的报告 ##############\e[0m\n" ${USED} for id in ${CCM} do eval `echo -e "${DATA}"|awk -vid=$id '{if($1==id) print "name="$2";type="$3";size="$4";used="$5";avail="$6";use="$7";dmount="$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} fi done } function Record_Disk_IO { printf "\e[32m ############# 正在生成硬盘写延时报告 ##############\e[0m\n" >>${LOG_FILE} printf "\e[32m ############# 正在生成硬盘写延时报告 ##############\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 1 fi #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} fi done } function Record_Ping_Time { printf "\e[32m ############# 正在%s到Cache的延时报告 ##############\e[0m\n" ${HOST}>>${LOG_FILE} printf "\e[32m ############# 正在%s到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 探测结果保存路径: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 [ Failed ]##############\e[0m\n" # exit 1 #fi # line end comments
收集Linux机器信息。
原创
©著作权归作者所有:来自51CTO博客作者在你的左边的原创作品,请联系作者获取转载授权,否则将追究法律责任
上一篇:Python编程模板
下一篇:Https证书平台功能
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
Python 实现Linux Raid信息监控
python脚本监控linux raid
zabbix raid python -
信息收集(二)IP信息收集
内容分发网络(CDN): 是指企业利用分布在不同区域的节点服务器群组成流量分配管理平
tcp/ip 网络 服务器 网络安全 安全 -
信息收集(一)域名信息收集
域名(英语:Domain Name),又称网域,是由一串用点分隔的名字组成的Internet上某一台
服务器 网络 linux 网络安全 安全 -
Kali Linux信息收集与侦查
通过使用Kali Linux中的工具和技术,我们可以有效地获取目标系统的关键信息,评估其安全性,并发现潜在的漏洞和风险。通过对目标网络进行扫描和
linux 运维 服务器 Kali 目标系统 -
信息收集之DNS信息收集 -- dnstracer
如何快速查看一条DNS查询都经过了哪些DNS服务器?试试dnstracer吧,一款让你发现更多目标的工具。
域名信息收集 dnstracer neg