Subversion Repositories sysadmin_scripts

Rev

Rev 91 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
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
92 rodolico 20
      'report to' => 'me@example.com',
89 rodolico 21
      'report type' => 'mail',
92 rodolico 22
      'report from' => 'root@localhost',
89 rodolico 23
      'type' => 'ping'
24
   },
25
   'sites to check' => { # all sites to check
92 rodolico 26
      'some web site' => { # this is for display purposes only
89 rodolico 27
         'url' => 'http://example.com', # the actual URL to use
28
         'type' => 'lwp' # type of test to run
29
      },
92 rodolico 30
      'something that responds to icmp' => {
89 rodolico 31
         'url' => '192.168.1.50',
32
         'type' => 'ping',
33
         'timeout' => 20 # 20 second timeout
34
      },
92 rodolico 35
      'site with netcat server running' => {
36
         'url' => '192.168.1.51',
37
         'type' => 'netcat',
38
         'port' => 45654,
39
         'timeout' => 3 # 20 second timeout
40
      },
89 rodolico 41
   }
42
};
43
 
44
# types of tests are listed in the code, and each test can take.
45
# different parameters. Read the comments at the top of the file
46
 
47
my $yaml = YAML::Tiny->new( $config );
48
$yaml->write( 'config.yaml' );
49