Effective way to read and write into syslog in Linux systems usingC++

A

anjaliraman2

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.

Thanks
Anjali
 
P

Pascal J. Bourguignon

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).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top