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