How to get the host template for a host??

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:

How to get the host template for a host??

Post by WillemDH »

While trying to solve this with a script: https://support.nagios.com/forum/viewto ... 16&t=41981

I'm getting the detailed host object in ps with:

Code: Select all

$InvStruct.Web.Downloadstring("$($InvStruct.Nagurl)/nagios/cgi-bin/objectjson.cgi?query=host&hostname=$NagHostName"
This in order to retrieve the configured template. But the template doesn't seem to be in the result of the JSON API. I also tried the new API:

curl -XGET "https://nagiosserver/nagiosxi/api/v1/ob ... testserver"

But this also doesn't contain the host template??

How can I do get the host template, so I can compare the configured contacts with the host template in order to see the impact of the bulk modiification wizard issue... Why si the template not in the result of neither of the above 2 api's? Please make a feature request for this.

Tx
Nagios XI 5.8.1
https://outsideit.net
avandemore
Posts: 1597
Joined: Tue Sep 27, 2016 4:57 pm

Re: How to get the host template for a host??

Post by avandemore »

You are correct, this information isn't available current through the API's.

I have create FR 10722 on this issue.
Previous Nagios employee
gormank
Posts: 1114
Joined: Tue Dec 02, 2014 12:00 pm

Re: How to get the host template for a host??

Post by gormank »

No help from the API perspective, but the template is in the use line of the host config file at /usr/local/nagios/etc/hosts/.
User avatar
WillemDH
Posts: 2320
Joined: Wed Mar 20, 2013 5:49 am
Location: Ghent
Contact:

Re: How to get the host template for a host??

Post by WillemDH »

@gormank Know that, but I'm automating through Powershell. Got a big script which is able to list, compare and update os, infrastructure, role and location based hostgroups, free variables, and export to Excel.. Wanted to add a feature which could check for hosts having a specific template and not the additive notification option.. But it needs to get the info from some api thing.
Nagios XI 5.8.1
https://outsideit.net
SteveBeauchemin
Posts: 524
Joined: Mon Oct 14, 2013 7:19 pm

Re: How to get the host template for a host??

Post by SteveBeauchemin »

Willem,

Reading what you are attempting. For today until there is an actual solution, could you expose that directory to your web browser maybe? Add a file to /etc/httpd/conf.d/
Name it something temporary like temp.conf and fill it with something like this

Code: Select all

# Copy this to /etc/httpd/conf.d
# Delete this when there is an API that allows me to see this data
Alias /hiddenhosts "/usr/local/nagios/etc/hosts"

<Directory "/usr/local/nagios/etc/hosts">
   Options +Indexes
</Directory>
Or something like this that works. It can be an unpublished link only you know about. Then your Powershell can grab the specific host file data using http:// and grep for the template.

Consider this a brainstorming session, like we are at a conference, if they had another one.

Steve B
XI 5.7.3 / Core 4.4.6 / NagVis 1.9.8 / LiveStatus 1.5.0p11 / RRDCached 1.7.0 / Redis 3.2.8 /
SNMPTT / Gearman 0.33-7 / Mod_Gearman 3.0.7 / NLS 2.0.8 / NNA 2.3.1 /
NSClient 0.5.0 / NRPE Solaris 3.2.1 Linux 3.2.1 HPUX 3.2.1
User avatar
WillemDH
Posts: 2320
Joined: Wed Mar 20, 2013 5:49 am
Location: Ghent
Contact:

Re: How to get the host template for a host??

Post by WillemDH »

I have a workaround atm. Just pasted the output of the relations for the hostgroup in the generated Excell. I know the problem hosts now. And received the missing code for the bulk tool by pm, so I can mass fix now.
It should still be possible to get the template of a host with the api though in the future, so leaving this open.
Thanks all for the advices!
Nagios XI 5.8.1
https://outsideit.net
avandemore
Posts: 1597
Joined: Tue Sep 27, 2016 4:57 pm

Re: How to get the host template for a host??

Post by avandemore »

For the record, leaving this thread open or closed with have no impact on the FR.
Previous Nagios employee
Locked