30 "H|hostname=s" => \$o{hostname}, |
30 "H|hostname=s" => \$o{hostname}, |
31 "S|servicename=s" => \$o{svcname}, |
31 "S|servicename=s" => \$o{svcname}, |
32 "nsca-host=s" => \$o{nsca_host}, |
32 "nsca-host=s" => \$o{nsca_host}, |
33 "p|nsca-port=i" => \$o{nsca_port}, |
33 "p|nsca-port=i" => \$o{nsca_port}, |
34 "h|help" => sub { pod2usage(-verbose => 1, -exit => 0) }, |
34 "h|help" => sub { pod2usage(-verbose => 1, -exit => 0) }, |
35 "man" => sub { |
35 "m|man" => sub { |
36 pod2usage( |
36 pod2usage( |
37 -verbose => 2, |
37 -verbose => 2, |
38 -exit => 0, |
38 -exit => 0, |
39 -noperldoc => system("perldoc -V 2>/dev/null 1>/dev/null") |
39 -noperldoc => system("perldoc -V 2>/dev/null 1>/dev/null") |
40 ); |
40 ); |
41 }, |
41 }, |
42 "d|debug" => \$o{debug}, |
42 "d|debug" => \$o{debug}, |
43 ) or pod2Usage(); |
43 ) or pod2usage(); |
44 |
44 |
45 my $cmdline = |
45 my $cmdline = |
46 "send_nsca -H '$o{nsca_host}'" |
46 "send_nsca -H '$o{nsca_host}'" |
47 . (defined $o{nsca_port} ? " -p $o{nsca_port}" : ""); |
47 . (defined $o{nsca_port} ? " -p $o{nsca_port}" : ""); |
48 |
48 |
68 |
68 |
69 } |
69 } |
70 |
70 |
71 __END__ |
71 __END__ |
72 |
72 |
73 set +e |
73 =head1 NAME |
74 |
74 |
75 output=$("$@") |
75 submit-via-nsca - submit service, or host check results via nsca |
76 rc=$? |
|
77 |
76 |
78 test "$svcname" || svcname="${output%% *}" |
77 =head1 SYNOPSIS |
79 |
78 |
80 tab=$'\x09' |
79 submit-via nsca --nsca-host {host} [options] -- {check} [check-options] |
81 echo "$hostname$tab$svcname$tab$rc$tab$output" \ |
|
82 | $send -H "$nsca_host" ${nsca_port:+-p $nsca_port} |
|
83 |
80 |
84 # vim:sts=4 sw=4 aw ai sm et: |
81 =head1 DESCRIPTION |
|
82 |
|
83 This simple script submits the result of nagios check plugins to an NSCA |
|
84 receiver. The script does not send the result itself, it's merely a |
|
85 wrapper around C<send_nsca>. |
|
86 |
|
87 =head1 OPTIONS |
|
88 |
|
89 =over |
|
90 |
|
91 =item B<-H> | B<--hostname> I<hostname> |
|
92 |
|
93 The hostname to be sent along with the result. (defaults to the local |
|
94 host name). |
|
95 |
|
96 =item B<-S> | B<--servicename> I<servicename> |
|
97 |
|
98 The servicename to be sent along with the result. If a single "-" (dash) |
|
99 is used, the servicename is guessed from service check output, if "" |
|
100 (empty), a host check is submitted. (default: "-") |
|
101 |
|
102 =item B<--nsca-host> I<hostname> |
|
103 |
|
104 The destination host (the host, where the NSCA listener is running). |
|
105 (no default). |
|
106 |
|
107 =item B<--nsca-port> I<port> |
|
108 |
|
109 The destination port. (default depends on the C<send_nsca> utility) |
|
110 |
|
111 =item B<-h> | B<--help> |
|
112 |
|
113 =item B<-m> | B<--man> |
|
114 |
|
115 The long or short help text. |
|
116 |
|
117 =back |
|
118 |
|
119 =head1 AUTHORS |
|
120 |
|
121 Heiko Schlittermann L<mailto:hs@schlittermann.de>, the source can be |
|
122 found at L<https://ssl.schlittermann.de/hg/submit-via-nsca>. |