summaryrefslogtreecommitdiffstats
path: root/web/input/doc/faq/use-perl-module.md
blob: 64ba18a65f85a9473c6f8ff7b9e674698b699f10 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
title: Using Nagios::Plugin
parent: FAQ
---

# How do I use the Nagios::Plugin module?

The Nagios::Plugin Perl module can be obtained from two main locations:

* from the Nagios Plugins tarball with an
  [extra configure option][configure-module]
* from [CPAN][cpan-module]

If you install from the Nagios Plugins tarball, the Perl module will be
installed in `$prefix/perl`.

If you install from CPAN, the Perl module will be installed into your Perl's
system directories by default.

To write your plugin, you should start it with:

    use FindBin;
    use lib "$FindBin::Bin/../perl/lib";
    use Nagios::Plugin;

This bit of code tells Perl to look for the Nagios::Plugin module in a
directory relative to where the plugin is executed - this is a hard
dependency.  If Nagios::Plugin is not found there, Perl's system directories
will be searched.

This approach allows a system administrator to decide whether they want
Nagios::Plugin installed via system directories or within the `$prefix` area
of the plugins.

[configure-module]: doc/faq/build-perl-module.html "configure with Nagios::Plugin"
[cpan-module]: http://search.cpan.org/dist/Nagios-Plugin/ "Nagios::Plugin on CPAN"

<!--% # vim:set filetype=markdown textwidth=78 joinspaces: # %-->