Example #1
0
def getApmonInstance(logr, apmonServer):
    global apmonInstance
    global apmonInit
    if apmonInstance is None and not apmonInit:
        apmonInit = True
        if apmonInstance is None:
            try:
                if not apmonServer:
                    apmonInstance = apmon.ApMon(apmonConf,
                                                logr)  #apmonLoggingLevel)
                else:
                    apmonInstance = apmon.ApMon(apmonServer, logr)
            except Exception, e:
                pass
Example #2
0
 def new_apmon():
     apMonConf = {
         DASHBOARDURL: {
             'sys_monitoring': 0,
             'general_info': 0,
             'job_monitoring': 0
         }
     }
     try:
         return apmon.ApMon(apMonConf, 0)
     except Exception:
         logger.exception("can't create ApMon instance")
     return None
Example #3
0
def getApmonInstance(logr=None, apmonServer=None):
    """ Get Apmon instance
    logr can be set to custom logger or to logging level.
        logging levels are defined in Logger.
    apmonServer can point to custom monitoring server"""
    global APMONINSTANCE
    global APMONINIT
    global APMONCONF
    global APMONLOGGINGLEVEL
    if apmonServer:
        APMONCONF = apmonServer
    if logr:
        APMONLOGGINGLEVEL = logr
    if APMONINSTANCE is None and not APMONINIT:
        APMONINIT = True
        if APMONUSEURL:
            apm = None
            print("Creating ApMon with dynamic configuration/url")
            try:
                apm = apmon.ApMon(APMONCONF, APMONLOGGINGLEVEL)
            except Exception as ex:
                print('Got exception %s' % str(ex))
            if apm is not None and not apm.initializedOK():
                print("Setting ApMon to static configuration")
                try:
                    apm.setDestinations(APMONCONF)
                except Exception:
                    apm = None
            APMONINSTANCE = apm
        if APMONINSTANCE is None:
            print("Creating ApMon with static configuration")
            try:
                APMONINSTANCE = apmon.ApMon(APMONCONF, APMONLOGGINGLEVEL)
            except Exception as ex:
                print('Got exception %s' % str(ex))
    return APMONINSTANCE
Example #4
0
    def _getApMonInstance(self):
        """
        _getApMonInstance_

        Private method that returns an instance of ApMon
        """
        self.logger.debug("Creating ApMon with static configuration")
        apMonConf = {self.server: self.defaultParams}
        try:
            return apmon.ApMon(apMonConf, self.logger)
        except Exception as ex:
            msg = "Error while getting an instance of ApMon under: %s\n" % self.server
            msg += str(ex)
            self.logger.error(msg)
        return None