系统信息日志配置/etc/syslog.conf

本文介绍了syslog配置文件中不同字段的意义,包括facility和level的选择,以及如何通过配置将不同类型的消息发送到不同的文件中。此外还提供了重启syslog服务的方法。

 

输出消息的类型  格式:   facility.level; facility.level.                      输入消息的位置

*.err;kern.notice;auth.notice                                                                          /dev/sysmsg
*.err;kern.debug;daemon.notice;mail.crit                                                      /var/adm/messages

重启syslog

/etc/init.d/syslog stop

/etc/init.d/syslog start

 

The selector field is a semicolon-separated list of priority specifications in the following format: facility.level; facility.level.

  •  The facility field can contain only 16 codes:
    • kern Messages generated by the kernel.
    • user Messages generated by user processes.
    • mail The mail system.
    • daemon System daemons, such as the in.ftpd and the telnetd daemons.
    • auth The authorization system, including the login and su commands.
    • syslog Messages generated internally by the syslogd daemon.
    • lpr The line printer spooling system, such as the lpr and lpc commands.
    • news Files reserved for the USENET network news system.
    • uucp  (obsolete) The UNIX-to-UNIX copy (UUCP) system does not use the syslog function.
    • cron The cron and at facilities, including crontab, at, and cron.
    • local0-7 Eight user-defined codes.
  • the level selector specifies the severity or importance of the message. Each level includes all the levels above (of a higher severity).  To remember the sequence for the certification exam you can use an appropriately constructed phase like "Every alerted cardriver escapes warning notice"
    • emerg 0 Panic conditions that are normally broadcast to all users
    • alert 1 Conditions that should be corrected immediately, such as a corrupted system database. Only sysadmin of a particular server needs to be informed by mail or paged.
    • crit 2 Warnings about critical conditions, such as hard device errors. 
    • err 3 Errors other than hard device errors
    • warning 4 Warning messages, that generally does not interfere with normal operation.
    • notice 5 Non-error conditions that might require special handling
    • info 6 Purely informational messages (usually does not require any handling)
    • debug 7 Messages that are normally used only when debugging a program
    • none 8 Messages are not sent from the indicated facility to the selected file
逐条注释 ``` if grep -q "chroot_list_file=/etc/vsftpd/chroot_list" /etc/vsftpd/vsftpd.conf then sed -i '/chroot_list_file=/etc/vsftpd/chroot_list/s/^/#/' /etc/vsftpd/vsftpd.conf echo 'chroot_list_file=/etc/vsftpd/chroot_list' >> /etc/vsftpd/vsftpd.conf else echo 'chroot_list_file=/etc/vsftpd/chroot_list' >> /etc/vsftpd/vsftpd.conf fi if grep -q "anonymous_enable" /etc/vsftpd/vsftpd.conf then sed -i '/anonymous_enable=YES/s/^/#/' /etc/vsftpd/vsftpd.conf sed -i '/anonymous_enable=NO/s/^/#/' /etc/vsftpd/vsftpd.conf echo 'anonymous_enable=NO' >> /etc/vsftpd/vsftpd.conf else echo 'anonymous_enable=NO' >> /etc/vsftpd/vsftpd.conf fi fi touch /etc/vsftpd/chroot_list chmod 750 /etc/vsftpd/chroot_list service vsftpd restart systemctl restart vsftpd.service mv /etc/issue /etc/issue.bak mv /etc/issue.net /etc/issue.net.bak touch /etc/motd chmod 644 /etc/motd rpm -e telnet-server systemctl stop telnet.socket if grep -q "Authorized only. All activity will be monitored and reported" /etc/motd then echo 'have' else echo "Authorized only. All activity will be monitored and reported" >> /etc/motd fi if [ -f "/etc/syslog.conf" ];then echo 'authpriv.* /var/log/secure' >> /etc/syslog.conf echo 'cron.*' >> /etc/syslog.conf echo '*.* @133.64.93.31' >> /etc/syslog.conf service syslog restart fi if [ -f "/etc/rsyslog.conf" ];then echo 'authpriv.* /var/log/secure' >> /etc/rsyslog.conf echo 'cron.*' >> /etc/rsyslog.conf echo '*.* @133.64.97.31' >> /etc/rsyslog.conf service rsyslog restart systemctl restart rsyslog.service fi echo 'ok' ```
07-20
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值