in reply to Re: Parsing nagios status.dat
in thread Parsing nagios status.dat

Wow !! thanks for the response. Two questions: 1; How should I run this script, are there 2 separated file? 2; where are you declaring the path to the status.dat file ? Thanks!

Replies are listed 'Best First'.
Re^3: Parsing nagios status.dat
by FreeBeerReekingMonk (Deacon) on Apr 01, 2016 at 19:54 UTC
    Leo, what atcroft was pointing out is that you need to put your code like this:

    cat status.dat | \ perl -Mstrict -Mwarnings -MData::Dumper -lne ' use vars qw(%s); BEGIN{ $Data::Dumper::Deepcopy = $Data::Dumper::Sortkeys = 1; }; chomp; if ( m/\}/ ) { print Data::Dumper->Dump( [ \%s, ], [ qw( *s ) ] ); %s = (); } next if ( m/^\s*$/imsx ); $s{TYPE} = $1 if ( m/^\s*(\S+)\s*\{/imsx ); $s{$1} = $2 if ( m/^\s+([^=]+)=(.+)$/imsx ); '