How can I control nagios core from the Linux command line?

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
Sol33t303
Posts: 1
Joined: Sat Oct 21, 2017 4:53 am

How can I control nagios core from the Linux command line?

Post by Sol33t303 »

I have just recently installed nagios onto my Fedora 26 home server that i have made, everything seems to have installed fine. I installed nagios because it was suggested to me by somebody in the linuxquestions.org forums. I was hoping to use nagios in a script i'm making which will detect whether or not an application has crashed (using nagios) and if it has to then send me a text message about it so I can use SSH and fix the issue remotly. But it would be much easier if I could use nagios in the command line so i can include it in my bash script.
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: How can I control nagios core from the Linux command lin

Post by mcapra »

So Nagios Core is an application that watches hosts/services that you specify. Essentially, you feed it a big list of things you would like to monitor, give it criteria for what a "problem" looks like, then configure logic to dictate what should be done when a problem is detected.

Given this use case:
Sol33t303 wrote:I was hoping to use nagios in a script i'm making which will detect whether or not an application has crashed (using nagios) and if it has to then send me a text message about it so I can use SSH and fix the issue remotly.
You wouldn't use "Nagios" in a script; You would use your script in Nagios. The script would be responsible for determining whether or not an application has crashed. Nagios would then call that script when it's time to check in on the application and examine the script's output. If the script's output contains criteria that says "yes there is a problem" (as laid out in these guidelines), Nagios will then react in the way in which you configured it. This could be sending a text message to a system administrator, running a script that SSHs into the machine and attempts to restart the application, sets in motion the most fantastic of Rube Goldberg machines to dump a bucket of water on the server, whatever. Point being, through configuration files, you as a user are telling Nagios exactly how you would like it to detect and respond to problems in your infrastructure.

Here's the official documentation with some relatively simple "hello world" style instructions for monitoring windows/linux/hardware devices:
https://assets.nagios.com/downloads/nag ... n/toc.html

Let us know if you have additional questions or something is unclear. What you want to do (application stopped, please send me a text message) is totally doable and a very common use case for Nagios, but much of the community documentation assumes you already know how things work in "Nagios land".

Personally, Twilio is my go-to for automated SMS stuff. There is some documentation out there for setting up Twilio with Nagios Core, but it's dated and has conventions that are no longer supported by Twilio's API.
Former Nagios employee
https://www.mcapra.com/
dwasswa

Re: How can I control nagios core from the Linux command lin

Post by dwasswa »

Thanks @ mcapra,

@Sol33t303 please let us know if you have any questions.
Locked