ipaddress=`ip a|grep "global"|awk '{print $2}' |awk -F/ '{print $1}'`
file_output='os_linux_summary.html'
echo -e
"" border="1" bordercolor=" echo -e
"" border="1" bordercolor=" td_str=`echo $1 | awk 'BEGIN{FS="|"}''{i=1; while(i<=NF) {print "
"$i" | ";i++}}'` th_str=`echo $1|awk 'BEGIN{FS="|"}''{i=1; while(i<=NF) {print "
"$i" | ";i++}}'` echo -e
"
" >> $file_output echo -e
"
" >> $file_output echo -e
" |
" >> $file_output
" printf "%+*s | %s\n" "${NAME_VAL_LEN}" "$1" "$2"
name_val "主机名" "`uname -n`"
name_val "系统版本" "`cat /etc/{oracle,redhat,SuSE,centos}-release 2>/dev/null|sort -ru|head -n1`"
name_val "内核版本" "`uname -r`"
name_val "架构" "CPU=`lscpu|grep Architecture|awk -F: '{print $2}'|sed 's/^[[:space:]]*//g'`;OS=`getconf LONG_BIT`-bit"
virtual=`grep -c ^processor "${file}"`
physical=`grep 'physical id' "${file}" | sort -u | wc -l`
cores=`grep 'cpu cores' "${file}" | head -n 1 | cut -d: -f2`
model=`grep "model name" "${file}"|sort -u|awk -F: '{print $2}'`
speed=`grep -i "cpu MHz" "${file}"|sort -u|awk -F: '{print $2}'`
cache=`grep -i "cache size" "${file}"|sort -u|awk -F: '{print $2}'`
SysCPUIdle=`vmstat | sed -n '$ p' | awk '{print $15}'`
[ "${physical}" = "0" ] && physical="${virtual}"
[ -z "${cores}" ] && cores=0
cores=$((${cores} * ${physical}));
if [ ${cores} -gt 0 -a $cores -lt $virtual ]; then htt=yes; else htt=no; fi
name_val "线程" "physical = ${physical}, cores = ${cores}, virtual = ${virtual}, hyperthreading = ${htt}"
name_val "cpu型号" "${physical}*${model}"
name_val "速度" "${virtual}*${speed}"
name_val "缓存" "${virtual}*${cache}"
name_val "CPU空闲率(%)" "${SysCPUIdle}%"
echo "interface | status | ipadds | mtu | Speed | Duplex" >>/tmp/tmpnet_h1_`date +%y%m%d`.txt
for ipstr in `ifconfig -a|grep ": flags"|awk '{print $1}'|sed 's/.$//'`
ipadds=`ifconfig ${ipstr}|grep -w inet|awk '{print $2}'`
mtu=`ifconfig ${ipstr}|grep mtu|awk '{print $NF}'`
speed=`ethtool ${ipstr}|grep Speed|awk -F: '{print $2}'`
duplex=`ethtool ${ipstr}|grep Duplex|awk -F: '{print $2}'`
echo "${ipstr}" "up" "${ipadds}" "${mtu}" "${speed}" "${duplex}"\
|awk '{print $1,"|", $2,"|", $3,"|", $4,"|", $5,"|", $6}' >>/tmp/tmpnet1_`date +%y%m%d`.txt
echo "####################################### cpu使用率 #######################################" >>/tmp/tmp_cpuuse_`date +%y%m%d`.txt
mpstat -P ALL 10 6 >>/tmp/tmp_cpuuse_`date +%y%m%d`.txt
filemax=`cat /proc/sys/fs/file-max`
name_val "Number of concurrent connections" "${filemax}"
echo "####################################### 系统限制最大进程数 #######################################" >>/tmp/tmp_ulimitinfo_`date +%y%m%d`.txt
ulimit -a >>/tmp/tmp_ulimitinfo_`date +%y%m%d`.txt
echo "Locator |Size |Speed |Form Factor | Type | Type Detail" >>/tmp/tmpmem3_h1_`date +%y%m%d`.txt
dmidecode| grep -v "Memory Device Mapped Address"|grep -A12 -w "Memory Device" \
|egrep "Locator:|Size:|Speed:|Form Factor:|Type:|Type Detail:" \
|awk -F: '/Size|Type|Form.Factor|Type.Detail|^[\t ]+Locator/{printf("|%s", $2)}/^[\t ]+Speed/{print "|" $2}' \
|grep -v "No Module Installed" \
|awk -F"|" '{print $4,"|", $2,"|", $7,"|", $3,"|", $5,"|", $6}' >>/tmp/tmpmem3_t1_`date +%y%m%d`.txt
free -glht >>/tmp/tmpmem2_`date +%y%m%d`.txt
memtotal=`vmstat -s | head -1 | awk '{print $1}'`
avm=`vmstat -s| sed -n '3p' | awk '{print $1}'`
name_val "Mem_used_rate(%)" "`echo "100*${avm}/${memtotal}" | bc`%" >>/tmp/tmpmem1_`date +%y%m%d`.txt
echo "Filesystem |Type |Size | Used | Avail | Use% | Mounted on | Opts" >>/tmp/tmpdisk_h1_`date +%y%m%d`.txt
df -ThP|grep -v tmpfs|sed '1d'|sort >/tmp/tmpdf1_`date +%y%m%d`.txt
mount -l|awk '{print $1,$6}'|grep ^/|sort >/tmp/tmpdf2_`date +%y%m%d`.txt
join /tmp/tmpdf1_`date +%y%m%d`.txt /tmp/tmpdf2_`date +%y%m%d`.txt\
|awk '{print $1,"|", $2,"|", $3,"|", $4,"|", $5,"|", $6,"|", $7,"|", $8}' >>/tmp/tmpdisk_t1_`date +%y%m%d`.txt
lsblk >>/tmp/tmpdisk1_`date +%y%m%d`.txt
for disk in `ls -l /sys/block|awk '{print $9}'|sed '/^$/d'|grep -v fd`
echo "${disk}" `cat /sys/block/${disk}/queue/scheduler` >>/tmp/tmpdisk2_`date +%y%m%d`.txt
pvs >>/tmp/tmpdisk3_`date +%y%m%d`.txt
echo "====================== ===== ===== ===== ===== ===== ========== =======" >>/tmp/tmpdisk3_`date +%y%m%d`.txt
vgs >>/tmp/tmpdisk3_`date +%y%m%d`.txt
echo "====================== ===== ===== ===== ===== ===== ========== =======" >>/tmp/tmpdisk3_`date +%y%m%d`.txt
lvs >>/tmp/tmpdisk3_`date +%y%m%d`.txt
echo "####################################### 网络流量情况 #######################################" >>/tmp/tmpload_`date +%y%m%d`.txt
sar -n DEV 10 6 >>/tmp/tmpload_`date +%y%m%d`.txt
echo "####################################### 系统资源变化 #######################################" >>/tmp/tmpload_`date +%y%m%d`.txt
vmstat -S M 10 6 >>/tmp/tmpload_`date +%y%m%d`.txt
mpstat 1 5 >>/tmp/tmptopcpu_`date +%y%m%d`.txt
echo "####################################### 消耗CPU前十排行 #######################################" >>/tmp/tmptopcpu_`date +%y%m%d`.txt
ps aux|head -1 >>/tmp/tmptopcpu_`date +%y%m%d`.txt
ps aux|grep -v PID|sort -rn -k +3|head >>/tmp/tmptopcpu_`date +%y%m%d`.txt
echo "####################################### 消耗内存前十排行 #######################################" >>/tmp/tmptopmem_`date +%y%m%d`.txt
ps aux|head -1 >>/tmp/tmptopmem_`date +%y%m%d`.txt
ps aux|grep -v PID|sort -rn -k +4|head >>/tmp/tmptopmem_`date +%y%m%d`.txt
echo "TOP10 CPU Resource Process" >>/tmp/tmptopmem_`date +%y%m%d`.txt
top -bn1 -o "%CPU"|sed -n '1,17p'
echo "####################################### 磁盘io情况 #######################################" >>/tmp/tmptopio_`date +%y%m%d`.txt
iostat -k -d 10 5 >>/tmp/tmptopio_`date +%y%m%d`.txt
crontab -l >>/tmp/tmp_crontab_`date +%y%m%d`.txt
if [ -s /tmp/tmp_crontab_`date +%y%m%d`.txt ] ; then
echo 'ths file is not empyt and file info'
echo '#### 无定时任务 ####' >>/tmp/tmp_crontab_`date +%y%m%d`.txt
create_html_css >> $file_output
create_html_head "系统基本信息" >> $file_output
create_table_head1 >> $file_output
get_physics >>/tmp/tmpos_summ_`date +%y%m%d`.txt
done < /tmp/tmpos_summ_`date +%y%m%d`.txt
create_table_end >> $file_output
create_html_head "cpu信息" >> $file_output
create_table_head1 >> $file_output
get_cpuinfo >>/tmp/tmp_cpuinfo_`date +%y%m%d`.txt
done < /tmp/tmp_cpuinfo_`date +%y%m%d`.txt
create_table_end >> $file_output
create_html_head "ip网络信息" >> $file_output
create_table_head1 >> $file_output
done < /tmp/tmpnet_h1_`date +%y%m%d`.txt
done < /tmp/tmpnet1_`date +%y%m%d`.txt
create_table_end >> $file_output
create_html_head "cpu使用率" >> $file_output
create_table_head1 >> $file_output
create_tr3 "/tmp/tmp_cpuuse_`date +%y%m%d`.txt"
create_table_end >> $file_output
create_html_head "连接数信息" >> $file_output
create_table_head1 >> $file_output
get_connections >>/tmp/tmp_connections_`date +%y%m%d`.txt
done < /tmp/tmp_connections_`date +%y%m%d`.txt
create_table_end >> $file_output
create_html_head "系统限制信息" >> $file_output
create_table_head1 >> $file_output
create_tr3 "/tmp/tmp_ulimitinfo_`date +%y%m%d`.txt"
create_table_end >> $file_output
create_html_head "内存使用信息" >> $file_output
create_table_head1 >> $file_output
done < /tmp/tmpmem1_`date +%y%m%d`.txt
create_table_end >> $file_output
create_table_head1 >> $file_output
create_tr3 "/tmp/tmpmem2_`date +%y%m%d`.txt"
create_table_end >> $file_output
create_table_head1 >> $file_output
done < /tmp/tmpmem3_h1_`date +%y%m%d`.txt
done < /tmp/tmpmem3_t1_`date +%y%m%d`.txt
create_table_end >> $file_output
create_html_head "磁盘使用信息" >> $file_output
create_table_head1 >> $file_output
done < /tmp/tmpdisk_h1_`date +%y%m%d`.txt
done < /tmp/tmpdisk_t1_`date +%y%m%d`.txt
create_table_end >> $file_output
create_table_head1 >> $file_output
create_tr3 "/tmp/tmpdisk1_`date +%y%m%d`.txt"
create_table_end >> $file_output
create_table_head1 >> $file_output
create_tr3 "/tmp/tmpdisk2_`date +%y%m%d`.txt"
create_table_end >> $file_output
create_table_head1 >> $file_output
create_tr3 "/tmp/tmpdisk3_`date +%y%m%d`.txt"
create_table_end >> $file_output
create_html_head "网络流量情况" >> $file_output
create_table_head1 >> $file_output
create_tr3 "/tmp/tmpload_`date +%y%m%d`.txt"
create_table_end >> $file_output
create_html_head "消耗CPU前十排行" >> $file_output
create_table_head1 >> $file_output
create_tr3 "/tmp/tmptopcpu_`date +%y%m%d`.txt"
create_table_end >> $file_output
create_html_head "消耗内存前十排行" >> $file_output
create_table_head1 >> $file_output
create_tr3 "/tmp/tmptopmem_`date +%y%m%d`.txt"
create_table_end >> $file_output
create_html_head "磁盘io情况" >> $file_output
create_table_head1 >> $file_output
create_tr3 "/tmp/tmptopio_`date +%y%m%d`.txt"
create_table_end >> $file_output
create_html_head "定时任务信息" >> $file_output
create_table_head1 >> $file_output
create_tr3 "/tmp/tmp_crontab_`date +%y%m%d`.txt"
create_table_end >> $file_output
create_html_end >> $file_output
sed -i 's/BORDER=1/width="68%" border="1" bordercolor="#000000" cellspacing="0px" style="border-collapse:collapse"/g' $file_output
rm -rf /tmp/tmp*_`date +%y%m%d`.txt
RUID=`id|awk -F\( '{print $1}'|awk -F\= '{print $2}'`
if [ ${RUID} != "0" ];then
echo"This script must be executed as root"
if [ ${PLATFORM} = "HP-UX" ] ; then
echo "This script does not support HP-UX platform for the time being"
elif [ ${PLATFORM} = "SunOS" ] ; then
echo "This script does not support SunOS platform for the time being"
elif [ ${PLATFORM} = "AIX" ] ; then
echo "This script does not support AIX platform for the time being"
elif [ ${PLATFORM} = "Linux" ] ; then
在linux启动脚本,会生成 os_linux_summary.html文件
-
相关阅读:
Next.js 热更新 Markdown 文件变更
TypeScript基础常用知识点总结
基于深度学习的图像生成与识别技术研究
telnet 连接闪退
temporal shift module(TSM)
Twitter群推解锁流量大门的钥匙
Blender 插件
聊聊流式数据湖Paimon(三)
python-Matplotlib画图那些你不知道的事
RHCE(五)HTTP、SSL协议综合实验
-
原文地址:https://blog.csdn.net/qq_37989070/article/details/133052077