示例#1
0
def _start_snmp_server():
    logger = logging.getLogger(__name__)
    # Start SNMP server in a separate process
    pid = os.fork()
    if pid == 0:
        from scalarizr.snmp.agent import SnmpServer
        globals()['_pid'] = 0
        cnf = bus.cnf
        ini = cnf.rawini
        snmp_server = SnmpServer(
            port=int(ini.get(config.SECT_SNMP, config.OPT_PORT)),
            security_name=ini.get(config.SECT_SNMP, config.OPT_SECURITY_NAME),
            community_name=ini.get(config.SECT_SNMP,
                                   config.OPT_COMMUNITY_NAME))
        bus.snmp_server = snmp_server

        try:
            snmp_server.start()
            logger.info('[pid: %d] SNMP process terminated', os.getpid())
            sys.exit(0)
        except SystemExit:
            raise
        except (BaseException, Exception), e:
            logger.warn('Caught SNMP error: %s', str(e))
            sys.exit(1)
示例#2
0
    def _start_snmp_server(self):
        remove_snmp_since = (4, 5, 0)
        if bus.scalr_version >= remove_snmp_since:
            self._logger.debug(
                'Skip SNMP process starting cause condition matched: Scalr version %s >= %s',
                bus.scalr_version, remove_snmp_since)
            self._snmp_pid = -1
            return

        # Start SNMP server in a separate process
        pid = os.fork()
        if pid == 0:
            globals()['_pid'] = 0
            cnf = bus.cnf
            ini = cnf.rawini
            snmp_server = SnmpServer(
                port=int(ini.get(config.SECT_SNMP, config.OPT_PORT)),
                security_name=ini.get(config.SECT_SNMP,
                                      config.OPT_SECURITY_NAME),
                community_name=ini.get(config.SECT_SNMP,
                                       config.OPT_COMMUNITY_NAME))
            bus.snmp_server = snmp_server

            try:
                snmp_server.start()
                self._logger.info('[pid: %d] SNMP process terminated',
                                  os.getpid())
                sys.exit(0)
            except SystemExit:
                raise
            except (BaseException, Exception), e:
                self._logger.warn('Caught SNMP error: %s', str(e))
                sys.exit(1)
示例#3
0
    def _start_snmp_server(self):
        remove_snmp_since = (4, 5, 0)
        if bus.scalr_version >= remove_snmp_since:
            self._logger.debug('Skip SNMP process starting cause condition matched: Scalr version %s >= %s',
                bus.scalr_version, remove_snmp_since)
            self._snmp_pid = -1
            return

        # Start SNMP server in a separate process
        pid = os.fork()
        if pid == 0:
            globals()['_pid'] = 0
            cnf = bus.cnf; ini = cnf.rawini
            snmp_server = SnmpServer(
                port=int(ini.get(config.SECT_SNMP, config.OPT_PORT)),
                security_name=ini.get(config.SECT_SNMP, config.OPT_SECURITY_NAME),
                community_name=ini.get(config.SECT_SNMP, config.OPT_COMMUNITY_NAME)
            )
            bus.snmp_server = snmp_server

            try:
                snmp_server.start()
                self._logger.info('[pid: %d] SNMP process terminated', os.getpid())
                sys.exit(0)
            except SystemExit:
                raise
            except (BaseException, Exception), e:
                self._logger.warn('Caught SNMP error: %s', str(e))
                sys.exit(1)
示例#4
0
def _start_snmp_server():
	logger = logging.getLogger(__name__)
	# Start SNMP server in a separate process
	pid = os.fork()
	if pid == 0:
		from scalarizr.snmp.agent import SnmpServer
		globals()['_pid'] = 0
		cnf = bus.cnf; ini = cnf.rawini		
		snmp_server = SnmpServer(
			port=int(ini.get(config.SECT_SNMP, config.OPT_PORT)),
			security_name=ini.get(config.SECT_SNMP, config.OPT_SECURITY_NAME),
			community_name=ini.get(config.SECT_SNMP, config.OPT_COMMUNITY_NAME)
		)
		bus.snmp_server = snmp_server
		
		try:
			snmp_server.start()
			logger.info('[pid: %d] SNMP process terminated', os.getpid())
			sys.exit(0)
		except SystemExit:
			raise
		except (BaseException, Exception), e:
			logger.warn('Caught SNMP error: %s', str(e))
			sys.exit(1)
示例#5
0
def prepare_snmp():
    _init()
    cnf = bus.cnf
    ini = cnf.rawini
    cnf.on('apply_user_data', _apply_user_data)
    cnf.bootstrap()

    server_id = ini.get('general', 'server_id')
    queryenv_url = ini.get('general', 'queryenv_url')
    queryenv = QueryEnvService(queryenv_url, server_id,
                               cnf.key_path(cnf.DEFAULT_KEY))

    bus.queryenv_service = queryenv

    snmp_server = SnmpServer(
        port=int(ini.get(config.SECT_SNMP, config.OPT_PORT)),
        security_name=ini.get(config.SECT_SNMP, config.OPT_SECURITY_NAME),
        community_name=ini.get(config.SECT_SNMP, config.OPT_COMMUNITY_NAME))
    return snmp_server