Page 1 of 1

NDRP - Send output from 1 nagios core to 2 nagiosXI servers

Posted: Fri Jul 02, 2021 9:24 am
by dberlenda
Hello ,
I success installalled NRDP and now I send the output of services monitored by my nagios core to nagiosXI with NRDP .
In my landscape I have 2 nagiosXI servers , one for dev and test system and another for production systems.
In some remote sites I have installed nagios core servees with svil , test and prod system monitored .


I tried without succcess to creare in the command.cfg 2 commands and add the follow line in the nagios.cfg file :
nagios.cfg :

# NRDP Send Data to NagiosXI
ochp_command=send_nrdp_host , send_nrdp_host_prod
ocsp_command=send_nrdp_service , send_nrdp_service_prod


command.cfg

define command{
command_name send_nrdp_host
command_line $USER1$/send_nrdp.php --url=http://xxx.xxx.xxx.xxx/nrdp/ --token=mytoken --host="$HOSTNAME$" --state=$HOSTSTATEID$ --output="$HOSTOUTPUT$"
}
define command{
command_name send_nrdp_service
command_line $USER1$/send_nrdp.php --url=http://xxx.xxx.xxx.xxx/nrdp/ --token=mytoken --host="$HOSTNAME$" --service="$SERVICEDESC$" --state=$SERVICESTATEID$ --output="$SERVICEOUTPUT$"
}

command_name send_nrdp_host_prod
command_line $USER1$/send_nrdp.php --url=http://xxx.xxx.xxx.xxx/nrdp/ --token=mytoken --host="$HOSTNAME$" --state=$HOSTSTATEID$ --output="$HOSTOUTPUT$"
}
define command{
command_name send_nrdp_service_prod
command_line $USER1$/send_nrdp.php --url=http://xxx.xxx.xxx.xxx/nrdp/ --token=mytoken --host="$HOSTNAME$" --service="$SERVICEDESC$" --state=$SERVICESTATEID$ --output="$SERVICEOUTPUT$"
}


This is possible to send the output of services monitored by nagios core to 2 nagiosXI servers wth NRDP ?

Thanks in advance
Davide

Re: NDRP - Send output from 1 nagios core to 2 nagiosXI serv

Posted: Tue Jul 06, 2021 11:38 am
by gsmith
Hi

Here's what I came up with. I create a command that calls a script that runs the send_nrdp command twice, once for each server.

So on the core machine I edited commands.cfg to add:

Code: Select all

define command {
        command_name    nrdptwice
        command_line    $USER1$/nrdptwice $HOSTALIAS$ $HOSTSTATEID$ $HOSTOUTPUT$
}
I edited localhost.cfg and changed the host alias:

Code: Select all

define host {

    use                     linux-server            ; Name of host template to use
                                                    ; This host definition will inherit all variables that are defined
                                                    ; in (or inherited by) the linux-server host template definition.
    host_name               localhost
    alias                   mycoreserver
    address                 127.0.0.1
}
and I defined a service:

Code: Select all

define service {

    use                     local-service           ; Name of service template to use
    host_name               localhost
    service_description     nrdp2
    check_command           nrdptwice
}

in /usr/local/nagios/libexec I created a file called "nrdptwice":

Code: Select all

#!/bin/sh

/usr/local/nrdp/clients/send_nrdp.php --url=http://192.168.23.81/nrdp/ --token=nrdptoken --host=$1  --state=$2 --output=$3
/usr/local/nrdp/clients/send_nrdp.php --url=http://192.168.23.82/nrdp/ --token=nrdptoken --host=$1  --state=$2 --output=$3
Give that a try.

Thanks