Getting information from Nagios

This forum is intended for the discussion of Nagios plugin development. Feature requests, patches, bug fixes, and all types of development-related discussions are welcome!

NOTE: The SourceForge.net nagiosplug-devel mailing list has been deprecated in favor of this forum in order to expedite support and provide additional features not available on the old mailing list.

Getting information from Nagios

Postby tarzan » Wed Mar 08, 2017 7:28 am

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
tarzan
 
Posts: 10
Joined: Thu Sep 08, 2016 9:09 am

Re: Getting information from Nagios

Postby mcapra » Wed Mar 08, 2017 4:23 pm

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
Be sure to check out our Knowledgebase for helpful articles and solutions!

https://github.com/mcapra/
User avatar
mcapra
Support Tech
 
Posts: 1969
Joined: Thu May 05, 2016 3:54 pm
Location: Nagios Enterprises

Re: Getting information from Nagios

Postby tarzan » Fri Mar 10, 2017 3:32 am

Thanks, I'll try and let you know.
tarzan
 
Posts: 10
Joined: Thu Sep 08, 2016 9:09 am

Re: Getting information from Nagios

Postby mcapra » Fri Mar 10, 2017 3:02 pm

Sure! Let us know if you encounter additional issues.
Be sure to check out our Knowledgebase for helpful articles and solutions!

https://github.com/mcapra/
User avatar
mcapra
Support Tech
 
Posts: 1969
Joined: Thu May 05, 2016 3:54 pm
Location: Nagios Enterprises

Re: Getting information from Nagios

Postby tarzan » Wed Mar 15, 2017 4:06 am

Hello,

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

Thank you
tarzan
 
Posts: 10
Joined: Thu Sep 08, 2016 9:09 am

Re: Getting information from Nagios

Postby mcapra » Wed Mar 15, 2017 2:24 pm

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.
Be sure to check out our Knowledgebase for helpful articles and solutions!

https://github.com/mcapra/
User avatar
mcapra
Support Tech
 
Posts: 1969
Joined: Thu May 05, 2016 3:54 pm
Location: Nagios Enterprises


Return to Nagios Plugin Development

Who is online

Users browsing this forum: No registered users and 1 guest