ERROR: The NRDP Server said NO TOKENS

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
optionstechnology
Posts: 228
Joined: Thu Nov 17, 2016 11:26 am

ERROR: The NRDP Server said NO TOKENS

Post by optionstechnology »

I am setting up an NRDP forwarder between two nagios servers, however, nothing is showing up in Unconfigured Objects.

I have tested locally on the box using:

Code: Select all

/usr/local/nrdp/clients/send_nrdp.sh -u https://127.0.0.1/nrdp -t MYTOKEN -H "testfromlocal" -S 0 -o "This is test 1"
This works - I can see "testfromlocal" show up in the unconfigured objects


When I try from the remote server using:

Code: Select all

 /usr/local/nrdp/clients/send_nrdp.sh -u https://OTHERSERVERIP/nrdp -t MYTOKEN -H "testfromremote" -S 0 -o "This is test 1"
I get:

ERROR: The NRDP Server said NO TOKENS

This is a very strange error..... because if it was an incorrect token it would say BAD TOKEN, and if I didn't supply a token as it is suggesting then it would fail locally and not even execute.

So it seems like it has the TOKEN when it first runs the script locally, but by the time it gets to the remote side the token is gone....

Any idea what could be causing this?

I can telnet on port 443 fine, no issues there
dchurch
Posts: 858
Joined: Wed Oct 07, 2020 12:46 pm
Location: Yo mama

Re: ERROR: The NRDP Server said NO TOKENS

Post by dchurch »

If your token contains shell meta-characters such as $ [ ] ( ) { } | ` ~ & # * ! ' " \ < > ?, try enclosing it in quotes:

Code: Select all

    /usr/local/nrdp/clients/send_nrdp.sh -u https://127.0.0.1/nrdp -t 'MYTOKEN' -H "testfromlocal" -S 0 -o "This is test 1"
If it contains a single-quote, you'll want to replace it with '\'' (four characters), e.g. foo's bar => 'foo'\''s bar'.
If you didn't get an 8% raise over the course of the pandemic, you took a pay cut.

Discussion of wages is protected speech under the National Labor Relations Act, and no employer can tell you you can't disclose your pay with your fellow employees.
optionstechnology
Posts: 228
Joined: Thu Nov 17, 2016 11:26 am

Re: ERROR: The NRDP Server said NO TOKENS

Post by optionstechnology »

It has no special characters in it

I've also tried double quotes around it but no luck
dchurch
Posts: 858
Joined: Wed Oct 07, 2020 12:46 pm
Location: Yo mama

Re: ERROR: The NRDP Server said NO TOKENS

Post by dchurch »

Try editing /usr/local/nrdp/server/config.inc.php and adding array entries to the $cfg['authorized_tokens'] array.

For example:

Code: Select all

$cfg['authorized_tokens'] = array("Token_here", "another_token_here", "yet_another_token");
If you didn't get an 8% raise over the course of the pandemic, you took a pay cut.

Discussion of wages is protected speech under the National Labor Relations Act, and no employer can tell you you can't disclose your pay with your fellow employees.
optionstechnology
Posts: 228
Joined: Thu Nov 17, 2016 11:26 am

Re: ERROR: The NRDP Server said NO TOKENS

Post by optionstechnology »

Its accepting the token, I know this because it accepts the token when i run it locally

the issue is that the token does not even get passed
dchurch
Posts: 858
Joined: Wed Oct 07, 2020 12:46 pm
Location: Yo mama

Re: ERROR: The NRDP Server said NO TOKENS

Post by dchurch »

Can you please modify /usr/local/nrdp/server/config.inc.php on the NRPE machine and change

Code: Select all

$cfg["debug"] = false;
to

Code: Select all

$cfg["debug"] = true;
Then please run this command from the remote server (i.e. the one not running nrpe) and give back the result?

Code: Select all

curl -f --silent --insecure -d "token=MYTOKEN&cmd=submitcheck&xml=<?xml version='1.0'?><checkresults><checkresult type='host' checktype='1'><hostname>testfromremote</hostname><state>0</state><output><![CDATA[This is test 1]]></output></checkresult></checkresults>" 'https://OTHERSERVERIP/nrdp/'
(of course replacing OTHERSERVERIP and MYTOKEN)
If you didn't get an 8% raise over the course of the pandemic, you took a pay cut.

Discussion of wages is protected speech under the National Labor Relations Act, and no employer can tell you you can't disclose your pay with your fellow employees.
optionstechnology
Posts: 228
Joined: Thu Nov 17, 2016 11:26 am

Re: ERROR: The NRDP Server said NO TOKENS

Post by optionstechnology »

This is the reply I get-

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<result>
    <status>-1</status>
    <message>NO TOKENS</message>
</result>
dchurch
Posts: 858
Joined: Wed Oct 07, 2020 12:46 pm
Location: Yo mama

Re: ERROR: The NRDP Server said NO TOKENS

Post by dchurch »

What is the output from the following command?

Code: Select all

grep -rF "\$cfg['authorized_tokens']" /usr/local
If you didn't get an 8% raise over the course of the pandemic, you took a pay cut.

Discussion of wages is protected speech under the National Labor Relations Act, and no employer can tell you you can't disclose your pay with your fellow employees.
optionstechnology
Posts: 228
Joined: Thu Nov 17, 2016 11:26 am

Re: ERROR: The NRDP Server said NO TOKENS

Post by optionstechnology »

Code: Select all

/usr/local/nrdp/server/includes/utils.inc.php:        _debug(" * token ($user_token) not in \$cfg['authorized_tokens'], denying token");
/usr/local/nrdp/server/config.inc.php:$cfg['authorized_tokens'] = array("MYTOKEN",);
/usr/local/nagiosxi/html/includes/components/nrdsconfigmanager/nrdsconfigmanager.php:    if (!isset($cfg['authorized_tokens'][0])) {
/usr/local/nagiosxi/html/includes/components/nrdsconfigmanager/nrdsconfigmanager.php:    if (!isset($cfg['authorized_tokens'][0])) {
/usr/local/nagiosxi/html/includes/components/nrdsconfigmanager/nrdsconfigmanager.php:                        foreach ($cfg['authorized_tokens'] as $token) {
/usr/local/nagiosxi/html/admin/dtinbound.php:    $replace = "\\\$cfg['authorized_tokens'] = $token_str";
gsmith
Posts: 1253
Joined: Tue Mar 02, 2021 11:15 am

Re: ERROR: The NRDP Server said NO TOKENS

Post by gsmith »

Hi,

Please provide us with this file: /usr/local/nrdp/server/config.inc.php

Thanks
Locked