linux syslog详解 转 (2)

Note 1 - Various operating systems have been found to utilize
          Facilities 4, 10, 13 and 14 for security/authorization,
          audit, and alert messages which seem to be similar.
       Note 2 - Various operating systems have been found to utilize
          both Facilities 9 and 15 for clock (cron/at) messages.

Severity的定义如下:

Numerical         Severity
        Code

0       Emergency: system is unusable
         1       Alert: action must be taken immediately
         2       Critical: critical conditions
         3       Error: error conditions
         4       Warning: warning conditions
         5       Notice: normal but significant condition
         6       Informational: informational messages
         7       Debug: debug-level messages

也就是说,尖括号中有1~3个数字字符,只有当数字是0的时候,数字才以0开头,也就是说00和01这样在前面补0是不允许的。

2.2、HEADER部分 
    HEADER部分包括两个字段,时间和主机名(或IP)。
    时间紧跟在PRI后面,中间没有空格,格式必须是“Mmm dd hh:mm:ss”,不包括年份。“日”的数字如果是1~9,前面会补一个空格(也就是月份后面有两个空格),而“小时”、“分”、“秒”则在前面补“0”。月份取值包括:
Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec

时间后边跟一个空格,然后是主机名或者IP地址,主机名不得包括域名部分。

因为有些系统需要将日志长期归档,而时间字段又不包括年份,所以一些不标准的syslog格式中包含了年份,例如:
<165>Aug 24 05:34:00 CST 1987 mymachine myproc[10]: %% It\'s
time to make the do-nuts. %% Ingredients: Mix=OK, Jelly=OK #
Devices: Mixer=OK, Jelly_Injector=OK, Frier=OK # Transport:
Conveyer1=OK, Conveyer2=OK # %%
    这样会导致解析程序将“CST”当作主机名,而“1987”开始的部分作为MSG部分。解析程序面对这种问题,可能要做很多容错处理,或者定制能解析多种syslog格式,而不仅仅是只能解析标准格式。

HEADER部分后面跟一个空格,然后是MSG部分。
    有些syslog中没有HEADER部分。这个时候MSG部分紧跟在PRI后面,中间没有空格。

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zgffwz.html