-
-
Save or1gb1u3/2e5188537a23da5c62d0 to your computer and use it in GitHub Desktop.
Revisions
-
unicolet revised this gist
Jun 27, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,7 +8,7 @@ hostgroups=set() hosts = csv.reader(open('hosts.csv'), delimiter=',', quotechar='"') for h in hosts: if h[0]!="" and h[0]!="ip": tmp.append(h) # skip rows w/o ip address for x in h[3].split(',') : hostgroups.add(x) hosts=tmp -
unicolet revised this gist
Jun 27, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,7 +9,7 @@ hosts = csv.reader(open('hosts.csv'), delimiter=',', quotechar='"') for h in hosts: if h[0]!="" and h[0]!="ip":: tmp.append(h) # skip rows w/o ip address for x in h[3].split(',') : hostgroups.add(x) hosts=tmp -
unicolet revised this gist
Jun 27, 2012 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ # intentionally left blank -
unicolet revised this gist
Jun 27, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,7 +8,7 @@ hostgroups=set() hosts = csv.reader(open('hosts.csv'), delimiter=',', quotechar='"') for h in hosts: if h[0]!="" and h[0]!="ip":: tmp.append(h) # skim rows w/o ip address for x in h[3].split(',') : hostgroups.add(x) hosts=tmp -
unicolet revised this gist
Jun 27, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ {% for record in hosts %} define host{ host_name {{ record[1].replace(' ','_') }} alias {{ record[1] }} -
unicolet revised this gist
Jun 27, 2012 . 2 changed files with 25 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ {% for hg in hostgroups %} define hostgroup{ hostgroup_name {{ hg }} alias {{ hg }} } # host hostgroup template define host{ check_command check-host-alive notification_options d,u,r max_check_attempts 5 name {{ hg }} register 0 } {% endfor %} This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,9 @@ % for record in hosts %} define host{ host_name {{ record[1].replace(' ','_') }} alias {{ record[1] }} address {{ record[0] }} hostgroups {{ record[3]}} use {{ record[3].split(",")[0] }} } {% endfor %} -
unicolet created this gist
Jun 27, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ import csv from jinja2 import Template,FileSystemLoader,Environment loader = FileSystemLoader('templates') env = Environment(loader=FileSystemLoader('templates')) tmp=[] hostgroups=set() hosts = csv.reader(open('hosts.csv'), delimiter=',', quotechar='"') for h in hosts: if h[0]!="": tmp.append(h) # skim rows w/o ip address for x in h[3].split(',') : hostgroups.add(x) hosts=tmp files = {'hostgroups':'','services':'','hosts':''} templates = {} for k in files.keys(): templates[k]=env.get_template(k) for k in files.keys(): files[k] += templates[k].render(hosts=hosts, hostgroups=hostgroups) for k in sorted(files.keys(),reverse=True): print files[k]