CentOS 6 系統最佳化檢測指令碼

來源:互聯網
上載者:User

標籤:系統最佳化   shell   optimize   centos   檢測   指令碼   

緊承上文《CentOS 6系統最佳化指令碼》,因為有時候一台虛擬機器已經刷過了最佳化指令碼,但是可能因為別的原因,這台虛擬機器暫時擱置了。等過了一段時間之後,突然要用又不知道這台虛擬機器是否已經最佳化過了,而重新使用cobbler刷一次系統又會耗費一定的時間,所以這個檢測系統是否刷過最佳化指令碼的shell指令碼就誕生了。指令碼不是特別準確,但是能針對上次的最佳化指令碼做一個檢查,如果已經刷過指令碼,就會通過運行該指令碼知道系統已經最佳化過了,可以立即投入使用,避免浪費時間重新再刷一次系統。如果是一個完全重新安裝的CentOS 6.x,那結果也可以看出該虛擬機器並未最佳化過,那麼執行最佳化指令碼最佳化一次即可。

#!/bin/bash######################################################################################The script is used to check whether the optimize script had been run on CentOS 6.x#Created by Jerry12356 on May 16th, 2016#####################################################################################. /etc/init.d/functionscheck_iptables(){     /etc/init.d/iptables status  >/dev/null 2>&1 [ $? -ne 0 ] && action "Optimize iptables: " /bin/true || action "Optimize iptables: " /bin/false}check_selinux(){     selinux_status=`getenforce` [ $selinux_status == ‘Disabled‘ ] && action "Optimize selinux: " /bin/true || action "Optimize selinux: " /bin/false}check_addusers(){     egrep "admin|nginx|zabbix" /etc/passwd  >>/dev/null 2>&1 [ $? -eq 0 ] && action "Add users: " /bin/true || action "Add users: " /bin/false}check_install(){     rpm -qa|egrep "gcc|gcc-c++|openssh-clients|wget|make|cmake|curl|finger|nmap|tcp_wrappers|expect|lrzsz|unzip|zip|xz|ntpdate|lsof|telnet|vim|tree" >/dev/null 2>&1  [ $? -eq 0 ] && action "Install softwares: " /bin/true || action "Install softwares: " /bin/false}check_repos(){     [ -d /etc/yum.repos.d/bak ] && action "Update repos: " /bin/true || action "Update repos: " /bin/false }check_time(){     date -R |grep +0800 >/dev/null 2>&1 [ $? -eq 0 ] && action "Setting timezone: " /bin/true || action "Setting timezone: " /bin/false     crond_num=`crontab -l|grep ntpdate|wc -l` [ $crond_num -ge 1 ] && action "Sync time: " /bin/true || action "Sync time: " /bin/false }check_services(){     service_num=`chkconfig --list |grep 3:on|egrep "crond|network|rsyslog|sshd"|wc -l` [ $service_num -eq 4 ] && action "Optimize services: " /bin/true || action "Optimize services: " /bin/false} check_history(){     [ $HISTSIZE -eq 10000 ] && action "Setting history: " /bin/true || action "Setting history: " /bin/false}  check_kernel(){     conn_num=`ulimit -n` [ $conn_num -eq 2097152 ] && action "Optimize kernel: " /bin/true || action "Optimize kernel: " /bin/false} check_hostname(){     [ $HOSTNAME != ‘localhost.localdomain‘ ] && action "Change hostname: " /bin/true || action "Change hostname: " /bin/false}   check_iptablescheck_selinuxcheck_adduserscheck_installcheck_reposcheck_timecheck_servicescheck_historycheck_kernelcheck_hostname


本文出自 “IT小二郎” 部落格,請務必保留此出處http://jerry12356.blog.51cto.com/4308715/1839284

CentOS 6 系統最佳化檢測指令碼

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.