5月 272017
 

syslog协议的第一部分是尖括号引用的一个数字,如: <182>

该数字大小范围为: 0 ~ 255, 为1个字节表达的数字,包含两部分内容:

低三位: (0 ~ 7)称作: Severity

 

高5位(右移3位后): (0 ~ 31)称作:Facility

 

根据尖括号中的数字还原上面两个部分的方法,以 182 为例:

即: local6的information

 

参考:https://tools.ietf.org/html/rfc3164#section-4.1.1

 Posted by at 下午 2:59
1月 012013
 

测试目的

如果syslog函数的调用并发很大的话,可能会因为syslogd消费太慢而阻塞;本实验观察其阻塞的几个决定因素:

1. 未消费报文数超过多少个会阻塞

2. 报文的长度允许最大多大

3. 如果报文数为超过最大值,则数据超过多少会阻塞

测试平台

ubuntu12

测试1:

1. kill -19 syslogd-pid

2. i=1; while :; do ((i++)); logger a; done

结论: 默认值为10, 可以通过修改net.unix.max_dgram_qlen来调的更大一些;

注意: 修改net.unix.max_dgram_qlen 后需要重启进程才能生效,或者kill rsyslogd (rsyslogd会自己重启的)

 

测试2:

1. while [ i < 65536 ]; do ((i++)); echo -n a>>a.txt; done

2. while :; do logger <a.txt; done

发现一条日志重复了64次,说明,单个数据包的最大数据量为1k; 但是,很有可能是logger程序故意做了这种1k的切割(通过logger的源代码确认了一下,是这样的); 使用PHP的syslog函数来写日志,只截取了其中2k的数据记录进去了,其它的就给丢弃了,不过,这个也可能是PHP给做了2k的限制; 看了下PHP的源码,没有做这样的限制,或许unix数据报的报文大小就是2k的限制了,不过,这个也太小了,难道unixsocket可以显式定义数据报的大小?

 

测试3:

创建了一个200字节的文件,并且把net.unix.max_dgram_qlen 修改为1000,kill -19 syslogd_pid 后,使用logger写了1000次文件后才阻塞,说明还是受到了net.unix.max_dgram_qlen的限制,而没有收到一个buffer的限制。猜测,难道没有这么一个buffer?

 (后测试发现写入84k的数据就开始阻塞了)

=======================

关于丢数据的问题

rsyslog的日志中发现如下日志:

Jan 1 21:19:44 phpor-VirtualBox rsyslogd-2177: imuxsock begins to drop messages from pid 2297 due to rate-limiting

 

 

 Posted by at 上午 1:29
8月 252012
 

从配置文件学起:

关于配置文件

  1. 配置文件的解析参看文件 runtime/rsconf.c
  2. $ActionExecOnlyWhenPreviousIsSuspended
关于配置文件的说明: http://www.rsyslog.com/doc/rsyslog_conf.html

关于模块

http://www.rsyslog.com/doc/rsyslog_conf_modules.html

 

问题

  1. 关于 QueueTimeoutActionCompletion 的理解

摘自官方文档

Discarding Messages

An interesting application is with disk-assisted queues: if the discard watermark is set lower than the high watermark, message discarding will start before the queue becomes disk-assisted. This may be a good thing if you would like to switch to disk-assisted mode only in cases where it is absolutely unavoidable and you prefer to discard less important messages first.

翻译:

关于使用磁盘辅助队列的一个有意思的应用方式是: 如果“丢弃水位”被设置的低于“高水位”,将在启用磁盘之前开始丢弃消息。如果你情愿丢弃一些不重要的消息,也不愿意使用磁盘的话,这是一个不错的选择。

摘自: http://www.rsyslog.com/doc/queues.html

命名惯例

Output modules, and only output modules, should start with a file name of “om” (e.g. “omfile.c”, “omshell.c”). Similarly, input modules will use “im” and filter modules “fm”. The third character shall not be a hyphen.

摘自: http://www.rsyslog.com/doc/modules.html

 

 

 Posted by at 下午 8:16