Oct 3, 2011

Getting Nagios Parent-child host relationship

Someone posted an interesting question in Nagios XI (customers only) forum whether it is possible to print the parent-child host relationships in a human readable format. 

NagiosQL stores this data in MySQL database server under the table named nagiosql.tbl_lnkHostToHost.  The table has two fields: idMaster and idSlave but the information is stored as host ids.  The Perl script posted here fetches this information, map the host ids to host names and displays the data in comma separated format which can be opened with any CSV reader, preferably Spreadsheet reader to make the data presentable.

I believe the script posted here applies to everyone who is using NagiosQL and not just Nagios XI users.