Subversion Repositories sysadmin_scripts

Rev

Go to most recent revision | Details | 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',
93 rodolico 23
      'type' => 'netcat'
89 rodolico 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,
93 rodolico 39
         # any additional netcat parameters. This is not checked, so 
40
         # use at your own risk.
41
         'additional parameters' => '-u',
92 rodolico 42
         'timeout' => 3 # 20 second timeout
43
      },
89 rodolico 44
   }
45
};
46
 
47
# types of tests are listed in the code, and each test can take.
48
# different parameters. Read the comments at the top of the file
49
 
50
my $yaml = YAML::Tiny->new( $config );
51
$yaml->write( 'config.yaml' );
52