Transform Ctrl+alt+del (default reboot) as a script for information collection scripts _linux

Source: Internet
Author: User
Tags iptables
A, the first press Ctrl+alt+del after 60 seconds and then invalid, after the execution of the N-multi-information collection operations will be the firewall deactivated, sshd service restart;
b, if still not connected to the server, then continue to let the engine room engineer Press Ctrl+alt+del machine will really restart.
The specific job steps are as follows:
1, first modify the current/etc/inittab file, and change the default reboot to execute/root/checksystem.sh
Copy Code code as follows:

Sed-i ' s#ca\:\:ctrlaltdel\:\/sbin\/shutdown\ \-t3\ \-r\ now#ca\:\:ctrlaltdel\:\/bin\/sh\ \/root\/checksystem\.sh# '/ Etc/inittab

2, and then use the command "Init Q" to overload the file
Copy Code code as follows:

Init q

3, next create/root/checksystem.sh this script file. Content as follows, the specific meaning of the unknown, we can enrich their content.
Copy Code code as follows:

#!/bin/bash
#History
#2011 -04-28 Caoyameng ver1.0
#
Test-e/root/systeminfo_lock && Exit 0
Touch/root/systeminfo_lock
TEST-E/root/systeminfo &&/bin/mv/root/systeminfo/root/systeminfo_bak
echo "# #1" >>/root/systeminfo
Date >>/root/systeminfo
echo "# #2" >>/root/systeminfo
Df-h >>/root/systeminfo
echo "# #3" >>/root/systeminfo
Free-m >>/root/systeminfo
echo "# #4" >>/root/systeminfo
Iostat >>/root/systeminfo
echo "# #5" >>/root/systeminfo
W >>/root/systeminfo
echo "# #6" >>/root/systeminfo
NETSTAT-LNTP >>/root/systeminfo
/sbin/ifconfig >>/root/systeminfo
echo "# #7" >>/root/systeminfo
Iptables-l >>/root/systeminfo
echo "# #8" >>/root/systeminfo
Ping-c 2-w 2 127.0.0.1 >>/root/systeminfo
Ping-c 2-w 2 is converted to eth0 IP >>/root/systeminfo
Ping-c 2-w 2 is changed here to eth1 IP (if there is eth1) >>/root/systeminfo
Ping-c 2-w 2 www.linuxtone.org >>/root/systeminfo
echo "# #9" >>/root/systeminfo
Route-n >>/root/systeminfo
echo "# #10" >>/root/systeminfo
/etc/init.d/iptables stop
echo "# #11" >>/root/systeminfo
/etc/init.d/sshd restart
/etc/init.d/network restart
####################
Sleep 60
Sed-i ' s#ca\:\:ctrlaltdel\:\/bin\/sh\ \/root\/checksystem\.sh#ca\:\:ctrlaltdel\:\/sbin\/shutdown\ \-t3\ \-r\ now# '/ Etc/inittab
Rm-f/root/systeminfo_lock
Init q

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.