Page 1 of 2
Exec plugin in nagios logserver
Posted: Tue Aug 22, 2017 11:30 am
by saleemthupsee
Hello,
i am using the exec plugin to execute a script send_nrdp.sh to send customized output messages to nagiosxi. I use the command in the output filter and it does not work. i use the same command on the command line, it works. I've treid detach it breaks nagioslogserver on memory.
(simple exec commands ls-al to a text file from the output filter works by the way)
Is there a way to resolve this issue ?
Saleem
Re: Exec plugin in nagios logserver
Posted: Tue Aug 22, 2017 11:35 am
by scottwilkerson
Can you share the full command you are trying to execute (obfuscating any sensitive data) so we can test this here.
Being simple commands work, I have a feeling it may be a permissions issue.
Re: Exec plugin in nagios logserver
Posted: Wed Aug 23, 2017 2:33 am
by saleemthupsee
in filter outputs
the following code:
exec {
command => "/usr/bin/send_nrdp.sh -u
https://192.168.97.2/nrdp -t ########### -H localhost -s RTL9 -S 2 -o testfromlogserver {} \;"
}
i have replaced the token by ##########
Saleem
Re: Exec plugin in nagios logserver
Posted: Wed Aug 23, 2017 9:00 am
by scottwilkerson
To be clear, can you run this from the command line on your Log Server and have it arrive?
Also, can you share the following command permission results:
Re: Exec plugin in nagios logserver
Posted: Wed Aug 23, 2017 11:44 am
by saleemthupsee
please see below
-rwxr-xr-x 1 root root 8559 Aug 22 17:31 /usr/bin/send_nrdp.sh
Re: Exec plugin in nagios logserver
Posted: Wed Aug 23, 2017 11:53 am
by cdienger
There could be a command within the script that fails due to permissions or you may need to specify the full path. The script isn't run as root when it is run by NLS so you'll have to take that into account. Can you share the script?
Re: Exec plugin in nagios logserver
Posted: Thu Aug 24, 2017 6:58 am
by saleemthupsee
please see attached
Re: Exec plugin in nagios logserver
Posted: Thu Aug 24, 2017 8:32 am
by tacolover101
nice plugin @scottwilkerson
are you sure your logic is actually triggering? from what you've mentioned it seems like it should be working if it's not permissions.
Re: Exec plugin in nagios logserver
Posted: Thu Aug 24, 2017 9:06 am
by mcapra
It might also be useful to share your Logstash logs to see if the
exec plugin is failing for some reason. They can typically be found in:
Re: Exec plugin in nagios logserver
Posted: Thu Aug 24, 2017 9:46 am
by saleemthupsee
i have verified once more the execution of the exec command by substituting the command echo to a text file. the parameters passed on the script through fields i.e %{fieldname} are not replaced by their field contents. i only have the output %{fieldname} in plain text in the text file instead of the contents of the fieldname being replaced in text file.
Anything wrong in my syntax. I checked through logstash 1.5 doc. to use %{fieldname} to gather the variables. the example is
command => "iptables -A INPUT -s %{clientip} -j DROP"
mine is :
exec {
command => "/usr/local/nagioslogserver/scripts/send_nrdp.sh -su
http://192.168.97.2/nrdp -t ######## -H localhost -s %{channel_name} -S %{sh_status} -o testfromlogserver"
}