Searching for 'Free variables'

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
User avatar
WillemDH
Posts: 2320
Joined: Wed Mar 20, 2013 5:49 am
Location: Ghent
Contact:

Searching for 'Free variables'

Post by WillemDH »

Hello,

Is there some way to search in Nagios XI for the values of the free variables definitions? For example if I set a free variable serial number, is there someway to search In Nagios XI with that serial number?

Grtz
Nagios XI 5.8.1
https://outsideit.net
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Searching for 'Free variables'

Post by abrist »

What is the use case?
You could try to search for those using a backend (xml or json). That would get you the hostname that you could then use to navigate to the desired host.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
User avatar
WillemDH
Posts: 2320
Joined: Wed Mar 20, 2013 5:49 am
Location: Ghent
Contact:

Re: Searching for 'Free variables'

Post by WillemDH »

Hmm the use case would be to store some extra info in Nagios XI. It was just an idea, but it depends of how easy it would be to search or see that extra info. I could make a quick action linking to a pretty-json url page, like this http://warfares.github.io/pretty-json/

So if you know what host it's relatively easy to get the data, but I'm not sure how I could search for the (example) serial number with json (or xml) without knowing from which host the serial is.. Or I would have to query all hosts seperately and then look at the values.. what doesn't seem really performant.

EDIT: Some really vague idea, would it be possible to somehow extract all the object data with some job / script to json format, let's say once a day and search in this info with NLS?
Nagios XI 5.8.1
https://outsideit.net
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Searching for 'Free variables'

Post by abrist »

Well, you can query the core json api for a json encoded full list of objects (including custom variables):

Code: Select all

http://<ip>/nagios/cgi-bin/objectjson.cgi?query=hostlist&details=true
Does this help?
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
User avatar
WillemDH
Posts: 2320
Joined: Wed Mar 20, 2013 5:49 am
Location: Ghent
Contact:

Re: Searching for 'Free variables'

Post by WillemDH »

This helps indeed! And it's superfast too. :o Really thanks Andy. I've used your JSON query generator a lot lately. Finding data in Nagios XI has been made super easy with this tool. If only it was as easy to write data back to Nagios XI. It's possible of course by editing the config files and running the import script, but rather cumbersome imho. Or does there happen to be a magic tool that converts Nagios config files to json and back? :D
Nagios XI 5.8.1
https://outsideit.net
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Searching for 'Free variables'

Post by abrist »

Nope, not yet. Maybe someday? Or maybe never?
WillemDH wrote:It's possible of course by editing the config files and running the import script, but rather cumbersome imho
This really is the only option if you need to change non-runtime state options. For runtime-state stuff (enable/disable notifications/perfdata/checks/etc) you can just submit to the command pipe or the cmd.cgi.

The limitation here is NagiosQL (the ccm) as any changes to the configs need to be inserted/updated in the nagiosql database. Due to the highly relational nature of this db, the import procedure is the only safe way to update them. Direct queries can be *very* dangerous unless you fully understand the nagiosql relational structure.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
User avatar
WillemDH
Posts: 2320
Joined: Wed Mar 20, 2013 5:49 am
Location: Ghent
Contact:

Re: Searching for 'Free variables'

Post by WillemDH »

Ok, thanks for confirming. You can close the thread Andy.
Nagios XI 5.8.1
https://outsideit.net
Locked