Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
ppabc committed Sep 2, 2016
1 parent 5b55840 commit 597b03c
Show file tree
Hide file tree
Showing 6 changed files with 147 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ kjyw

这里面的脚本是运维经常使用的脚本,方便大家使用!

相关使用文档:https://github.com/aqzt/kjyw/wiki

如果您有好用的脚本,希望一起来分享,可以联系邮件ppabc#qq.com,

微信关注https://github.com/aqzt
Expand Down
14 changes: 14 additions & 0 deletions shell/clean_haraka_logs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
## clean_haraka_logs 2016-09-02
## http://www.aqzt.com
## email: [email protected]
## robert yu
## ubuntu

#!/bin/bash
date=`date -d "-1 day" +%Y%m%d`
mkdir /data/haraka/$date/
mv /var/log/haraka.log /data/haraka/$date/haraka.log.$date
/etc/init.d/haraka restart
find /data/haraka/ -name "20*" -type d -mtime +3|tee -a /home/haraka_del.txt|xargs rm -r 2>>/home/haraka_err.txt
echo ok
32 changes: 32 additions & 0 deletions shell/clean_logs_centos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash
## clean_logs 2016-09-02
## http://www.aqzt.com
## email: [email protected]
## robert yu
## centos 6

rm -rf /var/log/audit/audit.*
rm -rf /var/log/secure-*
rm -rf /var/log/messages-*
rm -rf /var/log/spooler-*
rm -rf /var/log/yum.log-*
rm -rf /var/log/maillog-*
rm -rf /var/log/cron-*
rm -rf /var/log/btmp-*
rm -rf /var/log/dracut.log-*
rm -rf /var/log/dmesg.old

cat /dev/null > /root/.bash_history
cat /dev/null > /var/log/anaconda.syslog
cat /dev/null > /var/log/anaconda.xlog
cat /dev/null > /var/log/dmesg
cat /dev/null > /var/log/lastlog
cat /dev/null > /var/log/syslog
cat /dev/null > /var/log/wtmp
cat /dev/null > /var/log/btmp
cat /dev/null > /var/log/maillog
cat /dev/null > /var/log/messages
cat /dev/null > /var/log/maillog
cat /dev/null > /var/log/secure
cat /dev/null > /var/log/cron
history -c
26 changes: 26 additions & 0 deletions shell/clean_logs_ubuntu.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
## clean_logs 2016-09-02
## http://www.aqzt.com
## email: [email protected]
## robert yu
## ubuntu

rm -rf /var/log/alternatives.log.*
rm -rf /var/log/auth.log.*
rm -rf /var/log/dmesg.*
rm -rf /var/log/dpkg.log.*
rm -rf /var/log/kern.log.*
rm -rf /var/log/syslog.*
rm -rf /var/log/ufw.log.*
rm -rf /var/log/wtmp.*
rm -rf /var/log/upstart/*.gz
rm -rf /var/log/upstart/*.log
cat /dev/null > /root/.bash_history
cat /dev/null > /var/log/dmesg
cat /dev/null > /var/log/lastlog
cat /dev/null > /var/log/syslog
cat /dev/null > /var/log/wtmp
cat /dev/null > /var/log/mail.log
cat /dev/null > /var/log/faillog
cat /dev/null > /var/log/udev
history -c
10 changes: 10 additions & 0 deletions shell/for.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,13 @@ done

##批量修改文件后缀,conf改cfg
for i in *.conf;do mv $i $(sed "s/conf/cfg/" <<<$i);done


##for循环每秒执行脚本
#!/bin/bash
while true; do
sudo sh /data/shell/check_slave.sh
sleep 1
done


63 changes: 63 additions & 0 deletions shell/system_status/System_info.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/bin/bash
disk_info ()
{
echo "======================disk info========================"
df -ThP|column -t
}

cpu_info ()
{
echo "=======================cpu info========================"
echo "cpu processor is $(grep "processor" /proc/cpuinfo |wc -l)"
echo "cpu mode name is $(grep "model name" /proc/cpuinfo |uniq|awk '{print $4,$5,$6,$7,$8,$9}')"
grep "cpu MHz" /proc/cpuinfo |uniq |awk '{print $1,$2":"$4}'
awk '/cache size/ {print $1,$2":"$4$5}' /proc/cpuinfo |uniq
}

mem_info ()
{
echo "=====================memory info========================"
MemTotal=$(awk '/MemTotal/ {print $2}' /proc/meminfo)
MemFree=$(awk '/MemFree/ {print $2}' /proc/meminfo)
Buffers=$(awk '/^Buffers:/ {print $2}' /proc/meminfo)
Cached=$(awk '/^Cached:/ {print $2}' /proc/meminfo)
FreeMem=$(($MemFree/1024+$Buffers/1024+$Cached/1024))
UsedMem=$(($MemTotal/1024-$FreeMem))
echo "Total memory is $(($MemTotal/1024)) MB"
echo "Free memory is ${FreeMem} MB"
echo "Used memory is ${UsedMem} MB"
}

load_info ()
{
echo "=====================load info=========================="
Load1=$(awk '{print $1}' /proc/loadavg)
Load5=$(awk '{print $2}' /proc/loadavg)
Load10=$(awk '{print $3}' /proc/loadavg)
echo "Load in 1 min is $Load1"
echo "Load in 5 min is $Load5"
echo "Load in 10 min is $Load10"
}

network_info ()
{
echo "=====================network info======================="
network=$(ifconfig |grep "inet addr" |grep -v "127.0.0.1" |awk '{print $2}'|sed "s/addr://g")
echo "network eth0 IP is $network"
}

network_card_info ()
{
echo "=====================network_card_info==================="
card=$(ip a|awk -F "inet|/" '/inet.*brd/ {print $2}')
echo "Network card is $card"
}



disk_info
cpu_info
mem_info
load_info
network_info
network_card_info

0 comments on commit 597b03c

Please sign in to comment.