NAME

Monitoring::Generator::TestConfig - generate monitoring configurations (nagios/icinga/shinken)

SYNOPSIS

use Monitoring::Generator::TestConfig;
my $ngt = Monitoring::Generator::TestConfig->new( 'output_dir' => '/tmp/test_monitoring' );
$ngt->create();

DESCRIPTION

This modul generates test configurations for your monitoring. This can be useful if you want for doing load tests or testing addons and plugins.

CONSTRUCTOR

new ( [ARGS] )

Creates an Monitoring::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
layout                      which config should be generated, valid options are "nagios" and "icinga"
user                        user, defaults to the current user
group                       group, defaults to the current users group
prefix                      prefix to all hosts / services
binary                      path to your nagios/icinga bin
hostcount                   amount of hosts to export, Default 10
routercount                 amount of router to export, Default 5 ( exported as host and used as parent )
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
main_cfg                    overwrite/add settings from the nagios.cfg/icinga.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,block
router_types                key/value settings for percentage of hosttypes for router
service_types               key/value settings for percentage of servicetypes, possible keys are ok,warning,critical,unknown,flap,random,block
skip_dependencys            no service dependencys will be exported

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 Monitoring::Generator::TestConfig;
my $mgt = Monitoring::Generator::TestConfig->new(
                    'output_dir'                => '/tmp/test-conf',
                    'verbose'                   => 1,
                    'overwrite_dir'             => 1,
                    'user'                      => 'testuser',
                    'group'                     => 'users',
                    'hostcount'                 => 50,
                    'services_per_host'         => 20,
                    'main_cfg'                  => {
                            'debug_level'     => 1,
                            'debug_verbosity' => 1,
                        },
                    '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'       => 30,
                                    'block'        => 5,
                        },
                    'service_types'             => {
                                    'ok'           => 50, # percentage
                                    'warning'      => 5,
                                    'unknown'      => 5,
                                    'critical'     => 5,
                                    'pending'      => 5,
                                    'flap'         => 5,
                                    'random'       => 20,
                                    'block'        => 5,
                        },
);
$mgt->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.