Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > d1012c800fc5a174c1c765185f26f6b1 > files > 101

nagios-check_mk-1.0.37-2mdv2010.0.noarch.rpm

#!/usr/bin/python
# -*- encoding: utf-8; py-indent-offset: 4 -*-
# +------------------------------------------------------------------+
# |          _           _           _       _   __   ________       |
# |       __| |_  ___ __| |__  _ __ | |__   / | /  \ |__ /__  |      |
# |      / _| ' \/ -_) _| / / | '  \| / /   | || () | |_ \ / /       |
# |      \__|_||_\___\__|_\_\_|_|_|_|_\_\   |_(_)__(_)___//_/        |
# |                                            check_mk 1.0.37       |
# |                                                                  |
# | Copyright Mathias Kettner 2009                mk@mathias-kettner |
# +------------------------------------------------------------------+
# 
# This file is part of check_mk 1.0.37.
# The official homepage is at http://mathias-kettner.de/check_mk.
# 
# check_mk is free software;  you can redistribute it and/or modify it
# under the  terms of the  GNU General Public License  as published by
# the Free Software Foundation in version 2.  check_mk is  distributed
# in the hope that it will be useful, but WITHOUT ANY WARRANTY;  with-
# out even the implied warranty of  MERCHANTABILITY  or  FITNESS FOR A
# PARTICULAR PURPOSE. See the  GNU General Public License for more de-
# ails.  You should have  received  a copy of the  GNU  General Public
# License along with GNU Make; see the file  COPYING.  If  not,  write
# to the Free Software Foundation, Inc., 51 Franklin St,  Fifth Floor,
# Boston, MA 02110-1301 USA.

import glob, sys, os

mknagios_autochecksdir = "autochecks"	
outputdir              = "autochecks.new"
try: os.mkdir(outputdir)
except OSError: pass

hosts = {}

for f in glob.glob(mknagios_autochecksdir + '/*.mk'):
    try:
        for line in file(f).readlines():
           if line.lstrip().startswith('("'):
               splitted = line.split('"')
               hostname = splitted[1]
               hostchecks = hosts.get(hostname, [])
               hostchecks.append(line)
               hosts[hostname] = hostchecks
    except Exception, e:
        sys.stderr.write("Fehler bei Datei: %s\n" % e)
        sys.exit(1)

print "Found data from %d hosts" % len(hosts)

for host, lines in hosts.items():
  print "%s: %d Checks" % (host, len(lines))
  f = file(outputdir + "/" + host.replace(":","_") + ".mk", "w+")
  f.write("[\n")
  for line in lines:
    f.write(line)
  f.write("]\n")