File: multiple.t

package info (click to toggle)
nsca 2.10.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 868 kB
  • sloc: sh: 3,161; ansic: 2,351; perl: 195; makefile: 128
file content (50 lines) | stat: -rwxr-xr-x 893 bytes parent folder | download | duplicates (8)
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
#!/usr/bin/perl
#
# DESCRIPTION:
#       Test sending more than one passive result to nsca
#
# COPYRIGHT:
#       Copyright (C) 2007 Altinity Limited
#       Copyright is freely given to Ethan Galstad if included in the NSCA distribution
#
# LICENCE:
#       GNU GPLv2


use strict;
use NSCATest;
use Test::More;
use Clone qw(clone);

my $iterations = 10;

plan tests => 2;

my $data = [
	["hostname", "0", "Plugin output"],
	["host", "service", 0, "A good result here"],
	];

my $copies = [];
for (1 .. $iterations) {
	my $c = clone($data);
	push @$copies, @$c;
}

foreach my $type qw(--single --daemon) {
	my $nsca = NSCATest->new( config => "basic" );

	$nsca->start($type);

	my $i = 0;
	for($i; $i < $iterations; $i++) {
		$nsca->send($data);
	}
	sleep 1;		# Need to wait for --daemon to finish processing

	my $output = $nsca->read_cmd;

	is_deeply( $output, $copies );

	$nsca->stop;
}