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.
Hosts not belonging to any hostgroup
Re: Hosts not belonging to any hostgroup
Hi
From a CLI on your Nagios XI server please run:
Thanks
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 nagiosqlThanks
-
bramassendorp
- Posts: 28
- Joined: Sun Jun 09, 2019 3:16 am
Re: Hosts not belonging to any hostgroup
Hi,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
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
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
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
-
bramassendorp
- Posts: 28
- Joined: Sun Jun 09, 2019 3:16 am
Re: Hosts not belonging to any hostgroup
Hi,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
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
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 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
-
bramassendorp
- Posts: 28
- Joined: Sun Jun 09, 2019 3:16 am
Re: Hosts not belonging to any hostgroup
Yes, all done, thnx!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