Nagios::Object::Config(3pm) | User Contributed Perl Documentation | Nagios::Object::Config(3pm) |
Nagios::Object::Config - Perl objects to represent Nagios configuration
This is a module for parsing and processing Nagios object configuration files into perl objects.
To enable regular expression matching, use either the "regexp_matching" or "true_regexp_matching" arguments to new(). See enable_regexp_matching() and enable_true_regexp_matching() below.
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 );
$parser->parse( "myfile.cfg" );
my $object = $parser->find_object( "localhost" ); my $object = $parser->find_object( "oracle", "Nagios::Service" );
my @object_list = $parser->find_objects( "load", "Nagios::Service" );
The regular expressions are created by translating the "*" to ".*?" and "?" to ".". For now (v0.9), this code completely ignores Nagios's use_regexp_matching and use_true_regexp_matching and does full RE matching all the time.
my @objects = $parser->find_objects_by_regex( "switch_*", "Nagios::Host" ); my @objects = $parser->find_objects_by_regex( "server0?", "Nagios::Host" );
Usage: $objects = all_objects_for_type($object_type)
Parameters:
$object_type - A specific Nagios object type,
i.e. "Nagios::Contact"..
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.
Note that the array reference by the return value may be empty.
Example:
my $contacts = $config->all_objects_for_type("Nagios::Contact"); if (scalar(@$contacts) == 0) { print "No contacts have yet been defined\n"; } else { foreach $contact (@$contacts) { ... } }
my $everything = $config->all_objects;
my $object = $parser->find_attribute( "command_name", "check_host_alive" ); my $object = $parser->find_attribute( "command_name", "check_host_alive", 'Nagios::Host' );
$parser->resolve( $object );
$parser->register( $host_object ); my $timeperiod_object = $host_object->notification_period;
$parser->resolve_objects();
$parser->register_objects();
$parser->enable_regexp_matching; $parser->disable_regexp_matching;
The generated RE's have the same translation as above, but do not have the anchors to ^ and $.
This option always supercedes enable_regexp_matching.
$parser->enable_true_regexp_matching; $parser->disable_true_regexp_matching;
$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
Al Tobey <tobeya@cpan.org> Contributions From:
Lynne Lawrence (API & bugs)
2022-06-16 | perl v5.34.0 |