#!/usr/bin/perl use Pod::Usage; use Monitoring::Config; if(!defined $ARGV[0]) { pod2usage( { -verbose => 2, -exit => 3, -message => "\nERROR: missing argument: object.cache\n\n" } ); } if(!defined $ARGV[1]) { pod2usage( { -verbose => 2, -exit => 3, -message => "\nERROR: missing argument: object type\n\n" } ); } if(!-f $ARGV[0]) { pod2usage( { -verbose => 2, -exit => 3, -message => "\nERROR: ".$ARGV[0].': '.$!."\n\n" } ); } my $odb = Monitoring::Config->new({ obj_file => $ARGV[0], 'force' => 1 })->init(); my $objs = $odb->get_objects_by_type($ARGV[1]); my $def = $odb->get_default_keys($ARGV[1], { no_alias => 1, sort => 1 }); # print header print join(';', map(ucfirst, @{$def})), "\n"; # print data for my $o (@{$objs}) { my $first = 1; for my $attr (@{$def}) { if(!defined $o->{'conf'}->{$attr}) { print ";" unless $first; $first = 0; } else { if(ref $o->{'conf'}->{$attr} eq 'ARRAY') { print join(',', @{$o->{'conf'}->{$attr}}), ";"; } else { print $o->{'conf'}->{$attr}, ";"; } } } print "\n"; }