Exporting Nagios info - objects.config

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Post Reply
logisbk
Posts: 3
Joined: Mon Nov 08, 2021 1:00 pm

Exporting Nagios info - objects.config

Post by logisbk »

I need to gather all host and service info from Nagios specifically hosts, host groups, contacts, contact groups - and the same for services. I also need the inherited associations, ie an inherited contact from a host template.

My understanding is that all of this info is in the objects.config file, and I have pulled that into an Excel sheet. I need to bring each field into it's own column so I can filter it, and in the file each field is a separate row, so the spreadsheet has literally hundreds of thousand of rows. I've tried a variety of Excel formulas, though I am no Excel expert. A simple filter for example to filter column B for host_name and copy all the host names in column C to a new sheet, do the same for contacts, etc could work, but the issue is that some services/hosts don't have that defined so then it's thrown off. I ran into the same issue with my other formulas.

I found this post which is promising, but when I attempt to run it, I get an unterminated string, syntax error. Command below:

Code: Select all

awk 'BEGIN{print "host_name,hostgroups,contacts,contact_groups"} /host_name/{v1=$2} /hostgroups/{v2=","$2} /contacts/{v3=","$2} /contact_groups/{v4=","$2} /}/{print v1","v2","v3,"v4; v1=v2=v3=v4""}' objects.txt > objectexport2.csv
Anyone have thoughts on the best way to do this?
User avatar
jmichaelson
Posts: 132
Joined: Wed Aug 23, 2023 1:02 pm

Re: Exporting Nagios info - objects.config

Post by jmichaelson »

Looks like you have an extraneous " character near the end of the command after v3=v4, right here:

v1=v2=v3=v4""}'
Please let us know if you have any other questions or concerns.

-Jason
logisbk
Posts: 3
Joined: Mon Nov 08, 2021 1:00 pm

Re: Exporting Nagios info - objects.config

Post by logisbk »

Thanks Jason. I was able to get it to work after removing the 'hostgroups' as that doesn't appear to be a field in the file.

Code: Select all

awk 'BEGIN{print "host_name,contacts,contact_groups"} /host_name/{v1=$2} /contacts/{v2=$2} /contact_groups/{v3=$2} /}/{print v1","v2","v3; v1=v2=v3=""}' objects.txt > objectexport3.csv
logisbk
Posts: 3
Joined: Mon Nov 08, 2021 1:00 pm

Re: Exporting Nagios info - objects.config

Post by logisbk »

Oh and I realized I missed a " which is why the extraneous one was at the end, I missed one after the v3

Code: Select all

/{print v1","v2","v3","v4; v1=v2=v3=v4""}' 
Post Reply