an**********@gmail.com writes:
Hi All,
I am facing a problem of writing into and reading from syslog in
Linux Enviornment using C++. The CPU utilization is extremely high of
about 55% and is creating problems for other processes.
ideally the CPU utilization has to be only max of 10% not more.
I have used getline() for reading.
I hope u will please provide me a suitable solution.
Of course, you can always throttle the CPU usage by your process, but
what good would that be to have your processor 70% idle?
Just tell the kernel that your log analysis process is not prioritary,
and let the scheduler allocate the time available.
nice -5 log-analyzer &
other-processes &
top
Now, one good way to limit the CPU usage of log processing is to NOT
write any logs.
Note that reducing the log level at the syslog step is already too
late. At least, with syslog-ng, when I activate debugging logs with
no destination for them, syslog-ng still takes 20% CPU, doing nothing
more than /dev/null. (Of course, you can assume that the driver is
also taking 20% CPU only to send the logs).
--
__Pascal Bourguignon__