Add notes to system via CLI

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
Pontiac
Posts: 2
Joined: Tue Jun 12, 2018 10:00 am

Add notes to system via CLI

Post by Pontiac »

First time poster;

I've googled, and I've done a quick search on here prior to signing in, and I've not found quite the right answer to what I need to perform.

We're running NagiosXI at work. I've been given the task to update the 'Notes' field of a host with information extracted from a spreadsheet. I can extract the information from the spreadsheet and transform it to something usable, no huge deal, but, I'm not clear on how to make a bulk change to the notes based on the supplied hostname in the spreadsheet to what is being monitored in Nagios.

What I want to do is extract each row of this spreadsheet into an individual text file that contains KEY=VALUE pairs for each cell that has content for that row. I then want to take those text files and apply the content to the NOTES field for each host.

Is there a way I can do this at the command line?

I have root access to the Nagios server, I'm a full on admin within Nagios, I'm just not familiar with the CLI Nagios has, or if I have to submit these changes through some kind of HTTP API.

I'm pretty good with BASH, and I'm pretty good with HTTP API requests, and I can always write a custom application that does all of this for me with a single click in Windows. I just don't know the correct path to get the information into Nagios automagically.

Thanks!

Edit:
With a bit more research, I've found two places where "notes" can be stored. One spot is in MySQL where the 'notes' field is part of the CCM and Host Management, then there's objectnotes (Which I don't see in the plugin list, but, is still available -- Merged into base code maybe??). I came across this:
https://support.nagios.com/forum/viewto ... 16&t=28943

Executing that command, the query came back. So I'm starting to wonder if there is a REST API call I have to make, or, if I have to start plugging directly into the PostGresql database...
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Add notes to system via CLI

Post by mcapra »

Pontiac wrote:I'm just not familiar with the CLI Nagios has, or if I have to submit these changes through some kind of HTTP API.
Under the "Help" section of the Nagios XI GUI, there should be complete documentation for usage of the REST API that comes packaged with Nagios XI.

I don't believe there is a good method for "updating" a host currently, but you could pull down the entire host object via the REST API (using a limited query), append some notes to it, then "recreate" the object by deleting it via the API then adding it again via the API.
Former Nagios employee
https://www.mcapra.com/
Pontiac
Posts: 2
Joined: Tue Jun 12, 2018 10:00 am

Re: Add notes to system via CLI

Post by Pontiac »

Thank you.

I've not seen anything in that page that has anything to do with ObjectNotes, however, I've found the PHP file that ObjectNotes submits the data to PGSQL, so I've got that avenue to explore.

The options I've come up with are:
- Talk directly to the database through BASH scripting and STDOUT redirection
- Use wget/curl to make requests via HTTP to the ObjectNotes
- Call PHP against the ObjectNotes.php script with POST/GET variables in an external file.

Option 2 or 3 is probably what I'm going to go with. Right now, I'm just doing an analysis on what options I have.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Add notes to system via CLI

Post by scottwilkerson »

The objectnotes is not available through the REST API and what you have found is likely the best option.
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Locked