Page 2 of 6
Re: Sending Data Between Nagios Servers
Posted: Mon May 28, 2018 10:29 am
by optionstechnology
Any idea how to do it for non-state changing data?
Re: Sending Data Between Nagios Servers
Posted: Tue May 29, 2018 12:19 am
by vazudevan
You could probably define multiple ocsp_command and ochp_command each having the nrdp url pointing to respective client's nrdp server.
Code: Select all
###### Client 1
define command{
command_name send_nrdp_host_client1
command_line /usr/bin/php $USER1$/send_nrdp.php --url=http://client1.nagios.server/nrdp/ --token= client1token --host="$HOSTNAME$" --state=$HOSTSTATEID$ --output="$HOSTOUTPUT$|$HOSTPERFDATA$"
}
define command{
command_name send_nrdp_service_client1
command_line /usr/bin/php $USER1$/send_nrdp.php --url=http://client1.nagios.server/nrdp/ --token= client1token --host="$HOSTNAME$" --service="$SERVICEDESC$" --state=$SERVICESTATEID$ --output="$SERVICEOUTPUT$|$SERVICEPERFDATA$"
}
########## Client 2
define command{
command_name send_nrdp_host_client2
command_line /usr/bin/php $USER1$/send_nrdp.php --url=http://client2.nagios.server/nrdp/ --token=client2token --host="$HOSTNAME$" --state=$HOSTSTATEID$ --output="$HOSTOUTPUT$|$HOSTPERFDATA$"
}
define command{
command_name send_nrdp_service_client2
command_line /usr/bin/php $USER1$/send_nrdp.php --url=http://client2.nagios.server/nrdp/ --token=client2token --host="$HOSTNAME$" --service="$SERVICEDESC$" --state=$SERVICESTATEID$ --output="$SERVICEOUTPUT$|$SERVICEPERFDATA$"
}
And in the corresponding host / service definition, you can specify the corresponding oscp_command and ochp_command. (Specifiying command at host / service level will override the global setting, thereby you can achieve what you are looking for..)
Code: Select all
###### Cleint 1
define host {
...
ochp_command send_nrdp_host_client1
}
define service {
...
oscp_command send_nrdp_service_client1
}
##### Client 2
define host {
...
ochp_command send_nrdp_host_client2
}
define service {
...
oscp_command send_nrdp_service_client2
}
Re: Sending Data Between Nagios Servers
Posted: Tue May 29, 2018 9:40 am
by optionstechnology
Thanks for that
@vazudevan
I actually ended up using the send_nrdp.sh command to do the same thing, although its working from the command line - but not as an event handler
I tried hard coding the results to see if the macros were causing the issue -
send_nrdp_service
/usr/local/nrdp/clients/send_nrdp.sh -u
https://NAGSERVER.com/nrdp -t TOKEN -H HOSTNAME -s "Port - WAN Test" -S ok -o "This is a test from event handler"
When I run it from command line it works fine-
Code: Select all
[nagios@NAGSERVER /]$ /usr/local/nrdp/clients/send_nrdp.sh -u https://NAGSERVER.com/nrdp -t TOKEN -H HOSTNAME -s "Port - WAN Test" -S ok -o "This is a test from command line"
Sent 1 checks to https://NAGSERVER.com/nrdp
commandline.PNG
It is correctly setup as an event handler-
settings.PNG
I've used a dummy check to easily change the state - but no matter what state change the event handler never activates
Any idea what the issue could be?
Re: Sending Data Between Nagios Servers
Posted: Tue May 29, 2018 12:33 pm
by cdienger
Make sure obsess_over_hosts and obsess_over_services are also set to 1 in the nagios.cfg. Restart the nagios service too after making any changes to nagios.cfg file.
Re: Sending Data Between Nagios Servers
Posted: Wed May 30, 2018 12:28 am
by vazudevan
@optionstechnology In my opinion the best way would be to use ocsp and ohcp commands. For these commands to work, obsess_over_hosts and obsess_over_services needs to be enabled in nagios.cfg as
@cdienger mentioned.
Event handler will not be able to send data while state remains unchanging, whereas ocsp and ochp (obsess_over) will continue and send data for every time the check is executed. We are using send_nrdp.php in the above combinations and it works perfectly for us to transport realtime status info from one server to another.
Re: Sending Data Between Nagios Servers
Posted: Wed May 30, 2018 3:53 am
by optionstechnology
Ahh ok, I understand now! Yes this is exactly what I was looking for, thanks
@vazudevan
One final question - how do I set these ochp and ocsp commands using the XI front end?
is it under Global Event Handlers??? Or is it just whatever script is in the event_handler dropdown?
Re: Sending Data Between Nagios Servers
Posted: Wed May 30, 2018 2:37 pm
by cdienger
@vazudevan, I'm curious about you're setup as well. It seems like it would require adding static config(Configure > Core Config > Manager > Tools > Static Config Editor) and from my testing the ocsp_command isn't available for service defintions(
https://assets.nagios.com/downloads/nag ... sp_command). Did you take any additional steps to get it to work in your environment?
Re: Sending Data Between Nagios Servers
Posted: Fri Jun 01, 2018 4:35 am
by optionstechnology
cdienger wrote:@vazudevan, I'm curious about you're setup as well. It seems like it would require adding static config(Configure > Core Config > Manager > Tools > Static Config Editor) and from my testing the ocsp_command isn't available for service defintions(
https://assets.nagios.com/downloads/nag ... sp_command). Did you take any additional steps to get it to work in your environment?
Pending
@vazudevans reply here
@cdienger, if that's not how the ocsp_command= functions... then how does it function? It sounds like exactly what I'm looking for - but I cannot find anywhere in the front end where I can specify it for a service...
Obsessive Compulsive Service Processor Command
Format: ocsp_command=<command>
Example: ocsp_command=obsessive_service_handler
This option allows you to specify a command to be run after every service check, which can be useful in distributed monitoring. This command is executed after any event handler or notification commands. The command argument is the short name of a command definition that you define in your object configuration file. The maximum amount of time that this command can run is controlled by the ocsp_timeout option. More information on distributed monitoring can be found here. This command is only executed if the obsess_over_services option is enabled globally and if the obsess_over_service directive in the service definition is enabled.
Is this something that can only be set in the config? Is it a global setting? Am I missing something here?
Re: Sending Data Between Nagios Servers
Posted: Fri Jun 01, 2018 1:25 pm
by cdienger
@
@optionstechnology - No, I don't think you're missing anything, but I don't see how this could be done. The option is for the main config file(naigos.cfg) which makes it global. Trying to set it in a service definition results in an error. Perhaps it can be done, but it wouldn't be a typical setup.
Re: Sending Data Between Nagios Servers
Posted: Sat Jun 02, 2018 5:54 am
by vazudevan
@optionstechnology ,
@cdienger I realise now, I managed to get it as I am using Nagios Core and have the flexibility of setting individual ocsp, and ochp commands overriding global settings. Each of the cores send the check results to the central XI.
In the absence of configuring command in XI interface, this is what I propose for you to achieve what you are looking for.
Add two custom variables _CUSTNAG, _CUSTTOKEN or similar for hosts and services, and mention the nagios url in the custom variable and token like (
http://client1.nagios.server/nrdp/ and client1token). Modify the send_nrdp_host and send_nrpd_service commands to reflect as below.
Code: Select all
######
define command{
command_name send_nrdp_host
command_line /usr/bin/php $USER1$/send_nrdp.php --url="$_CUSTNAG$" --token="$_CUSTTOKEN$" --host="$HOSTNAME$" --state=$HOSTSTATEID$ --output="$HOSTOUTPUT$|$HOSTPERFDATA$"
}
define command{
command_name send_nrdp_service
command_line /usr/bin/php $USER1$/send_nrdp.php --url="$_CUSTNAG$" --token="$_CUSTTOKEN$" --host="$HOSTNAME$" --service="$SERVICEDESC$" --state=$SERVICESTATEID$ --output="$SERVICEOUTPUT$|$SERVICEPERFDATA$"
}
The above trick should work for you with the global send_nrdp.php command and setting obsess_over_hosts and obsess_over_services. If any host or service does not have the custom variable defined, you will end up finding error messages in nagios.log file for them. You can avoid such errors by using a wrapper script around the send_nrdp.php. Probably a customer specific template will make your life easier.
@cdiengerA field be made available for ocsp and ochp commands in the web interface of XI, would be the best. Please raise a feature request.