Sending Data Between Nagios Servers
-
optionstechnology
- Posts: 234
- Joined: Thu Nov 17, 2016 11:26 am
Re: Sending Data Between Nagios Servers
Any idea how to do it for non-state changing data?
Re: Sending Data Between Nagios Servers
You could probably define multiple ocsp_command and ochp_command each having the nrdp url pointing to respective client's nrdp server.
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
###### 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$"
}
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
}
-
optionstechnology
- Posts: 234
- Joined: Thu Nov 17, 2016 11:26 am
Re: Sending Data Between Nagios Servers
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-
It is correctly setup as an event handler-
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?
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/nrdpI'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?
You do not have the required permissions to view the files attached to this post.
Re: Sending Data Between Nagios Servers
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.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Re: Sending Data Between Nagios Servers
@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.
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.
-
optionstechnology
- Posts: 234
- Joined: Thu Nov 17, 2016 11:26 am
Re: Sending Data Between Nagios Servers
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?
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
@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?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
-
optionstechnology
- Posts: 234
- Joined: Thu Nov 17, 2016 11:26 am
Re: Sending Data Between Nagios Servers
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...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?
Is this something that can only be set in the config? Is it a global setting? Am I missing something here?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.
Re: Sending Data Between Nagios Servers
@@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.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Re: Sending Data Between Nagios Servers
@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.
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.
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$"
}
@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.