Bobcares

NCPA For Passive Checks – Using Nagios Remote Data Processor

by | May 16, 2021

Wondering about NCPA For Passive Checks? We can help you.

Passive checks reduce the load on the Nagios server by reducing the number of active checks run. They are also useful for security-related and asynchronous events we wish to monitor.

As part of our Server Management Services, we assist our customers with several Nagios queries.

Today, let us see how to configure the Nagios Cross-Platform Agent (NCPA) to send passive check results to Nagios XI or Nagios Core.

 

NCPA For Passive Checks

In order to begin, our Support Techs suggest having:

  • The NRDP listener must configure properly on the Nagios server
  • Implement SSL/TLS for NRDP.
  • The remote machine should have NCPA.

 

Configuration Files

NCPA supports multiple configuration files. This allows us to separate our configurations to allow for seamless upgrades.

We can find these files in:

  • Windows
    ◦ C:\Program Files (x86)\Nagios\NCPA\etc\ncpa.cfg
    ◦ C:\Program Files (x86)\Nagios\NCPA\etc\ncpa.cfg.d\
  • All Other
    ◦ /usr/local/ncpa/etc/ncpa.cfg
    ◦ /usr/local/ncpa/etc/ncpa.cfg.d/

 

Configure ncpa.cfg

First and foremost, we configure the ncpa.cfg file to send passive check results to Nagios [XI/Core] server using NRDP.

We need to provide the NRDP URL, NRDP Token, and hostname.

For example, here, we will use:

  • NRDP URL = https://10.25.5.21/nrdp/
  • NRDP Token = NRDP_T0k3n
  • hostname = S1601

Initially, we open the ncpa.cfg file in a text editor and locate the [passive] section:

[passive]
handlers = None

Then we configure handlers for NRDP:

[passive]
handlers = nrdp

In the same section we can find a sleep value:

sleep = 300

The default setting is 300 seconds (5 minutes). We can change this if we want to execute/send the passive checks in another time frame.

Then we locate the [nrdp] section:

[nrdp]
parent =
token =
hostname = NCPA 2

We update these values with the correct values for our environment.

For example,

[nrdp]
parent = https://10.25.5.21/nrdp/
token = NRDP_T0k3n
hostname = S1601

Eventually, we save and close the file.

 

Configure Passive Checks

Next, we need to create a configuration file that contains the passive check commands.

The NCPA installer gives an example file in the ncpa.cfg.d directory, example.cfg. We use it as a starting point for passive checks.

We create a copy of the example.cfg file called nrdp.cfg in the ncpa.cfg.d directory using the following steps:

a. Linux/Mac OS X/AIX

cd /usr/local/ncpa/etc/ncpa.cfg.d/
sudo cp example.cfg nrdp.cfg
sudo chown nagios:nagios nrdp.cfg

b. Windows

We open a command prompt with administrative rights and execute:

cd “C:\Program Files (x86)\Nagios\NCPA\etc\ncpa.cfg.d”
copy example.cfg nrdp.cfg

A prompt to overwrite nrdp.cfg means the file already exists. We do not need to overwrite it.

 

Define Passive Checks

When we open the nrdp.cfg file in any text editor we will see the following:

#[passive checks]

#%HOSTNAME%|__HOST__ = system/agent_version
#%HOSTNAME%|CPU Usage = cpu/percent –warning 60 –critical 80 –aggregate avg
#%HOSTNAME%|Swap Usage = memory/swap –warning 60 –critical 80 –units Gi
#%HOSTNAME%|Memory Usage = memory/virtual –warning 80 –critical 90 –units Gi
#%HOSTNAME%|Process Count = processes –warning 300 –critical 400

The # symbol means that they are commented out and are not being used. We need to simply remove the # symbol to make the checks active.

Ensure to remove the # before [passive checks] to enable passive checks.

Here, we can see that there is no disk usage check in the example file.

Here is an example of how we can add to the nrdp.cfg file the used disk space with a warning at 80% used and critical at 90% used.

a. Linux/Mac OS X/AIX

This example checks the disk space on the / (root) mount. In NCPA, all \ and / must represent as the | (pipe symbol).

#%HOSTNAME%|Disk Used root = disk/logical/|/used_percent –warning 80 –critical 90

b. Windows

This example checks the disk space on the E:\ drive. In NCPA, all \ and / must represent as | (pipe symbol).

#%HOSTNAME%|Disk Used E = /disk/logical/E:|/used_percent –warning 80 –critical 90

We cannot use the : (colon) in the service name. Otherwise, it will cause that command to fail.

Finally, we save and close the file.

 

Restart the Service

To apply the changes we made, we need to restart the NCPA Passive service. The command, however, will differ depending on the OS and version.

a. Windows

net stop ncpapassive
net start ncpapassive

