File: statuslog.t

package info (click to toggle)
libnagios-object-perl 0.14-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 512 kB
  • ctags: 112
  • sloc: perl: 1,804; makefile: 53
file content (38 lines) | stat: -rw-r--r-- 1,262 bytes parent folder | download | duplicates (2)
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
#!/usr/local/bin/perl -w
use strict;
use Test::More;
use lib qw( ../lib ./lib );
BEGIN { plan tests => 18 }
eval { chdir('t') };

use_ok( 'Nagios::StatusLog' );

my $config = 'status.log';
ok( my $log = Nagios::StatusLog->new( $config ), "new()" );
ok( $log->update(), "update()" );

ok( my $host = $log->host('spaceghost'), "->host()" );
ok( my $svc  = $log->service('localhost','SSH'), "->service()" );
ok( my $pgm  = $log->program(), "->program()" );

is( $host->host_name(), 'spaceghost', "\$host->host_name() returns correct value" );
is( $svc->description(), 'SSH', "\$svc->description() returns correct value" );

my $v2logfile = 'v2log.dat';

ok( my $v2log = Nagios::StatusLog->new( Filename => $v2logfile, Version => '2.4' ), "new()" );
can_ok( $v2log, qw(host service program info) );

ok( my $i = $v2log->info, "info()" );
ok( my @services = $v2log->list_services(), "list_services()" );
ok( @services > 0, "More then 0 services." );
ok( my $h = $v2log->host( 'localhost' ), "host()" );
ok( my $s = $v2log->service('localhost', $services[0]), "service()" );

# spot check
can_ok( $h, qw( host_name status check_command ) );
ok( $h->status, "status returns a non-null value" );
can_ok( $s, qw( host_name service_description last_time_ok ) );

exit 0;