Hi Jim, The format of the config file is like this:
*Config file example1:* For one host in this case named hostname1 belonging to 4 contactgroups (group1 to group4), <-------- begin config file example 1 ------------> host_contactgroups += [ ( 'group1', ['hostname1'] ), ( 'group2', ['hostname1'] ), ( 'group3', ['hostname1'] ), ( 'group4', ['hostname1'] ), ] all_hosts += [ "hostname1|cmk-agent|prod|lan|tcp|wato|/" + FOLDER_PATH + "/", ] # Explicit IP addresses ipaddresses.update({'hostname1': u'hostname1.domain.com'}) # Settings for alias extra_host_conf.setdefault('alias', []).extend((u'hostname1.domain.com', ['hostname1'])]) # Host attributes host_attributes.update( {'hostname1': {'alias': u'hostname1.domain.com', 'contactgroups': (True, ['group1', 'group2', 'group3', 'group4']), 'ipaddress': u'hostname1.domain.com', 'tag_agent': 'cmk-agent', 'tag_criticality': 'prod', 'tag_networking': 'lan'}}) <-------- end config file example 1 ------------> *Config file example 2:* For three host in this case, hostname1, hostname2 and hostname3, with hostname1 belonging to contactgroups "group1 to group4", hostname2 belonging to contactgroups "group3 and group4", and hostname3 belonging to contactgroups "group3" only. <-------- begin config file example 2 ------------> host_contactgroups += [ ( 'group1', ['hostname1'] ), ( 'group2', ['hostname1'] ), ( 'group3', ['hostname1'] ), ( 'group4', ['hostname1'] ), ] host_contactgroups += [ ( 'group3', ['hostname2'] ), ( 'group4', ['hostname2'] ), ] host_contactgroups += [ ( 'group3', ['hostname3'] ), ] all_hosts += [ "hostname1|cmk-agent|prod|lan|tcp|wato|/" + FOLDER_PATH + "/", "hostname2|test|cmk-agent|lan|tcp|wato|/" + FOLDER_PATH + "/", "hostname3|cmk-agent|prod|lan|tcp|wato|/" + FOLDER_PATH + "/", ] # Explicit IP addresses ipaddresses.update({'hostname1': u'hostname1.domain.com', 'hostname2': u'hostname2.domain.com', 'hostname3': u'hostname3.domain.com'}) # Settings for alias extra_host_conf.setdefault('alias', []).extend( [(u'hostname3.domain.com', ['hostname3']), (u'hostname2.domain.com', ['hostname2']), (u'hostname1.domain.com', ['hostname1'])]) # Host attributes host_attributes.update( {'hostname1': {'alias': u'hostname1.domain.com', 'contactgroups': (True, ['group1', 'group2', 'group3', 'group4']), 'ipaddress': u'hostname1.domain.com', 'tag_agent': 'cmk-agent', 'tag_criticality': 'prod', 'tag_networking': 'lan'}, 'hostname2': {'alias': u'hostname2.domain.com', 'contactgroups': (True, ['group3', 'group4']), 'ipaddress': u'hostname2.domain.com', 'tag_agent': 'cmk-agent', 'tag_criticality': 'test', 'tag_networking': 'lan'}, 'hostname3': {'alias': u'hostname3.domain.com', 'contactgroups': (True, ['group3']), 'ipaddress': u'hostname3.domain.com', 'tag_agent': 'cmk-agent', 'tag_criticality': 'prod', 'tag_networking': 'lan'}}) <-------- end config file example 2 ------------> Final note: Notice the lines containing FOLDER_PATH in the *all_hosts +=*section in config file example 2: "hostname1|cmk-agent*|prod*|lan|tcp|wato|/" + FOLDER_PATH + "/", "hostname2|*test*|cmk-agent|lan|tcp|wato|/" + FOLDER_PATH + "/", "hostname3|cmk-agent|*prod*|lan|tcp|wato|/" + FOLDER_PATH + "/", Where hostname1 and hostname 3 contains "prod" and hostname 2 contains "test" which indicates that hostname 2 is a test server whilst the others are production hosts. The very last section under # Host attributes section: *host_attributes.update *is then basically build up from the information that was given up to now so that the final format for each hostname now looks like this: {'hostname1': {'alias': u'hostname1.domain.com', 'contactgroups': (True, ['group1', 'group2', 'group3', 'group4']), 'ipaddress': u'hostname1.domain.com', 'tag_agent': 'cmk-agent', 'tag_criticality': 'prod', 'tag_networking': 'lan'}, Many thanks, Wernher On Mon, Mar 3, 2014 at 8:36 PM, Jim Gibson <jimsgib...@gmail.com> wrote: > > On Mar 3, 2014, at 8:47 AM, Wernher Eksteen wrote: > > > Hi Shlomi, > > > > Thank you for the pointers. I do want to learn Python as well when I get > a chance. This "framework" I'm writing now will automate things to a great > extend eventually freeing up loads of my daily operations time so I can > focus on more interesting things. > > > > I'm really not expecting the code to be written for me, mere pointers as > you did (with some examples would be a plus) is all that's needed for me to > look into that and take it further. > > If you want some examples of how to parse your config files, then you > should show us some examples of those config files. How to best parse the > files depends wholly upon the format of the files. Some formats are easy to > parse; other formats are more difficult. Nobody can advise you without > seeing some examples of the files, and how much variation occurs in the > format or content of the possible files you will encounter. > > Good luck. > > > -- > To unsubscribe, e-mail: beginners-unsubscr...@perl.org > For additional commands, e-mail: beginners-h...@perl.org > http://learn.perl.org/ > > >