b. RHEL/CentOS/Oracle Linux 5.x/6.x

service ncpa_passive restart

c. RHEL/CentOS/Oracle Linux 7.x

systemctl restart ncpa_passive.service

d. Ubuntu 12.x/13.x/14.x

sudo service ncpa_passive restart

e. Ubuntu 15.x+

sudo systemctl restart ncpa_passive.service

f. Debian 7.x

service ncpa_passive restart

g. Debian 8.x+

systemctl restart ncpa_passive.service

h. openSUSE/SUSE SLES 11.x

sudo /sbin/service ncpa_passive restart

i. openSUSE Leap 42.x+/SUSE SLES 12.x+

sudo systemctl restart ncpa_passive.service

j. AIX

stopsrc -s ncpa_passive
startsrc -s ncpa_passive

k. Mac OS X

sudo launchctl stop org.nagios.ncpa_passive
sudo launchctl start org.nagios.ncpa_passive

 

Check Nagios

Since we configured NCPA, it will start sending passive check results to our Nagios [XI/Core] server.

We can check to see if they have been received because they will be in the nagios.log file.

To check the log file, we execute the following command on our Nagios XI server:

grep ‘Error: Got’ /usr/local/nagios/var/nagios.log

Our output will be like this:

[1508380204] Error: Got host checkresult for ‘S1601’, but no such host can be found
[1508380204] Error: Got check result for service ‘CPU Usage’ on host ‘S1601’. Unable to find service
[1508380204] Error: Got check result for service ‘Disk Usage’ on host ‘S1601’. Unable to find service
[1508380204] Error: Got check result for service ‘Swap Usage’ on host ‘S1601’. Unable to find service
[1508380204] Error: Got check result for service ‘Memory Usage’ on host ‘S1601’. Unable to find service
[1508380204] Error: Got check result for service ‘Process Count’ on host ‘S1601’. Unable to find service
[1508380204] Error: Got check result for service ‘Disk Usage E’ on host ‘S1601’. Unable to find service

We don’t have to alarm ourselves due to the error messages. This occurs because Nagios [XI/Core] does not have any object definitions for these check results.

 

Configure Nagios

Now that Nagios [XI/Core] is receiving the check results, we need to create the host and service objects.

  • Adding Unconfigured Objects to Nagios XI

To add unconfigured objects to Nagios XI as host and service objects, we run the Unconfigured Passive Object wizard.

We can run this wizard in two ways:

  1. Add One Host with Services – Click the play button at the top right of the list for that host.
  2. Add Multiple Hosts with Services – In the list of unconfigured objects, check the box for each host that we want to add. Then click the gear icon at the bottom of the list.

The list of hosts that will have services created will appear in the summary list. We can run through the wizard and select the preferred settings and Apply.

Then we click the View status details for xxx link which should direct us to a screen.

Eventually, the host and its services will no longer appear under the unconfigured objects section.

  • Passive host and service definitions in Nagios Core

The Passive NRDP checks will not appear anywhere in Nagios until we define host and service definitions.

The following Nagios Definitions will result in:

  1. A Passive Host object for the server S1601
  2. Passive Service objects for the server S1601 for the services

a. Command

define command {
command_name check_dummy
command_line $USER1$/check_dummy $ARG1$
}

b. Templates

Host

define host {
use generic-host
name passive_host
active_checks_enabled 0
passive_checks_enabled 1
flap_detection_enabled 0
register 0
check_period 24×7
max_check_attempts 1
check_interval 5
retry_interval 1
check_freshness 0
contact_groups admins
check_command check_dummy!0
notification_interval 60
notification_period 24×7
notification_options d,u,r
}

Service

define service {
use generic-service
name passive_service
active_checks_enabled 0
passive_checks_enabled 1
flap_detection_enabled 0
register 0
check_period 24×7
max_check_attempts 1
check_interval 5
retry_interval 1
check_freshness 0
contact_groups admins
check_command check_dummy!0
notification_interval 60
notification_period 24×7
notification_options w,u,c,r
}

c. Host Definition

define host {
use passive_host
host_name S1601
}

d. Service Definitions

CPU Usage

define service {
use passive_service
service_description CPU Usage
host_name S1601
}

Disk Usage

define service {
use passive_service
service_description Disk Usage
host_name S1601
}

Swap Usage

define service {
use passive_service
service_description Swap Usage
host_name S1601
}

Memory Usage

define service {
use passive_service
service_description Memory Usage
host_name S1601
}

Process Count

define service {
use passive_service
service_description Process Count
host_name S1601
}

Once we create the objects in Nagios [XI/Core], we will be successfully using NCPA for passive checks.

[Need help with the configuration? We’d be happy to assist]

 

Conclusion

To conclude, we saw how our Support Techs configure NCPA For Passive Checks.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF