NAME
Nagios::Generator::TestConfig - Perl extension for generating test nagios configurations
SYNOPSIS
use Nagios::Generator::TestConfig;
my $ngt = Nagios::Generator::TestConfig->new( 'output_dir' => '/tmp/test_nagios' );
$ngt->create();
DESCRIPTION
This modul generates test configurations for nagios. This can be useful if you want for doing load tests or testing nagios addons and plugins.
CONSTRUCTOR
- new ( [ARGS] )
-
Creates an
Nagios::Generator-TestConfig
object.new
takes at least the output_dir. Arguments are in key-value pairs.verbose verbose mode output_dir export directory overwrite_dir overwrite contents of an existing directory. Default: false hostcount amount of hosts of export, Default 10 services_per_host amount of services per host, Default 10 host_settings key/value settings for use in the define host service_settings key/value settings for use in the define service nagios_cfg overwrite/add settings from the nagios.cfg hostfailrate chance of a host to fail, Default 2% servicefailrate chance of a service to fail, Default 5% host_types key/value settings for percentage of hosttypes, possible keys are up,down,flap,random service_types key/value settings for percentage of servicetypes, possible keys are ok,warning,critical,unknown,flap,random
METHODS
- create
-
create() generates and writes the configuration Returns true on success or undef on errors.
EXAMPLE
Create a sample config with manually overriden host/service settings:
use Nagios::Generator::TestConfig;
my $ngt = Nagios::Generator::TestConfig->new(
'output_dir' => '/tmp/nagios-test-conf',
'verbose' => 1,
'overwrite_dir' => 1,
'hostcount' => 50,
'services_per_host' => 20,
'nagios_cfg' => {
'nagios_user' => 'nagios',
'nagios_group' => 'nagios',
},
'hostfailrate' => 2, # percentage (only for the random ones)
'servicefailrate' => 5, # percentage (only for the random ones)
'host_settings' => {
'normal_check_interval' => 10,
'retry_check_interval' => 1,
},
'service_settings' => {
'normal_check_interval' => 10,
'retry_check_interval' => 2,
},
'host_types' => {
'down' => 5, # percentage
'up' => 50,
'flap' => 5,
'pending' => 5,
'random' => 35,
},
'service_types' => {
'ok' => 50, # percentage
'warning' => 5,
'unknown' => 5,
'critical' => 5,
'pending' => 5,
'flap' => 5,
'random' => 25,
},
);
$ngt->create();
AUTHOR
Sven Nierlein, <nierlein@cpan.org>
COPYRIGHT AND LICENSE
Copyright (C) 2009 by Sven Nierlein
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.