.\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Nagios::Object::Config 3pm" .TH Nagios::Object::Config 3pm "2013-09-24" "perl v5.18.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Nagios::Object::Config \- Perl objects to represent Nagios configuration .SH "DESCRIPTION" .IX Header "DESCRIPTION" This is a module for parsing and processing Nagios object configuration files into perl objects. .SH "METHODS" .IX Header "METHODS" .IP "\fInew()\fR" 4 .IX Item "new()" Create a new configuration object. If Version is not specified, the already weak validation will be weakened further to allow mixing of Nagios 1.0 and 2.0 configurations. For now, the minor numbers of Version are ignored. Do not specify any letters as in '2.0a1'. .Sp To enable regular expression matching, use either the \*(L"regexp_matching\*(R" or \*(L"true_regexp_matching\*(R" arguments to \fInew()\fR. See \fIenable_regexp_matching()\fR and \fIenable_true_regexp_matching()\fR below. .Sp .Vb 2 \& my $objects = Nagios::Object::Config\->new(); \& my $objects = Nagios::Object::Config\->new( Version => 1.2 ); \& \& my $objects = Nagios::Object::Config\->new( \& Version => 2.0, \& regexp_matching => 1, \& true_regexp_matching => 2 \& ); .Ve .IP "\fIparse()\fR" 4 .IX Item "parse()" Parse a nagios object configuration file into memory. Although Nagios::Objects will be created, they are not really usable until the \fIregister()\fR method is called. .Sp .Vb 1 \& $parser\->parse( "myfile.cfg" ); .Ve .IP "\fIfind_object()\fR" 4 .IX Item "find_object()" Search through the list of objects' names and return the first match. The second argument is optional. Always using it can considerably reduce the size of the list to be searched, so it is recommended. .Sp .Vb 2 \& my $object = $parser\->find_object( "localhost" ); \& my $object = $parser\->find_object( "oracle", "Nagios::Service" ); .Ve .IP "\fIfind_objects()\fR" 4 .IX Item "find_objects()" Search through the list of objects' names and return all the matches. The second argument is required. .Sp .Vb 1 \& my @object_list = $parser\->find_objects( "load", "Nagios::Service" ); .Ve .IP "\fIfind_objects_by_regex()\fR" 4 .IX Item "find_objects_by_regex()" Search through the list of objects' names and return a list of matches. The first argument will be evaluated as a regular expression. The second argument is required and specifies what kind of object to search for. .Sp The regular expressions are created by translating the \*(L"*\*(R" to \*(L".*?\*(R" and \*(L"?\*(R" to \*(L".\*(R". For now (v0.9), this code completely ignores Nagios's use_regexp_matching and use_true_regexp_matching and does full \s-1RE\s0 matching all the time. .Sp .Vb 2 \& my @objects = $parser\->find_objects_by_regex( "switch_*", "Nagios::Host" ); \& my @objects = $parser\->find_objects_by_regex( "server0?", "Nagios::Host" ); .Ve .IP "\fIall_objects_for_type()\fR" 4 .IX Item "all_objects_for_type()" Obtain a reference to all objects of the specified Nagios object type. .Sp Usage: \f(CW$objects\fR = all_objects_for_type($object_type) .Sp Parameters: \f(CW$object_type\fR \- A specific Nagios object type, i.e. \*(L"Nagios::Contact\*(R".. .Sp Returns: A reference to an array of references to all objects of the specified type associated with this configuration. Objects of this type added to the configuration following the call to this method _will_ be accessible through this reference after the fact. .Sp .Vb 1 \& Note that the array reference by the return value may be empty. .Ve .Sp Example: .Sp .Vb 8 \& my $contacts = $config\->all_objects_for_type("Nagios::Contact"); \& if (scalar(@$contacts) == 0) { \& print "No contacts have yet been defined\en"; \& } else { \& foreach $contact (@$contacts) { \& ... \& } \& } .Ve .IP "\fIall_objects()\fR" 4 .IX Item "all_objects()" Returns an arrayref with all objects parsed from the config in it. .Sp .Vb 1 \& my $everything = $config\->all_objects; .Ve .IP "\fIfind_attribute()\fR" 4 .IX Item "find_attribute()" Search through the objects parsed thus far, looking for a particular textual name. When found, return that object. If called with two arguments, it will search through all objects currently loaded until a match is found. A third argument may specify the type of object to search for, which may speed up the search considerably. .Sp .Vb 2 \& my $object = $parser\->find_attribute( "command_name", "check_host_alive" ); \& my $object = $parser\->find_attribute( "command_name", "check_host_alive", \*(AqNagios::Host\*(Aq ); .Ve .IP "\fIresolve()\fR" 4 .IX Item "resolve()" Resolve the template for the specified object. Templates will not work until this has been done. .Sp .Vb 1 \& $parser\->resolve( $object ); .Ve .IP "\fIregister()\fR" 4 .IX Item "register()" Examine all attributes of an object and link all of it's references to other Nagios objects to their respective perl objects. If this isn't called, some methods will return the textual name instead of a perl object. .Sp .Vb 2 \& $parser\->register( $host_object ); \& my $timeperiod_object = $host_object\->notification_period; .Ve .IP "\fIresolve_objects()\fR" 4 .IX Item "resolve_objects()" Resolve all objects currently loaded into memory. This can be called any number of times without corruption. .Sp .Vb 1 \& $parser\->resolve_objects(); .Ve .IP "\fIregister_objects()\fR" 4 .IX Item "register_objects()" Same deal as \fIresolve_objects()\fR, but as you'd guess, it registers all objects currently loaded into memory. .Sp .Vb 1 \& $parser\->register_objects(); .Ve .IP "\fIenable_regexp_matching()\fR/\fIdisable_regexp_matching()\fR" 4 .IX Item "enable_regexp_matching()/disable_regexp_matching()" This correlates to the \*(L"use_regexp_matching\*(R" option in nagios.cfg. When this option is enabled, Nagios::Object::Config will translate \*(L"*\*(R" to \*(L".*?\*(R" and \*(L"?\*(R" to \*(L".\*(R" and evaluate the result as a perl \s-1RE,\s0 anchored at both ends for any value that can point to multiple other objects (^ and $ are added to either end). .Sp .Vb 2 \& $parser\->enable_regexp_matching; \& $parser\->disable_regexp_matching; .Ve .IP "\fIenable_true_regexp_matching()\fR/\fIdisable_true_regexp_matching()\fR" 4 .IX Item "enable_true_regexp_matching()/disable_true_regexp_matching()" This correlates to the \*(L"use_true_regexp_matching\*(R" option in nagios.cfg. This is very similar to the \fIenable_regexp_matching()\fR option, but matches more data and allows more powerful \s-1RE\s0 syntax. These modules will allow you the full power of perl \s-1RE\s0's \- this is probably more than is available in Nagios, so don't blame me if something works here but not in Nagios (it's usually the other way around anyways). .Sp The generated \s-1RE\s0's have the same translation as above, but do not have the anchors to ^ and $. .Sp This option always supercedes enable_regexp_matching. .Sp .Vb 2 \& $parser\->enable_true_regexp_matching; \& $parser\->disable_true_regexp_matching; .Ve .IP "\fIlist_hosts()\fR, \fIlist_hostgroups()\fR, etc." 4 .IX Item "list_hosts(), list_hostgroups(), etc." Returns an array/arrayref of objects of the given type. .Sp .Vb 10 \& $config\->list_hosts \& $config\->list_hostgroups \& $config\->list_services \& $config\->list_timeperiods \& $config\->list_commands \& $config\->list_contacts \& $config\->list_contactgroups \& $config\->list_hostdependencies \& $config\->list_servicedependencies \& $config\->list_hostescalations \& $config\->list_hostgroupescalations \& $config\->list_serviceescalations \& $config\->list_servicegroups \& $config\->list_hostextinfo \& $config\->list_serviceextinfo .Ve .SH "AUTHOR" .IX Header "AUTHOR" Al Tobey Contributions From: Lynne Lawrence (\s-1API &\s0 bugs)