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", "icinga", "shinken" and "omd" user user, defaults to the current user group group, defaults to the current users group prefix prefix to all hosts / services / contacts / contactgroups binary path to your nagios/icinga bin hostcount amount of hosts to export, Default 10 hostcheckcmd use custom hostcheck command line servicecheckcmd use custom servicecheck command line 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_dependencies no service dependencies will be exported contacts_count amount of contacts to export, Default 1 contactgroups_count amount of contactgroups to export, Default 1 contacts_per_group amount of contacts to export, Default 1 contacts_per_host amount of contacts per host, Default 0 contactgroups_per_host amount of contactgroups per host, Default 1 contacts_per_service amount of contacts per service, Default 0 contactgroups_per_service amount of contactgroups per service, Default 1 skip_hostgroups no hostgroups will be exported skip_servicegroups no servicegroups will be exported
METHODS
- create
-
create() generates and writes the configuration Returns true on success or undef on errors.
EXAMPLE
OMD Users
Using OMD makes generating test configs really easy:
#> create site test
#> su - test
OMD[test]:~$ cpan
...
Would you like me to configure as much as possible automatically? [yes] <enter>
...
cpan[1]> install Monitoring::Generator::TestConfig
...
cpan[2]> exit
OMD[test]:~$ ./local/lib/perl5/bin/create_monitoring_test_config.pl
After the first installation, configuration can be adjusted in the recreate.pl in your SITE directory.
Sample Script
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.