Newbie Question: Handlers

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
TCN-Link
Posts: 30
Joined: Tue Dec 13, 2016 2:05 pm

Newbie Question: Handlers

Post by TCN-Link »

Hello, all.

I've read over the documentation on setting up handlers in Nagios XI and I have a few questions.
  • Since nearly all of our checks are going to be passive, how does that translate when setting the handler up on the server?
  • What does the client look for when obtaining information to report on the Nagios XI server? Should my scripts create a text file in a certain format, syntax, and nomenclature or is there something else?
  • Where is your documentation on reporting and how to set reports up based on whatever we want or scripts to report on?
Thank you,
Link
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Newbie Question: Handlers

Post by rkennedy »

- Take a look at this document which explains passive checks, the one part you'll want to focus on is the freshness threshold as this will allow you to specify when a command should be executed after a result has not been received. https://assets.nagios.com/downloads/nag ... ios-XI.pdf
Freshness threshold
900
If Nagios XI does not hear from the specified host or service in the specified freshness threshold period, it will execute
the check command that will be defined on the
Common Settings
tab.
- The above document should help you to set these up. Another one that may help is NRDS for passive monitoring - https://assets.nagios.com/downloads/nag ... h_NRDS.pdf
- I'll need more clarification here to understand the question. We have reporting available under the 'Reports' tab, if you're looking to pull this information into another device then check out the 'Help' menu which has a lot of API information.
Former Nagios Employee
TCN-Link
Posts: 30
Joined: Tue Dec 13, 2016 2:05 pm

Re: Newbie Question: Handlers

Post by TCN-Link »

Thank you! I'll read these over and reply if I have any more questions.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Newbie Question: Handlers

Post by rkennedy »

Sounds good - I'll leave this open should you have further questions.
Former Nagios Employee
TCN-Link
Posts: 30
Joined: Tue Dec 13, 2016 2:05 pm

Re: Newbie Question: Handlers

Post by TCN-Link »

I've read through the documents, but there's something missing.

I need to know what the client uses to collect the data from the scripts on passive checks. The documents reference making a text file, but they don't seem to tell how the contents of that text file should be laid out to where Nagios understands what to do with the data once the client collects it. Maybe I'm missing it somewhere, so I'll need this explained to me.

Also, I need to make sure that the client computer name (not just its IP address) is being accurately reported with the data collected. All of our clients are remote working strictly off of their home Internet connections. This means that not only will their IP addresses frequently change over time, but many of them will have the same IP address as reported from their home routers. The client name is our only steady reference to these computers.

Thank you!
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Newbie Question: Handlers

Post by tgriep »

What types of systems are you going to to monitor. Windows, linux, etc....
What types of checks to you want to run on those systems?
If you run through the Wizard, it will setup the files for you and should setup the agent to use the Hostname as well.
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Newbie Question: Handlers

Post by mcapra »

TCN-Link wrote:I need to know what the client uses to collect the data from the scripts on passive checks. The documents reference making a text file, but they don't seem to tell how the contents of that text file should be laid out to where Nagios understands what to do with the data once the client collects it. Maybe I'm missing it somewhere, so I'll need this explained to me.
NRDP/NRDS (Nagios Remote Data Processor/Source) are the two protocols we usually recommend for transfer of passive checks. In that documentation you reviewed:
In order to send passive service checks from external applications and servers to Nagios, you'll need to use the NSCA or NRDP addon
to facilitate the transfer of data to the Nagios XI server.
Nagios XI has it's own NRDP server built-in which can be configured on the "Inbound Transfers" page:
2017_01_25_15_39_30_Administration_Nagios_XI.png
Once the NRDP server is configured, all we really need to do is configure a source to start shipping things to the NRDP server. This document describes the very bare-bones process of sending a passive check to a remote Nagios XI system:
https://assets.nagios.com/downloads/nag ... erview.pdf

NCPA, the Nagios Cross-Platform Agent, can be very easily configured to submit it's check results to Nagios XI via passive checks. Here's the docs for leveraging NCPA to send passive checks:
https://www.nagios.org/ncpa/help/2.0/passive.html
TCN-Link wrote:Also, I need to make sure that the client computer name (not just its IP address) is being accurately reported with the data collected.
If you were using NCPA, rather than configuring a passive check to use it's current hostname/address:

Code: Select all

%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
You could hard-code a specific name in a given computer's configuration:

Code: Select all

bob-computer|__HOST__ = system/agent_version
bob-computer|CPU Usage = cpu/percent --warning 60 --critical 80 --aggregate avg
bob-computer|Swap Usage = memory/swap --warning 60 --critical 80 --units Gi
bob-computer|Memory Usage = memory/virtual --warning 80 --critical 90 --units Gi
bob-computer|Process Count = processes --warning 300 --critical 400
Assuming that your Nagios XI had a host named "bob-computer". The process for using the raw send_nrdp.php script is roughly the same; You're specifying the hostname directly rather than automagically populating it somehow.
You do not have the required permissions to view the files attached to this post.
Former Nagios employee
https://www.mcapra.com/
TCN-Link
Posts: 30
Joined: Tue Dec 13, 2016 2:05 pm

Re: Newbie Question: Handlers

Post by TCN-Link »

Very helpful! To be clear on how my scripts are supposed to prepare the data for the NSClient...

If I want to pick up, say, the idle time before the screensaver activates, then I would let my client side script detect such, then tell it to print a text file named after my script in which its contents looks like this?

Code: Select all

%HOSTNAME%|__HOST__ = system/agent_version
%HOSTNAME%|Screen Saver Idle Time = system/screensaver --warning 0 --critical 301 --units sec
This is assuming I'm using NCPA passive checks. Is that correct? If so, where would my script's values go so Nagios can check against the warning and critical values?
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Newbie Question: Handlers

Post by mcapra »

Any sort of custom scripts, like your screensaver checker, should send their output to whatever your system recognizes as stdout (generally an "echo" is fine) with the exit code that corresponds to the state of the check. Then, when NCPA/NSClient++/NRPE calls the script, it can make sense of the scripts output directly.

In psuedocode, a script that checks the screensaver time and prints out the status in a format Nagios likes might look like this:

Code: Select all

$status = get_screensaver_time();

if($status is ok) {
    echo "OK - The screensaver is ok!";
    exit 0;
}

else if($status is warning) {
    echo "WARNING - Screensaver is in a warning state for some reason!";
    exit 1;
}

else if($status is critical) {
    echo "CRITICAL - Dang we don't even have a screensaver!";
    exit 2;
}

else {
    echo "UNKNOWN - Can't really tell what's going on here!"
    exit 3;
}
Former Nagios employee
https://www.mcapra.com/
Locked