Please help me to parse the file of Nagios config via Python script. I got the array with hostnames, and from this need to parse file and get their members. How i can do this?
There is my code :
import os
hostgroups=os.popen('grep hostgroup_name /var/log/nagios/objects.cache | cut -f3').read().split('\n')
for i in hostgroups[:-1]:
print i
how parse file again or what to do to get members. Example see below :
define hostgroup {
hostgroup_name test
alias test
members server1,server2
}
Thanks.