Last active
September 8, 2015 04:26
-
-
Save javierwilson/f159ac92aaff838e4b75 to your computer and use it in GitHub Desktop.
Generates Nagios config for Access Points
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 characters
define hostgroup{ | |
hostgroup_name access_points | |
alias Access Points | |
} | |
{%- for ap in items %} | |
define host{ | |
use generic-switch | |
host_name {{ ap.name }} | |
alias {{ ap.name }} | |
address {{ ap.ip }} | |
hostgroups access_points | |
} | |
define service{ | |
use generic-service | |
host_name {{ ap.name }} | |
service_description PING | |
check_command check_ping!200.0,20%!600.0,60% | |
} | |
{%- 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 characters
10.0.0.221 Linksys1 | |
10.0.0.222 Linksys2 | |
10.0.0.223 Cisco1 | |
10.0.0.224 Linksys3 | |
10.0.0.225 Linksys4 | |
10.0.0.226 Linksys5 | |
10.0.0.227 Linksys6 | |
10.0.0.228 Linksys7 | |
10.0.0.229 Linksys8 | |
10.0.0.230 DLink1 | |
10.0.0.231 DLink2 | |
10.0.0.232 DLink3 | |
10.0.0.233 DLink4 | |
10.0.0.234 DLink5 | |
10.0.0.235 Linksys9 | |
10.0.0.236 DLink6 | |
10.0.0.237 DLink7 | |
10.0.0.238 DLink8 | |
10.0.0.239 DLink9 | |
10.0.0.240 DLink10 |
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 characters
#!/usr/bin/python | |
from jinja2 import Template, Environment, FileSystemLoader | |
env = Environment( loader = FileSystemLoader('./') ) | |
template = env.get_template('access_points.tpl') | |
with open('access_points.txt') as f: | |
lines = f.readlines() | |
items = [] | |
for line in lines: | |
args =line.rstrip().split(' ') | |
items.append({'ip': args[0], 'name': args[1]}) | |
print template.render(items=items) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment