Exemplo n.º 1
0
    def getConfig(self):
        """make configuration file
        TODO filename or filehandle must be an argument
        """
        dtHostCfg = datetime.now(berlinTZ)
        #fpHostCfg = open(u'/opt/ikomtrol/etc/Host.cfg', 'w+')
        fpHostCfg = open(u'/opt/nagios/etc/ict_ok/Host.cfg', 'w+')
        fpHostCfg.write(u"# Host.cfg\n")
        fpHostCfg.write(u"# generated by ict-ok.org Ver. %s (%s)\n\n" %
                        (getIkVersion(), dtHostCfg))

        dtHostGroupCfg = datetime.now(berlinTZ)
        #fpHostGroupCfg = open(u'/opt/ikomtrol/etc/HostGroup.cfg', 'w+')
        fpHostGroupCfg = open(u'/opt/nagios/etc/ict_ok/HostGroup.cfg', 'w+')
        fpHostGroupCfg.write(u"# HostGroup.cfg\n")
        fpHostGroupCfg.write(u"# generated by ict-ok.org Ver. %s (%s)\n\n" %
                             (getIkVersion(), dtHostGroupCfg))
        fpHostGroupCfg.write(u"define hostgroup {\n")
        fpHostGroupCfg.write(u"    hostgroup_name IKOMtrol\n")
        fpHostGroupCfg.write(u"    alias IKOMtrol-Systeme\n")
        fpHostGroupCfg.write(u"    members ")

        dtServiceCfg = datetime.now(berlinTZ)
        #fpServiceCfg = open(u'/opt/ikomtrol/etc/Service.cfg', 'w+')
        fpServiceCfg = open(u'/opt/nagios/etc/ict_ok/Service.cfg', 'w+')
        fpServiceCfg.write(u"# Service.cfg\n")
        fpServiceCfg.write(u"# generated by ict-ok.org Ver. %s (%s)\n\n" %
                           (getIkVersion(), dtServiceCfg))

        fileDict = {
            'HostCfg': fpHostCfg,
            'HostGroupCfg': fpHostGroupCfg,
            'ServiceCfg': fpServiceCfg
        }
        #cfgFile = open('/tmp/cfgNagiosFile', 'w')
        #import pdb; pdb.set_trace()
        its = zapi.getRoot(self).items()
        for (dummy_name, oobj) in its:
            if ISupernode.providedBy(oobj):
                try:
                    adapterGenNagios = IGenNagios(oobj)
                    if adapterGenNagios:
                        adapterGenNagios.traverse4nagiosGenerator(
                            fileDict, level=1, comments=False)
                except TypeError, errText:
                    logger.error(u"Problem in adaption of nagios config: %s" %\
                                 (errText))
Exemplo n.º 2
0
 def traverse4nagiosGeneratorBody(self, fileDict, level=0, comments=True):
     """graphviz configuration data of/in object
     """
     if comments:
         print >> fileDict['HostCfg'], \
               "%s## Body (%s,%d) - SupernodeGenNagios" % \
               ("\t" * level, self.context.ikName, level)
     its = self.context.items()
     for (dummy_name, oobj) in its:
         if ISuperclass.providedBy(oobj):
             try:
                 adapterGenNagios = IGenNagios(oobj)
                 if adapterGenNagios:
                     adapterGenNagios.traverse4nagiosGenerator(
                         fileDict, level + 1, comments)
             except TypeError:
                 logger.error(u"Problem in adaption of nagios config")
Exemplo n.º 3
0
 def traverse4nagiosGeneratorBody(self, level=0, comments=True):
     """graphviz configuration data of/in object
     """
     if comments:
         self.write("%s## Body (%s,%d) - SupernodeGenNagios" % \
                    ("\t" * level, self.context.ikName, level))
     its = self.context.items()
     for (dummy_name, oobj) in its:
         if ISuperclass.providedBy(oobj):
             try:
                 adapterGenNagios = IGenNagios(oobj)
                 if adapterGenNagios:
                     adapterGenNagios.parentAdapter = self
                     adapterGenNagios.traverse4nagiosGenerator(
                         level + 1, comments)
             except TypeError, errText:
                 logger.error(u"Problem in nagios adaption: '%s'" % \
                              errText)