public inbox for linux-audit@redhat.com
 help / color / mirror / Atom feed
* Minimizing CPU Utilization of audisp Plugin
@ 2018-10-05 13:11 Osama Elnaggar
  2018-10-05 14:10 ` Steve Grubb
  0 siblings, 1 reply; 2+ messages in thread
From: Osama Elnaggar @ 2018-10-05 13:11 UTC (permalink / raw)
  To: linux-audit


[-- Attachment #1.1: Type: text/plain, Size: 567 bytes --]

Hi,

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?

Thanks

-- 
Osama Elnaggar

[-- Attachment #1.2: Type: text/html, Size: 2371 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Minimizing CPU Utilization of audisp Plugin
  2018-10-05 13:11 Minimizing CPU Utilization of audisp Plugin Osama Elnaggar
@ 2018-10-05 14:10 ` Steve Grubb
  0 siblings, 0 replies; 2+ messages in thread
From: Steve Grubb @ 2018-10-05 14:10 UTC (permalink / raw)
  To: linux-audit

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-10-05 14:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-05 13:11 Minimizing CPU Utilization of audisp Plugin Osama Elnaggar
2018-10-05 14:10 ` Steve Grubb

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox