89 |
rodolico |
1 |
#! /usr/bin/env perl
|
|
|
2 |
use warnings;
|
|
|
3 |
use strict;
|
|
|
4 |
use YAML::Tiny;
|
|
|
5 |
|
|
|
6 |
# basically, if you're not that good with YAML, like me, this will
|
|
|
7 |
# let you create the config as a hashref, then run the script
|
|
|
8 |
# which will give you a file (config.yaml) that is the YAML equivilent.
|
|
|
9 |
#
|
|
|
10 |
# rename the created file to monitorNetwork.yaml and it is now your
|
|
|
11 |
# config file
|
|
|
12 |
#
|
|
|
13 |
# rename this file to makeConfig, edit it, then save and run.
|
|
|
14 |
# It will not be overwritten by svn updates
|
|
|
15 |
|
|
|
16 |
my $config = {
|
|
|
17 |
'defaults' => { # defaults if not specified in site
|
|
|
18 |
'timeout' => 60, # the default timeout, in seconds
|
|
|
19 |
'failure count' => 0, # the number of successive failures before a report
|
|
|
20 |
'report to' => 'something',
|
|
|
21 |
'report type' => 'mail',
|
91 |
rodolico |
22 |
'report from' => 'root',
|
89 |
rodolico |
23 |
'type' => 'ping'
|
|
|
24 |
},
|
|
|
25 |
'sites to check' => { # all sites to check
|
|
|
26 |
'name of site' => { # this is for display purposes only
|
|
|
27 |
'url' => 'http://example.com', # the actual URL to use
|
|
|
28 |
'type' => 'lwp' # type of test to run
|
|
|
29 |
},
|
|
|
30 |
'name of another site' => {
|
|
|
31 |
'url' => '192.168.1.50',
|
|
|
32 |
'type' => 'ping',
|
|
|
33 |
'timeout' => 20 # 20 second timeout
|
|
|
34 |
},
|
|
|
35 |
}
|
|
|
36 |
};
|
|
|
37 |
|
|
|
38 |
# types of tests are listed in the code, and each test can take.
|
|
|
39 |
# different parameters. Read the comments at the top of the file
|
|
|
40 |
|
|
|
41 |
my $yaml = YAML::Tiny->new( $config );
|
|
|
42 |
$yaml->write( 'config.yaml' );
|
|
|
43 |
|