From: Steve Grubb <sgrubb@redhat.com>
To: linux-audit@redhat.com
Subject: Re: Minimizing CPU Utilization of audisp Plugin
Date: Fri, 05 Oct 2018 10:10:22 -0400 [thread overview]
Message-ID: <10916994.zGLAod9bSu@x2> (raw)
In-Reply-To: <CACva_gEoSDtR62oC5Gc53KnqC-VT5teZ6ifnaS=PZciGyWgdUg@mail.gmail.com>
Hello,
On Friday, October 5, 2018 9:11:28 AM EDT Osama Elnaggar wrote:
> I'm currently working on a Python audisp plugin. My main routine looks
> like this:
>
> if __name__ == '__main__':
>
> try:
> ...
>
> aup = auparse.AuParser(auparse.AUSOURCE_FEED)
> aup.add_callback(process_event, None)
>
> while True:
> for _ in fileinput.input():
> aup.feed(_)
> except:
> ...
>
> While profiling my plugin, I noticed that 95% + of the CPU time used by my
> plugin is used in fileinput.input(), waiting/reading from input
>
> Is there any way to lower this or preferred way to poll/read?
I don't do much if any python programming. But in C, all examples include a
select in the event processing loop. Python has a select module. There are
examples on the internet about how to use it. One is here:
https://www.programcreek.com/python/example/258/select.select
There are other examples.
-Steve
prev parent reply other threads:[~2018-10-05 14:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-05 13:11 Minimizing CPU Utilization of audisp Plugin Osama Elnaggar
2018-10-05 14:10 ` Steve Grubb [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=10916994.zGLAod9bSu@x2 \
--to=sgrubb@redhat.com \
--cc=linux-audit@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.