CentOS 6 system optimization detection script

Source: Internet
Author: User

CentOS 6 system optimization detection script

Keep up with the above CentOS 6 system optimization script, because sometimes a virtual machine has been flushed with the optimization script, but this virtual machine may be temporarily shelved for other reasons. After waiting for a while, it will take some time for you to suddenly use it and you don't know if this virtual machine has been optimized. It will take some time to re-use cobbler to fl the system, therefore, the shell script used to check whether the system has flushed the optimization script is born. The script is not very accurate, but it can be checked for the last optimization script. If the script has been flushed, it will be known that the system has been optimized by running the script and can be put into use immediately, avoid wasting time refresh the system. If it is a fully reinstalled CentOS 6.x, the result can also be seen that the virtual machine has not been optimized, then execute the optimization script to optimize it once.

#!/bin/bash ##################################################################################### #ThescriptisusedtocheckwhethertheoptimizescripthadbeenrunonCentOS6.x #CreatedbyJerry12356onMay16th,2016 ##################################################################################### . /etc/init .d /functions check_iptables(){ /etc/init .d /iptables status> /dev/null 2>&1 [$?- ne 0]&&action "Optimizeiptables:" /bin/true ||action "Optimizeiptables:" /bin/false } check_selinux(){ selinux_status=`getenforce` [$selinux_status== 'Disabled' ]&&action "Optimizeselinux:" /bin/true ||action "Optimizeselinux:" /bin/false } check_addusers(){ egrep "admin|nginx|zabbix" /etc/passwd >> /dev/null 2>&1 [$?- eq 0]&&action "Addusers:" /bin/true ||action "Addusers:" /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 "Installsoftwares:" /bin/true ||action "Installsoftwares:" /bin/false } check_repos(){ [-d /etc/yum .repos.d /bak ]&&action "Updaterepos:" /bin/true ||action "Updaterepos:" /bin/false } check_time(){ date -R| grep +0800> /dev/null 2>&1 [$?- eq 0]&&action "Settingtimezone:" /bin/true ||action "Settingtimezone:" /bin/false crond_num=` crontab -l| grep ntpdate| wc -l` [$crond_num- ge 1]&&action "Synctime:" /bin/true ||action "Synctime:" /bin/false } check_services(){ service_num=`chkconfig--list| grep 3:on| egrep "crond|network|rsyslog|sshd" | wc -l` [$service_num- eq 4]&&action "Optimizeservices:" /bin/true ||action "Optimizeservices:" /bin/false } check_history(){ [$HISTSIZE- eq 10000]&&action "Settinghistory:" /bin/true ||action "Settinghistory:" /bin/false } check_kernel(){ conn_num=` ulimit -n` [$conn_num- eq 2097152]&&action "Optimizekernel:" /bin/true ||action "Optimizekernel:" /bin/false } check_hostname(){ [$HOSTNAME!= 'localhost.localdomain' ]&&action "Changehostname:" /bin/true ||action "Changehostname:" /bin/false } check_iptables check_selinux check_addusers check_install check_repos check_time check_services check_history check_kernel check_hostname

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.