Exemple #1
0
 def allConfigFilesOut(self, forceOutput=False, event=None, genOutput=True):
     """make configuration file
     return True if any value has changed
     """
     valueChanged = forceOutput
     # start config file header
     utcTZ = timezone('UTC')
     starttimeCfg = datetime.datetime.now(utcTZ)
     if genOutput:
         fpCfg = codecs.open(u'/opt/smokeping/etc/ict_ok/ict.cfg',
                             'w',
                             encoding='utf-8')
         fpCfg.write(u"# generated by ict-ok.org Ver. %s (%s)\n\n" %
                     (getIkVersion(), starttimeCfg))
         fpCfg.write(u"# ----------------------------------------\n")
         fpCfg.close()
     # start config file main parts
     its = zapi.getRoot(self).items()
     for (dummy_name, oobj) in its:
         if ISupernode.providedBy(oobj):
             try:
                 adapterGenSmokePing = IGenSmokePing(oobj)
                 if adapterGenSmokePing:
                     adapterGenSmokePing.genOutput = genOutput
                     if adapterGenSmokePing.smokepingConfigFileOut(\
                         forceOutput, event):
                         valueChanged = True
             except TypeError, errText:
                 logger.error(u"Problem in adaption of smokeping conf: %s" %\
                              (errText))
Exemple #2
0
 def __init__(self, **data):
     """
     constructor of Supernode
     """
     Superclass.__init__(self, **data)
     BTreeContainer.__init__(self)
     for (name, value) in data.items():
         if name in ISupernode.names():
             setattr(self, name, value)
     self.ikRevision = __version__
Exemple #3
0
 def allConfigFilesOut(self):
     """make configuration file
     """
     self.touchLastConfigFile()
     its = zapi.getRoot(self).items()
     for (dummy_name, oobj) in its:
         if ISupernode.providedBy(oobj):
             try:
                 adapterGenNagios = IGenNagios(oobj)
                 if adapterGenNagios:
                     adapterGenNagios.nagiosConfigFileOut(True, None)
             except TypeError, errText:
                 logger.error(u"Problem in adaption of nagios config: %s" %\
                              (errText))
Exemple #4
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))
Exemple #5
0
 def getConfig(self):
     """make configuration file
     TODO filename or filehandle must be an argument
     """
     cfgFile = open('/tmp/cfgFile', 'w')
     its = zapi.getRoot(self).items()
     for (dummy_name, oobj) in its:
         if ISupernode.providedBy(oobj):
             try:
                 adapterGenHoneyd = IIKGenHoneyd(oobj)
                 if adapterGenHoneyd:
                     adapterGenHoneyd.traverse4honeydGenerator(
                         cfgFile, level=1, comments=True)
             except TypeError:
                 logger.error(u"Problem in adaption of honeyd config")
     cfgFile.flush()
     cfgFile.close()
     return "aaa"
Exemple #6
0
 def fillDotFile(self, objList, dotFile):
     """generate the dot file
     """
     print >> dotFile, '// GraphViz DOT-File'
     print >> dotFile, 'graph "%s" {' % (zapi.getRoot(self).__name__)
     print >> dotFile, '\tgraph [bgcolor="#E5FFF9"];'
     print >> dotFile, '\tedge [style = "setlinewidth(2)", color = gray];'
     print >> dotFile, '\trankdir = LR;'
     for (dummy_name, oobj) in objList:
         if ISupernode.providedBy(oobj):
             try:
                 adapterGenGraphvizDot = IGenGraphvizDot(oobj)
                 if adapterGenGraphvizDot:
                     adapterGenGraphvizDot.setParent(zapi.getRoot(self))
                     adapterGenGraphvizDot.traverse4DotGenerator(\
                         dotFile,
                         level=1,
                         comments=False)
             except TypeError, err:
                 logger.error("TypeError in fillDotFile() [%s]" % err)
Exemple #7
0
 def generateAllPdf(self, absFilename, authorStr, versionStr):
     """
     will generate a complete pdf report
     """
     files2delete = []
     document = RptDocument(absFilename)
     #document.setVolumeNo("1")
     document.setAuthorName(authorStr)
     document.setVersionStr(versionStr)
     its = zapi.getRoot(self).items()
     for (dummy_name, oobj) in its:
         if ISupernode.providedBy(oobj):
             try:
                 adapterRptPdf = IRptPdf(oobj)
                 if adapterRptPdf:
                     adapterRptPdf.document = document
                     adapterRptPdf.traverse4Rpt(1, False)
                     files2delete.extend(adapterRptPdf.files2delete)
                     del adapterRptPdf
             except TypeError, errText:
                 logger.error(u"Problem in adaption of pdf report: %s" %\
                              (errText))