See Also: Developing Plugins For Use With Embedded Perl
Mod-Gearman can be compiled with support for an embedded Perl interpreter. This allows Mod-Gearman to execute Perl plugins much more efficiently that it otherwise would, so it may be of interest to you if you rely heavily on plugins written in Perl.
Without the embedded Perl interpreter, Mod-Gearman executes Perl (and non-Perl) plugins by forking and executing the plugins as an external command. When the embedded Perl interpreter is used, Mod-Gearman can execute Perl plugins by simply making a library call.
This documentation discusses the embedded Perl interpreter in relation to plugins used for host and service checks, but it applies just the same to other types of Perl scripts you may be using for other types of commands (e.g. notification scripts, event handler scripts, etc.).
Stephen Davies contributed the original embedded Perl interpreter code several years back. Stanley Hopcroft has been the primary person helping to improve the embedded Perl interpreter code quite a bit and has commented on the advantages/disadvantages of using it. He has also given several helpful hints on creating Perl plugins that work properly with the embedded interpreter.
It should be noted that “ePN”, as used in this documentation, refers to embedded Perl Mod-Gearman, or if you prefer, Mod-Gearman compiled with an embedded Perl interpreter.
Some advantages of ePN (embedded Perl in Mod-Gearman) include:
The disadvantages of ePN (embedded Perl in Mod-Gearman) are much the same as Apache mod_perl (i.e. Apache with an embedded interpreter) compared to a plain Apache:
If you want to use the embedded Perl interpreter to run your Perl plugins and scripts, here’s what you’ll need to do:
If you want to use the embedded Perl interpreter, you’ll first need to compile Mod-Gearman with support for it.
To do this, simply run the configure script with the addition of the--enable-embedded-perl
option. If you want the embedded interpreter to cache internally compiled scripts, add the --with-perlcache option as well.
./configure --enable-embedded-perl --with-perlcache <otheroptions...>
Once you’ve rerun the configure script with the new options, make sure to recompile Mod-Gearman.
Beginning with Mod-Gearman, you can specify which Perl plugins or scripts should or should not be run under the embedded Perl interpreter. This is particularly useful if you have troublesome Perl scripts which do not work well with the Perl interpreter.
To explicitly tell Mod-Gearman whether or not to use the embedded Perl interpreter for a particular perl script, add one of the following entries to your Perl script/plugin…
To tell Mod-Gearman to use the Perl interpreter for a particular script, add this line to the Perl script:
# nagios: +epn
To tell Mod-Gearman to NOT use the embedded Perl interpreter for a particular script, add this line to the Perl script:
# nagios: -epn
Either line must be located within the first 10 lines of a script for Mod-Gearman to detect it.
If the value is set to 1, all Perl plugins/scripts (that do not explicitly enable/disable the ePN) will be run under the Perl interpreter. If the value is 0, they will NOT be run under the Perl interpreter.
Information on developing plugins for use with the embedded Perl interpreter can be found here.