Centos 7週期性任務、日誌rotation、過濾和core壓縮的實現

來源:互聯網
上載者:User

標籤:centos7   log   core   

Centos7週期性任務日誌rotation、過濾和core壓縮的實現


1.centos7中cron指令碼及其呼叫指令碼的實現樣本


[[email protected]cron.d]# pwd

/etc/cron.d

[[email protected]cron.d]# cat syslog

#Run mysys activity accounting tool every 10 minutes

*/5* * * * root /usr/sbin/mysyslog.sh 2>&1 >>/var/log/mysys.log

#0 * * * * root /usr/lib64/sa/sa1 600 6 &

#Generate a daily summary of process accounting at 23:53

*/5* * * * root /usr/sbin/ipmilog.sh

#5323 * * * root /usr/lib64/sa/sa2 -A



2. 實現日誌rotation及其相關指令碼

[[email protected]logrotate.d]# pwd

/etc/logrotate.d

[[email protected]logrotate.d]# cat selmon

/var/log/ipmi.log{

weekly

copytruncate

compress

missingok

notifempty

rotate200

}

[[email protected]logrotate.d]# cat mysysmon

/var/log/mysys.log{

#weekly

daily

copytruncate

compress

dateext

create644 root root

missingok

notifempty

rotate10

}


[[email protected]logrotate.d]# cat smhmon

/var/sysdbase/eventlog.txt/var/sysdbase/eventlog {

weekly

copytruncate

ccompress

dateext

create644 root root

missingok

notifempty

rotate198

}


3.rsyslog.conf規則的更新


添加對ceph-fuse日誌的支援:

:syslogtag,contains, "ceph-fuse"        /var/log/lsd/ceph-fuse.log


添加對需要抓取分級日誌的應用程式的輸出:

#:syslogtag, contains, "gluser-fire"  /var/log/log.txt

#action(type="omfile"file="/var/log/log.txt")

if$programname == ‘gluser-fire‘ then {

if$msg contains ‘in print level 0‘ then

action(type="omfile"file="/var/log/log-level0.txt")

if$msg contains ‘in print level 1‘ then

action(type="omfile"file="/var/log/log-level1.txt")

if$msg contains ‘in print level 2‘ then

action(type="omfile"file="/var/log/log-level2.txt")

if$msg contains ‘in print level 3‘ then

action(type="omfile"file="/var/log/log-level3.txt")

if$msg contains ‘in print level 4‘ then

action(type="omfile"file="/var/log/log-level4.txt")

if$msg contains ‘in print level 5‘ then

action(type="omfile"file="/var/log/log-level5.txt")

if$msg contains ‘in print level 6‘ then

action(type="omfile"file="/var/log/log-level6.txt")

if$msg contains ‘in print level 7‘ then

action(type="omfile"file="/var/log/log-level7.txt")

}


4.修改核心panic產生core的方式

1)在終端中輸入ulimit-c 如果結果為0,說明當程式崩潰時,系統並不能產生coredump。

 

2)使用ulimit-c unlimited命令,開啟coredump功能,並且不限制產生coredump檔案的大小。如果需要限制,加數字限制即可。ulimit- c 1024


3)參考下面的命令實現core 壓縮:

修改/proc/sys/kernel/core_pattern:

[[email protected]~]# cat /usr/sbin/core_compresser

#!/bin/bash

execgzip - > /var/core/app/core-$1-$2-$3.gz

#!/bin/bash

execgzip - > /var/core/app/core-$1-$2-$3.gz

[[email protected]~]# cat /proc/sys/kernel/core_pattern

/var/core/app/core-%e-%p-%t

[[email protected]~]# echo "|/usr/sbin/core_compresser %e %p %t" >/proc/sys/kernel/core_pattern

[[email protected]~]# cat /proc/sys/kernel/core_pattern

|/usr/sbin/core_compresser%e %p %t



本文出自 “儲存之廚” 部落格,請務必保留此出處http://xiamachao.blog.51cto.com/10580956/1882049

Centos 7週期性任務、日誌rotation、過濾和core壓縮的實現

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.