CentOS7.x 系统巡检脚本
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CentOS7.x 系统巡检脚本相关的知识,希望对你有一定的参考价值。
#!/bin/bash ############################################################## # File Name: CenOS7.sh # Version: V1.0 # Author: # Organization: # Created Time : date # Description: ############################################################## export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin source /etc/profile [ $(id -u) -gt 0 ] && echo "请用root用户执行此脚本!" && exit 1 #uploadHostDailyCheckApi="http://10.0.0.1:8080/api/uploadHostDailyCheck" #uploadHostDailyCheckReportApi="http://10.0.0.1:8080/api/uploadHostDailyCheckReport" centosVersion=$(awk '{print $(NF-1)}' /etc/redhat-release) VERSION=`date +%F` #日志相关 PROGPATH=`echo $0 | sed -e 's,[\/][^\/][^\/]*$,,'` [ -f $PROGPATH ] && PROGPATH="." LOGPATH="$PROGPATH/log" [ -e $LOGPATH ] || mkdir $LOGPATH RESULTFILE="$LOGPATH/HostDailyCheck-`hostname`-`date +%Y%m%d`.txt" #定义报表的全局变量 report_DateTime="" report_Hostname="" report_OSRelease="" report_Kernel="" report_Language="" report_LastReboot="" report_Uptime="" report_CPUs="" report_CPUType="" report_Arch="" report_MemTotal="" report_MemFree="" report_MemUsedPercent="" report_DiskTotal="" report_DiskFree="" report_DiskUsedPercent="" report_InodeTotal="" report_InodeFree="" report_InodeUsedPercent="" report_IP="" report_MAC="" report_Gateway="" report_DNS="" report_Listen="" report_Selinux="" report_Firewall="" report_USERs="" report_USEREmptyPassword="" report_USERTheSameUID="" report_PasswordExpiry="" report_RootUser="" report_Sudoers="" report_SSHAuthorized="" report_SSHDProtocolVersion="" report_SSHDPermitRootLogin="" report_DefunctProsess="" report_SelfInitiatedService="" report_SelfInitiatedProgram="" report_RuningService="" report_Crontab="" report_Syslog="" report_SNMP="" report_NTP="" report_JDK="" function version(){ echo "" echo "" echo "系统巡检脚本:Version $VERSION" } function getCpuStatus(){ echo "" echo -e "