|
Nagios::Config - Parse Nagios configuration files |
Nagios::Config - Parse Nagios configuration files
use Nagios::Config ;
my $nc = new Nagios::Config("/usr/local/nagios/etc/nagios.cfg") ;
foreach my $object ($nc->get_objects('host')){
print $object->get('host_name') . "\n" ;
}
Nagios::Config parses the Nagios configuration files in order to extract
all information about nagios.cfg, resource.cfg and template-based objects. All
template values are merged recursively, meaning that each object has all its
attributes present, even those that were defined in templates.
Note: Nagios::Config assumes that your Nagios configuration is valid
and may react unexpectedly if it is not. Please check your configuration
using the ``nagios -v'' command prior to using Nagios::Config on it.
Nagios::Config, which will parse the contents of FILE assuming
it is a Nagios Main Configuration File. FILE can be a file name or a reference
to an already opened filehandle. If FILE is false, it will default to
``/usr/local/nagios/etc/nagios.cfg''
Ex: my @types = $nc->get_object_types() ;
Nagios::Config::ObjectFile
objects) that where parsed.
Ex: my @files = $nc->get_object_files() ;
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 = $nc->get_objects('host') ;
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 = $nc->get_object_hash('host', 'host_name') ;
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 %my_host_services = $nc->get_object_hash('service', 'host_name', 'my_host', 1) ;
Nagios::Config::File object corresponding to nagios.cfg.
Nagios::Config::File object corresponding to resource.cfg.
Patrick LeBoutillier, patl@cpan.org
Nagios::Config::File, Nagios::Config::ObjectFile, Nagios::Config::Object
|
Nagios::Config - Parse Nagios configuration files |