Proposal : Python Embedded

Andreas Ericsson ae at op5.se
Mon Jul 21 15:30:48 CEST 2008


Yann JOUANIN wrote:
> Hello everyone,
> 
>  
> 
> I am wondering how hard it could be to include an embedded python
> interpreter in Nagios.
> 
>  
> 
> Does anyone had already try to code this kind of feature?
> 


I know Spike Morelli of Linden Labs has toyed around with a NEB-module
that loads an embedded python interpreter. Given how simple it is to
embed python, I should think it isn't overly complicated.

However, given the fact that the embedded perl engine leaks memory at
such a horrible pace that not many people use it, I'd be very careful
about developing any in-core embedded interpreters.

Creating a NEB-module wouldn't be overly difficult, ofcourse, although
please take into account that Nagios has to carry the embedded python
interpreter around in memory once for every fork(). For Linux, that's
not much of an issue (due to copy-on-write page allocation), but for
Solaris, AIX and other less-frequently-used Nagios host platforms, it
could turn out to be a major pain and a very strong deterrent.

A NEB-module could ofcourse be unloaded for those hosts, unless they
rely so much on python plugins that it actually offsets the drawbacks
for them.

I've been thinking the same thing about LUA and PHP, although more
along the lines of intellectual masturbation than for any real use.

Oh btw, Nagios still would need a generic interface to
1. Insert a running slave-command (plugin, notification command, etc)
   into a "here are the currently running child processes" queue.
2. Poll said queue for events on any or all of the child processes'
   stdout file descriptor.
3. Read output (stdout and stderr) from child processes waiting in
   said queue.
4. Reap exit status codes from said queue.

Steps 2-4 may require a callback interface so that Nagios can alert
the module that started the child about what's going on inside it.

If you want to get started, make sure 1-4 happens first. Then we can
convert the embedded perl stuff to a NEB, and then re-use that NEB
to embed other languages.

-- 
Andreas Ericsson                   andreas.ericsson at op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/




More information about the Developers mailing list