I'm working on a custom component and I need to list all hosttemplates into a select box. I've done it before with hostgroups using get_xml_hostgroup_objects() but there is no backend call for listing host templates. Anyone know of a way for me to grab all the hosttemplate names?
List of host templates
List of host templates
I promise, this is my last coding question for at least the next 2 weeks 
I'm working on a custom component and I need to list all hosttemplates into a select box. I've done it before with hostgroups using get_xml_hostgroup_objects() but there is no backend call for listing host templates. Anyone know of a way for me to grab all the hosttemplate names?
I'm working on a custom component and I need to list all hosttemplates into a select box. I've done it before with hostgroups using get_xml_hostgroup_objects() but there is no backend call for listing host templates. Anyone know of a way for me to grab all the hosttemplate names?
2 of XI5.6.14 Prod/DR/DEV - Nagios LogServer 2 Nodes
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
Re: List of host templates
I'm not aware of a function in XI that currently just grabs the host templates available. However, it should be easy enough to pull from the nagiosql DB in mysql - table is table_hosttemplate - you should get more than enough info for what you need with just a basic SELECT * FROM nagiosql.tbl_hosttemplate;
I should point out there's a function to run SQL queries inside of XI since it's already actually connected to each of the DBs. This returns an ADO object which you can use $rs->RecordCount(); to get the amount of records or something like $rs->GetArray(); to get a full array of the data.
I should point out there's a function to run SQL queries
Code: Select all
$rs = exec_sql_query(DB_NAGIOSQL, $sql);You do not have the required permissions to view the files attached to this post.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Re: List of host templates
Yeah, thanks again man! I did digging in nagios code and stole some of yoursjomann wrote:I'm not aware of a function in XI that currently just grabs the host templates available. However, it should be easy enough to pull from the nagiosql DB in mysql - table is table_hosttemplate - you should get more than enough info for what you need with just a basic SELECT * FROM nagiosql.tbl_hosttemplate;
I should point out there's a function to run SQL queriesinside of XI since it's already actually connected to each of the DBs. This returns an ADO object which you can use $rs->RecordCount(); to get the amount of records or something like $rs->GetArray(); to get a full array of the data.Code: Select all
$rs = exec_sql_query(DB_NAGIOSQL, $sql);
Code: Select all
$hosttemplates = exec_sql_query(DB_NAGIOSQL, "SELECT `template_name` FROM nagiosql.tbl_hosttemplate ORDER BY `template_name`;", true);2 of XI5.6.14 Prod/DR/DEV - Nagios LogServer 2 Nodes
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
Re: List of host templates
Awesome 
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.