1 # Copyright (c) 2013 Holger Weiss <holger@weiss.in-berlin.de>
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are met:
7 # 1. Redistributions of source code must retain the above copyright notice, this
8 # list of conditions and the following disclaimer.
10 # 2. Redistributions in binary form must reproduce the above copyright notice,
11 # this list of conditions and the following disclaimer in the documentation
12 # and/or other materials provided with the distribution.
14 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
18 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20 # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
21 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
22 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 AT_BANNER([Unusual input.])
27 AT_SETUP([Multiline check result])
28 NSCA_CHECK([jupiter 0 jupiter
29 is alive], [PROCESS_HOST_CHECK_RESULT;jupiter;0;jupiter\n is alive])
32 AT_SETUP([Multiple check results])
33 AT_CAPTURE_FILE([input])
34 printf 'jupiter\t0\tresult 1\n' >input
36 printf 'jupiter\t0\tresult 2\n' >>input
38 printf 'jupiter\t0\tresult 3\n' >>input
39 AT_CAPTURE_FILE([expout])
40 printf 'PROCESS_HOST_CHECK_RESULT;jupiter;0;result 1\n' >expout
41 printf 'PROCESS_HOST_CHECK_RESULT;jupiter;0;result 2\n' >>expout
42 printf 'PROCESS_HOST_CHECK_RESULT;jupiter;0;result 3\n' >>expout
43 NSCA_CHECK([], [expout], [], [], [], [], [], [0], [3])
46 AT_SETUP([Multiple monitoring commands])
47 AT_CAPTURE_FILE([input])
48 printf 'PROCESS_HOST_CHECK_RESULT;saturn;0;result 1\n' >input
49 printf 'PROCESS_HOST_CHECK_RESULT;saturn;0;result 2\n' >>input
50 printf 'PROCESS_HOST_CHECK_RESULT;saturn;0;result 3\n' >>input
51 AT_CAPTURE_FILE([expout])
53 NSCA_CHECK([], [expout], [], [-C], [], [], [], [0], [3])
56 AT_SETUP([Incorrect input format])
57 NSCA_CHECK([garbage], [],
58 [[send_nsca: [FATAL] Input format incorrect, see the send_nsca(8) man page]],
62 AT_SETUP([Data size exceeds max_command_size])
63 NSCA_CHECK([jupiter 0 jupiter is alive], [],
64 [[send_nsca: [FATAL] Server said: FAIL PUSH data size too large]],
66 [max_command_size = 10
68 password = "forty-two"
73 AT_SETUP([Data size exceeds PIPE_BUF])
74 AT_CAPTURE_FILE([input])
76 `printf "jupiter 0 %0${nsca_pipe_buf}d" 1`
78 AT_CAPTURE_FILE([server.cfg])
79 cat >server.cfg <<NSCA_EOF
83 password = "forty-two"
87 NSCA_CHECK([], [stdout])
88 AT_CHECK([[grep "^PROCESS_FILE;`pwd`/nsca\..\{6\};1$" stdout]], [0], [ignore])
91 dnl vim:set joinspaces textwidth=80 filetype=m4: