blib/script/parse.pl untested

filter: Statementstmt 0.0% 0 / 48 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 7 Podpod n/a totaltotal 0.0% 0 / 76 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 #!/usr/local/bin/perl -w
2  
3 # $Id$
4 # $LastChangedDate$
5 # $Rev$
6  
7 use strict;
8 use lib qw( ./lib ../lib);
9 use Nagios::Config;
10 use Nagios::Object::Config;
11 use Getopt::Std;
12 use Benchmark qw(:all);
13 use Data::Dumper;
14  
15 our ( $opt_n, $opt_o, $opt_v, $opt_b, $opt_d, $opt_f, $opt_r, $opt_l );
16 getopt('n:o:v:');
17 getopt('bdfrl');
18  
19 if ($opt_f) {
20 Nagios::Config->fast_mode(1);
21 }
22  
23 Nagios::Object::Config->strict_mode(undef);
24 unless ($opt_l) {
25 Nagios::Object::Config->strict_mode(1);
26 }
27  
28 if ( !$opt_n && !$opt_o ) {
29 print "Must specify a filename to parse (either -n or -o).\n";
30 exit 1;
31 }
32  
33 my $t0 = new Benchmark;
34  
35 my $obj = undef;
36 if ($opt_n) {
37 $obj = Nagios::Config->new( Filename => $opt_n, Version => $opt_v );
38 }
39 if ($opt_o) {
40 $obj = Nagios::Object::Config->new( Version => $opt_v );
41 $obj->parse($opt_o);
42  
43 if ($opt_r) {
44 $obj->resolve_objects;
45 $obj->register_objects;
46 }
47 }
48  
49 if ($opt_d) {
50 print Dumper($obj), "\n";
51 }
52  
53 if ($opt_b) {
54 my $t1 = new Benchmark;
55 my $td = timediff( $t1, $t0 );
56 printf "Benchmark: %s\n", timestr($td);
57 }
58  
59 =head1 NAME
60  
61 parse.pl
62  
63 =head1 USAGE
64  
65 parse.pl [-n|-o] [-v] [-b] [-d] [-f]
66  
67 =head1 OPTIONS
68  
69 =over 4
70  
71 =item -n
72  
73 Specify a primary nagios configuration file. This file will be parsed along with
74 any object configuration files referenced inside it.
75  
76 =item -o
77  
78 Parse a single object configuration file.
79  
80 =item -v
81  
82 Specify a Nagios configuration version to parse. i.e. -v 1 or -v 2
83  
84 =item -b
85  
86 Show some benchmarking information.
87  
88 =item -d
89  
90 Dump out the data structures after parsing (uses Data::Dumper).
91  
92 =item -f
93  
94 Use the new EXPERIMENTAL fast mode.
95  
96 =cut
97