The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Nagios::Config::Onject - Class for Nagios object configuration files

SYNOPSIS

  use Nagios::Config ;
  my $nc = new Nagios::Config("/usr/local/nagios/etc/nagios.cfg") ;
  my @object_files = $nc->get_object_files() ; 
  foreach (@object_files){
    my @hosts = $_->get_objects('host') ;
    foreach my $h (@hosts){
      print $h->get_attr('host_name') . "\n" ;
    }
  }

DESCRIPTION

Nagios::Config::ObjectFile is the class for all Nagios object configuration files. You should not need to create these yourself.

CONSTRUCTOR

new ([FILE])

Creates a Nagios::Config::ObjectFile.

METHODS

get_objects ([TYPE])

Returns a list of all the objects of type TYPE that where found during the parse. Each of these objects will be blessed in the Nagios::Config::Object::TYPE package, which inherits from Nagios::Config::Object.

Ex: my @hosts = $of->get_objects('host') ;

get_object_hash ([TYPE], [KEY])

Returns a hash of all the objects of type TYPE that where found during the parse, using attribute KEY as the hash key. Make sure that the value of KEY is unique for each object, or else you will not get all the objects in the hash. Each of these objects will be blessed in the Nagios::Config::Object::TYPE package, which inherits from Nagios::Config::Object.

Ex: my %hosts = $of->get_object_hash('host', 'host_name') ;

find_objects ([TYPE], [ATTR], [QUERY], [SPLIT])

Returns a list of all the objects of type TYPE that where found during the parse, where ATTR "matches" QUERY. QUERY can be a regular expression (i.e. qr/.../) or a scalar. If SPLIT is true, the values will be split on /\s*,\s*/ and each of the resulting values will be compared separately. Also, if the value of the ATTR is '*', the object is returned regardless of the value of QUERY. Each of these objects will be blessed in the Nagios::Config::Object::TYPE package, which inherits from Nagios::Config::Object.

Ex: my %services = $of->get_object_hash('service', 'host_name', 'my_host', 1) ;

AUTHOR

Patrick LeBoutillier, patl@cpan.org

SEE ALSO

Nagios::Config, Nagios::Config::Object, Nagios::Config::File