Page 1 of 1
Hosts not belonging to any hostgroup
Posted: Fri Feb 04, 2022 7:57 am
by bramassendorp
Hi,
Is it possible to generate a list of hosts that are not member of any hostgroup?
Via the API I managed to get a list of hosts per hostgroup, but I also need a list of hosts that do not have any hostgroup.
Thnx.
Re: Hosts not belonging to any hostgroup
Posted: Fri Feb 04, 2022 6:09 pm
by gsmith
Hi
From a CLI on your Nagios XI server please run:
Code: Select all
echo "select id, host_name from tbl_host where id not in (select idMaster from tbl_lnkHostToHostgroup) order by host_name;" | mysql -u root -pnagiosxi nagiosql
Thanks
Re: Hosts not belonging to any hostgroup
Posted: Mon Feb 07, 2022 3:59 am
by bramassendorp
gsmith wrote:Hi
From a CLI on your Nagios XI server please run:
Code: Select all
echo "select id, host_name from tbl_host where id not in (select idMaster from tbl_lnkHostToHostgroup) order by host_name;" | mysql -u root -pnagiosxi nagiosql
Thanks
Hi,
Yes, that works, but only for hosts that where added via the host config, and not added via the hostgroup config.
We have a mixed situation, so I need a method to have a list with hosts without a host group, but not depending on what method it's added.
Thnx.
Re: Hosts not belonging to any hostgroup
Posted: Mon Feb 07, 2022 2:17 pm
by gsmith
Hi
Please send me a database dump as follows:
To send us a database dump
1. mysqldump -uroot -pnagiosxi nagios > /tmp/nagios.sql
2. tar -cvzf /tmp/nagios.sql.tar.gz /tmpnagios.sql
3. Share the /tmpnagios.sql.tar.gz in a private message and then reply to this post to bring it up in the queue.
Also please give the names of a few hosts that were added via added via the hostgroup config so I can
refine the sql query.
Thanks
Re: Hosts not belonging to any hostgroup
Posted: Thu Feb 10, 2022 5:34 am
by bramassendorp
gsmith wrote:Hi
Please send me a database dump as follows:
To send us a database dump
1. mysqldump -uroot -pnagiosxi nagios > /tmp/nagios.sql
2. tar -cvzf /tmp/nagios.sql.tar.gz /tmpnagios.sql
3. Share the /tmpnagios.sql.tar.gz in a private message and then reply to this post to bring it up in the queue.
Also please give the names of a few hosts that were added via added via the hostgroup config so I can
refine the sql query.
Thanks
Hi,
You got me on the right track, seems there are two tables, sounds this about right to you?
select id, host_name from tbl_host where id not in (select idMaster from tbl_lnkHostToHostgroup) and id not in (select idSlave from tbl_lnkHostgroupToHost) order by host_name;
btw, can you maybe explain what the difference is between the databases, I have the nagios, nagiosql and nagiosxi databases.
The above data I could also get from the nagios database, different tables but it could be done.
Can you explain which one best to use?
Thank you!
Re: Hosts not belonging to any hostgroup
Posted: Thu Feb 10, 2022 10:53 am
by gsmith
Hi
Yes it sounds like you have a good handle on it.
There are 3 databases. nagios and nagiosql existed for Nagios Core, and the
Nagios XI database was added for Nagios XI. You are correct, you could query on
just the nagios db to get what you need. You could think of the nagiosql database
as the equivalent of a set of foreign keys for the nagios db.
Please let me know if that answers your questions, if so I will lock this thread.
Thank you
Re: Hosts not belonging to any hostgroup
Posted: Fri Feb 11, 2022 8:53 am
by bramassendorp
gsmith wrote:Hi
Yes it sounds like you have a good handle on it.
There are 3 databases. nagios and nagiosql existed for Nagios Core, and the
Nagios XI database was added for Nagios XI. You are correct, you could query on
just the nagios db to get what you need. You could think of the nagiosql database
as the equivalent of a set of foreign keys for the nagios db.
Please let me know if that answers your questions, if so I will lock this thread.
Thank you
Yes, all done, thnx!