Last change
on this file since 10391 was 10391, checked in by rick, 13 years ago |
Fix typo in hostgroup.
While here, fix the wrong key autogen_fqdn and introduce autogen_realname which does this the proper way.
Related-To: beheer#176
|
-
Property svn:executable
set to
*
|
File size:
1.3 KB
|
Line | |
---|
1 | #!/usr/bin/env python
|
---|
2 | #
|
---|
3 | # Script to create nagios output files from gformat configurtion files
|
---|
4 | #
|
---|
5 | # Original: Richard van Mansom <richardvm@wirelessleiden.nl>
|
---|
6 | # Rick van der Zwet <rick@wirelessleiden.nl>
|
---|
7 |
|
---|
8 | import gformat
|
---|
9 |
|
---|
10 | NODE_PREFIX = 'nodes-7-2'
|
---|
11 |
|
---|
12 | def is_ap(ifacedump):
|
---|
13 | return ifacedump.has_key('dhcp') and not ifacedump['dhcp'] == 'no'
|
---|
14 |
|
---|
15 | def is_iris(node):
|
---|
16 | return node.has_key('release') and node['release'] in ['8.0-RELEASE', '7.2-RELEASE', '8.1-RELEASE', '8.2-RELEASE']
|
---|
17 |
|
---|
18 | if __name__ == '__main__':
|
---|
19 | for host in gformat.get_hostlist():
|
---|
20 | datadump = gformat.get_yaml(host)
|
---|
21 |
|
---|
22 | # Make sure to process only active IRIS nodes
|
---|
23 | if not is_iris(datadump) or not datadump['status'] == 'up':
|
---|
24 | continue
|
---|
25 |
|
---|
26 | # Default hostgroup
|
---|
27 | hostgroups = [NODE_PREFIX,]
|
---|
28 |
|
---|
29 | # Interface groups
|
---|
30 | for iface in datadump['autogen_iface_keys']:
|
---|
31 | ifacedump = datadump[iface]
|
---|
32 | if (ifacedump['status'] == 'up' and not is_ap(ifacedump)):
|
---|
33 | key = 'iface-%s' % ifacedump['autogen_ifname']
|
---|
34 | if not key in hostgroups:
|
---|
35 | hostgroups.append(key)
|
---|
36 |
|
---|
37 | if datadump['ileiden']:
|
---|
38 | hostgroups.append('nodes-ileiden')
|
---|
39 |
|
---|
40 | datadump['hostgroups'] = ','.join(hostgroups)
|
---|
41 | print """
|
---|
42 | define host{
|
---|
43 | use host-pnp
|
---|
44 | host_name %(autogen_realname)s
|
---|
45 | alias %(autogen_realname)s
|
---|
46 | address %(masterip)s
|
---|
47 | hostgroups %(hostgroups)s
|
---|
48 | }
|
---|
49 |
|
---|
50 | """ % datadump
|
---|
Note:
See
TracBrowser
for help on using the repository browser.