Getting information from Nagios

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
tarzan
Posts: 17
Joined: Thu Sep 08, 2016 9:09 am

Getting information from Nagios

Post by tarzan »

Hello everybody,

my questions are as follows:

you can access from a Perl program to the state of hosts and services on Nagios? Where can I find information about the controls or libraries that make it possible to obtain information about Nagios hosts and services?

thank you

Tarzan
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Getting information from Nagios

Post by mcapra »

I don't know of any Perl libraries for assessing the Nagios Core system state, but the status.dat file defined in your nagios.cfg file under the status_file directive is a good place to start. Take a look through that file and see if it's got the sort of information you're looking to access.

Monitoring::Plugin is a pretty popular library for creating Nagios Core plugins though:
http://search.cpan.org/~nierlein/Monito ... /Plugin.pm
Former Nagios employee
https://www.mcapra.com/
tarzan
Posts: 17
Joined: Thu Sep 08, 2016 9:09 am

Re: Getting information from Nagios

Post by tarzan »

Thanks, I'll try and let you know.
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Getting information from Nagios

Post by mcapra »

Sure! Let us know if you encounter additional issues.
Former Nagios employee
https://www.mcapra.com/
tarzan
Posts: 17
Joined: Thu Sep 08, 2016 9:09 am

Re: Getting information from Nagios

Post by tarzan »

Hello,

you can by a Perl program using macros on demand Nagios?

Thank you
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Getting information from Nagios

Post by mcapra »

I assume you're talking about these?
https://assets.nagios.com/downloads/nag ... olist.html

The Nagios macros are evaluated when Nagios Core executes a given command. So if you wrote a Perl script that accepts certain arguments (a path, file, warning/critical thresholds, service name, etc), you could feel the Nagios Core macros into that script via the Nagios Core command definition.

Here's an example of a command definition calling check_disk locally with 3 arguments:

Code: Select all

define command {
       command_name                             check_local_disk
       command_line                             $USER1$/check_disk.pl -w $ARG1$ -c $ARG2$ -p $ARG3$
}
What macros you have access to for a given situation depends. You can reference that document I linked above for which macros are available in which contexts.
Former Nagios employee
https://www.mcapra.com/
Locked