syslog-ngのプロセスがずっとCPU使用率99.9%になった・・・

syslog-ngのプロセスがCPU使用率99.9%になったsyslog-ng.conf は以下の通りです。

source s_local { pipe ("/proc/kmsg" log_prefix("kernel: ")); unix-stream("/dev/log"); internal(); udp(); };

#destination d_console  { pipe("/dev/console"); };
destination d_messages { file("/var/log/messages"); };
destination d_authlog  { file("/var/log/secure"); };
destination d_maillog  { file("/var/log/maillog");};
destination d_cron     { file("/var/cron/log"); };
destination d_alluser  { usertty("*"); };
destination d_spooler  { file("/var/log/spooler"); };
destination d_local7   { file("/var/log/boot.log");};
destination d_loghost  { file("/var/log/siteA.lighttpd.access.${YEAR}${MONTH}${DAY}.log");};

#filter f_console  { facility(kern) and level(debug..emerg)};
filter f_messages { level(info) and
                    not facility(mail) and
                    not facility(authpriv) and
                    not facility(cron) and
                    not facility(local6) and level(info);
                  };
filter f_authlog  { facility(authpriv) and level(debug..emerg); };
filter f_maillog  { facility(mail) and level(debug..emerg); };
filter f_cron     { facility(cron) and level(debug..emerg); };
filter f_alluser  { level(emerg); };
filter f_spooler  { facility(uucp) and level(crit) or
                    facility(news) and level(crit);
                  };
filter f_local7   { facility(local7) and level(debug..emerg); };
filter f_loghost  { facility(local6) and level(info); };

#log { source(s_local); filter(f_console);  destination(d_console); };
log { source(s_local); filter(f_messages); destination(d_messages); };
log { source(s_local); filter(f_authlog);  destination(d_authlog); };
log { source(s_local); filter(f_maillog);     destination(d_maillog); };
log { source(s_local); filter(f_cron);     destination(d_cron); };
log { source(s_local); filter(f_alluser);  destination(d_alluser); };
log { source(s_local); filter(f_spooler);  destination(d_spooler); };
log { source(s_local); filter(f_local7);  destination(d_local7); };
log { source(s_local); filter(f_loghost);  destination(d_loghost); };


syslog-ngを起動すると、2つある syslog-ng の1つが 99.9% CPUをずっと占領しています・・・。これは明らかにおかしいです・・・。

原因

syslog-ng.conf の以下の部分の設定が良くありませんでした。

source s_local { pipe ("/proc/kmsg" log_prefix("kernel: ")); unix-stream("/dev/log"); internal(); udp(); };

正しくは、以下です。

source s_local { file ("/proc/kmsg" log_prefix("kernel: ")); unix-stream("/dev/log"); internal(); udp(); };

ただしくは、pipe が file になります。これで、CPUの使用率は 0% となり正常になりました。



起動時のエラーメッセージを読む

syslog-ng 起動時に以下のようなメッセージがでる

Starting syslog-ng:  Starting syslog-ng: Your configuration file uses an obsolet
ed keyword, please update your configuration; keyword='log_prefix', change='prog
ram_override'
Error opening pipe, underlying file is not a FIFO, it should be used by file();
filename='/proc/kmsg'
OK
                                                           [  OK  ]

ここに原因が書いてありました・・・。

4〜5行目の

Error opening pipe, underlying file is not a FIFO, it should be used by file();
filename='/proc/kmsg'

に、「Error opening pipe, filename='/proc/kmsg' は file(); を使用すべきです! 」と書いてあります。

また、1〜3行目については、log_prefix が program_override という記述に変わったようです。



上記を修正して、起動すると、

$ sudo /etc/init.d/syslog-ng restart
Restarting syslog-ng: Stopping syslog-ng: OK
Starting syslog-ng: OK


きれいに起動しました。CPUの使用率も問題ありません。エラーメッセージはちゃんと読まないとですね・・・。