~ubuntu-branches/ubuntu/utopic/libmonitoring-livestatus-perl/utopic

« back to all changes in this revision

Viewing changes to lib/Monitoring/Livestatus.pm

  • Committer: Bazaar Package Importer
  • Author(s): Alexander Wirt
  • Date: 2011-06-05 21:51:34 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20110605215134-3ql4x8q7a68ps7cv
Tags: 0.74-1
* New upstream release
* Bump standards version (no changes)

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
use Encode;
13
13
use JSON::XS;
14
14
 
15
 
our $VERSION = '0.64';
 
15
our $VERSION = '0.74';
16
16
 
17
17
 
18
18
=head1 NAME
784
784
    return(490, $self->_get_error(490), undef) if !defined $statement;
785
785
    chomp($statement);
786
786
 
787
 
    # remove empty lines from statement
788
 
    $statement =~ s/\n+/\n/gmx;
789
 
 
790
787
    my($status,$msg,$body);
791
788
    if($statement =~ m/^Separators:/mx) {
792
789
        $status = 492;
848
845
 
849
846
        # Commands need no additional header
850
847
        if($statement !~ m/^COMMAND/mx) {
851
 
            #$header .= "ColumnHeaders: on\n";
852
848
            $header .= "OutputFormat: json\n";
853
849
            $header .= "ResponseHeader: fixed16\n";
854
850
            if($self->{'keepalive'}) {
855
851
                $header .= "KeepAlive: on\n";
856
852
            }
857
 
        }
 
853
            # remove empty lines from statement
 
854
            $statement =~ s/\n+/\n/gmx;
 
855
        }
 
856
 
 
857
        # add additional headers
 
858
        if(defined $opt->{'header'} and ref $opt->{'header'} eq 'HASH') {
 
859
            for my $key ( keys %{$opt->{'header'}}) {
 
860
                $header .= $key.": ".$opt->{'header'}->{$key}."\n";
 
861
            }
 
862
        }
 
863
 
858
864
        chomp($statement);
859
865
        my $send = "$statement\n$header";
860
866
        $self->{'logger'}->debug("> ".Dumper($send)) if $self->{'verbose'};
896
902
 
897
903
    my $limit_start = 0;
898
904
    if(defined $opt->{'limit_start'}) { $limit_start = $opt->{'limit_start'}; }
899
 
    #utf8::encode($body);
900
905
    my $result;
901
906
    # fix json output
902
907
    $body =~ s/\],\n\]\n$/]]/mx;
1453
1458
        'backend'       => 1,
1454
1459
        'columns'       => 1,
1455
1460
        'deepcopy'      => 1,
 
1461
        'header'        => 1,
1456
1462
        'limit'         => 1,
1457
1463
        'limit_start'   => 1,
1458
1464
        'limit_length'  => 1,