64 lines
1.3 KiB
Bash
64 lines
1.3 KiB
Bash
#!/bin/bash
|
||
#
|
||
# System authorization information.
|
||
# SSH prevents violent cracking
|
||
# Email: aixiao@aixiao.me
|
||
# Time: 20170909
|
||
#
|
||
|
||
source /etc/profile
|
||
|
||
function init() {
|
||
SEND_MAIL=0
|
||
PWD_PATH="/root";
|
||
TIME=`date +"%Y%m%d%H%M"`;
|
||
LOG_FILE="${PWD_PATH}/${TIME}.log";
|
||
EMAIL_ADDRESS="1605227279@qq.com";
|
||
IPTABLES=$(which iptables)
|
||
|
||
IPTABLES_SAVE=$(which iptables-save)
|
||
}
|
||
|
||
function run()
|
||
{
|
||
echo "Read-Only Memory,ROM:" &>> ${LOG_FILE}
|
||
df -am &>> ${LOG_FILE}
|
||
|
||
echo "random access memory,RAM:" &>> ${LOG_FILE}
|
||
free -hl &>> ${LOG_FILE}
|
||
|
||
echo "System process:" &>> ${LOG_FILE}
|
||
ps -auxwwjf &>> ${LOG_FILE}
|
||
|
||
echo "Network Connections" &>> ${LOG_FILE}
|
||
netstat -tnulp &>> ${LOG_FILE}
|
||
|
||
echo "System SSH authorization information:" &>> ${LOG_FILE}
|
||
/root/denyhosts/rhost | awk '{a[$1]+=1;} END {for(i in a){print a[i]" "i;}}' &>> ${LOG_FILE}
|
||
|
||
$IPTABLES_SAVE > /root/ipv4tables
|
||
|
||
echo "" &>> ${LOG_FILE}
|
||
echo "Iptables filter table" &>> ${LOG_FILE}
|
||
$IPTABLES -L -n --line-numbers &>> ${LOG_FILE}
|
||
echo "" &>> ${LOG_FILE}
|
||
|
||
if test $SEND_MAIL = 1; then
|
||
mail -s "System Log" ${EMAIL_ADDRESS} < ${LOG_FILE}
|
||
rm ${LOG_FILE}
|
||
fi
|
||
|
||
sync
|
||
}
|
||
|
||
|
||
init;
|
||
run;
|
||
exit 0;
|
||
20190103
|
||
20190911
|
||
20191008
|
||
20210614
|
||
aixiao@aixiao.me
|
||
|