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 printf 'jupiter\t0\tresult 1\n' >input
35 printf 'jupiter\t0\tresult 2\n' >>input
37 printf 'jupiter\t0\tresult 3\n' >>input
38 NSCA_CHECK([input], [dnl
39 PROCESS_HOST_CHECK_RESULT;jupiter;0;result 1
40 PROCESS_HOST_CHECK_RESULT;jupiter;0;result 2
41 PROCESS_HOST_CHECK_RESULT;jupiter;0;result 3], [], [], [], [], [], [0], [3])
44 AT_SETUP([Multiple results, colon-separated])
45 printf 'jupiter\t0\tresult 1\n' >input
47 printf 'jupiter\t0\tresult 2\n' >>input
49 printf 'jupiter\t0\tresult 3\n' >>input
50 NSCA_CHECK([input], [dnl
51 PROCESS_HOST_CHECK_RESULT;jupiter;0;result 1
52 PROCESS_HOST_CHECK_RESULT;jupiter;0;result 2
53 PROCESS_HOST_CHECK_RESULT;jupiter;0;result 3], [], [-e :], [], [], [], [0], [3])
56 AT_SETUP([Multiple monitoring commands])
57 cat >input <<'NSCA_EOF'
58 PROCESS_HOST_CHECK_RESULT;saturn;0;result 1
59 PROCESS_HOST_CHECK_RESULT;saturn;0;result 2
60 PROCESS_HOST_CHECK_RESULT;saturn;0;result 3
63 NSCA_CHECK([input], [expout], [], [-C], [], [], [], [0], [3])
66 AT_SETUP([Result with trailing ETB and newline])
67 printf 'jupiter\t0\tjupiter is alive\n' >input
68 printf '\27\n' >>input
69 NSCA_CHECK([input], [PROCESS_HOST_CHECK_RESULT;jupiter;0;jupiter is alive])
72 AT_SETUP([Incorrect input format])
73 NSCA_CHECK([garbage], [],
74 [[send_nsca: [FATAL] Input format incorrect, see the send_nsca(8) man page]],
78 AT_SETUP([Data size exceeds max_command_size])
79 NSCA_CHECK([jupiter 0 jupiter is alive], [],
80 [[send_nsca: [FATAL] Server said: FAIL PUSH data size too large]], [], [], [],
81 [max_command_size = 10
83 password = "forty-two"
88 AT_SETUP([Data size exceeds PIPE_BUF])
90 `printf "jupiter 0 %0${nsca_pipe_buf}d" 1`
92 AT_CAPTURE_FILE([server.cfg])
93 cat >server.cfg <<NSCA_EOF
94 temp_directory = "`pwd`"
97 password = "forty-two"
101 NSCA_CHECK([input], [stdout])
102 AT_CHECK([[grep "^PROCESS_FILE;`pwd`/nsca\..\{6\};1$" stdout]], [0], [ignore])
105 dnl vim:set joinspaces textwidth=80 filetype=m4: