On Sat, 27 Jun 2015, Horatiu N wrote:

> Hello,
> 
> I needed to make my own CheckCommand definition and also a custom bash
> script in my PluginDir to check for openvpn availability. I'm using a
> bash script that calls nmap and does some logic then prints some output
> and exits with code 0 on success and 2 on error. But it's not working as
> i'd like it to.
> 
> my CheckCommand looks like this
> 
> > 
> > object CheckCommand "check-openvpn" {
> >         import "plugin-check-command"
> >         import "ipv4-or-ipv6"
> > 
> >         vars.ip_protocol = {{
> >                 var tcp = macro("$openvpn_tcp_port$")
> >                 var udp = macro("$openvpn_udp_port$")
> > 
> >                 if (tcp) {
> >                         vars.ip_protocol = "-sS -nn -p T:" + tcp
^^^^
> >                         return 
> >                 } else {
> >                         vars.ip_protocol = "-sU -nn -p U:" + udp
^^^^^

That doesn't work. There is no shell involved and therefore no wordsplitting
does happen. That means that "-sU -nn -p U:" reaches your script as 1
parameter. Exactly like if you would the script like ./script '-sU -nn -p U:'

You will have to create an array of your parameters. Like 
vars.ip_protocol = [ '-sU', '-nn', '-p', 'U:' + udp ]

*snip*
> > [2015-06-27 21:53:18 +0300] warning/PluginCheckTask: Check command for 
> > object 'my-host-addr!openvpn' (PID: 15256, arguments: 
> > '/usr/lib/nagios/plugins/check_openvpn' '-h' 'ip.address.of.host') 
> > terminated with exit code 4, output: -h ip.address.of.host
> > Usage: /usr/lib/nagios/plugins/check_openvpn -h <host> -p <parameters>
> 
> So i'd like to manually run that checkcommand somehow, to figure out
> where i went wrong, to see what values the vars have, etc, as i'd do
> with bash for instance bash -x script.sh
> 
> I'm really in the dark with this one, any help appreciated. Thank you :)
for debuggin a simple bash wrapper that logs $@ is really helpful. That will
show you the parameters that reached your script and how they reached it.

Alex

_______________________________________________
icinga-users mailing list
icinga-users@lists.icinga.org
https://lists.icinga.org/mailman/listinfo/icinga-users

Reply via email to