本文整理汇总了Python中pysandesh.sandesh_base.Sandesh.reconfig_collectors方法的典型用法代码示例。如果您正苦于以下问题:Python Sandesh.reconfig_collectors方法的具体用法?Python Sandesh.reconfig_collectors怎么用?Python Sandesh.reconfig_collectors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pysandesh.sandesh_base.Sandesh
的用法示例。
在下文中一共展示了Sandesh.reconfig_collectors方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ConfigServiceLogger
# 需要导入模块: from pysandesh.sandesh_base import Sandesh [as 别名]
# 或者: from pysandesh.sandesh_base.Sandesh import reconfig_collectors [as 别名]
#.........这里部分代码省略.........
host_ip = args.host_ip
else:
host_ip = socket.gethostbyname(socket.getfqdn())
node_type = Module2NodeType[module]
self._module_name = ModuleNames[module]
self._node_type_name = NodeTypeNames[node_type]
self.table = "ObjectConfigNode"
self._instance_id = INSTANCE_ID_DEFAULT
self._hostname = socket.getfqdn(host_ip)
# sandesh init
self.sandesh_init(http_server_port)
def _get_sandesh_logger_level(self, sandesh_level):
return self._LOGGER_LEVEL_TO_SANDESH_LEVEL[sandesh_level]
def log(self, log_msg, level=SandeshLevel.SYS_DEBUG, fun=None):
if fun:
log = fun(level=level, og_msg=log_msg, sandesh=self._sandesh)
log.send(sandesh=self._sandesh)
else:
self._sandesh.logger().log(
SandeshLogger.get_py_logger_level(level), log_msg)
def emergency(self, log_msg, log_fun=None):
self.log(log_msg, level=SandeshLevel.SYS_EMERG, fun=log_fun)
def alert(self, log_msg, log_fun=None):
self.log(log_msg, level=SandeshLevel.SYS_ALERT, fun=log_fun)
def critical(self, log_msg, log_fun=None):
self.log(log_msg, level=SandeshLevel.SYS_CRIT, fun=log_fun)
def error(self, log_msg, log_fun=None):
self.log(log_msg, level=SandeshLevel.SYS_ERR, fun=log_fun)
def cgitb_error(self):
string_buf = cStringIO.StringIO()
cgitb_hook(file=string_buf, format="text")
self.error(string_buf.getvalue())
def warning(self, log_msg, log_fun=None):
self.log(log_msg, level=SandeshLevel.SYS_WARN, fun=log_fun)
def notice(self, log_msg, log_fun=None):
self.log(log_msg, level=SandeshLevel.SYS_NOTICE, fun=log_fun)
def info(self, log_msg, log_fun=None):
self.log(log_msg, level=SandeshLevel.SYS_INFO, fun=log_fun)
def debug(self, log_msg, log_fun=None):
self.log(log_msg, level=SandeshLevel.SYS_DEBUG, fun=log_fun)
def _utc_timestamp_usec(self):
epoch = datetime.datetime.utcfromtimestamp(0)
now = datetime.datetime.utcnow()
delta = now - epoch
return (delta.microseconds +
(delta.seconds + delta.days * 24 * 3600) * 10 ** 6)
def redefine_sandesh_handles(self):
""" Redefine sandesh handle requests for various object types. """
pass
def sandesh_init(self, http_server_port=None):
""" Init sandesh """
self._sandesh = Sandesh()
self.redefine_sandesh_handles()
if not http_server_port:
http_server_port = self._args.http_server_port
self._sandesh.init_generator(
self._module_name, self._hostname, self._node_type_name,
self._instance_id, self._args.random_collectors,
'%s_context' % self.context, int(http_server_port),
['cfgm_common', '%s.sandesh' % self.module_pkg],
logger_class=self._args.logger_class,
logger_config_file=self._args.logging_conf,
config=self._args.sandesh_config)
self._sandesh.set_logging_params(
enable_local_log=self._args.log_local,
category=self._args.log_category,
level=self._args.log_level,
file=self._args.log_file,
enable_syslog=self._args.use_syslog,
syslog_facility=self._args.syslog_facility)
# connection state init
ConnectionState.init(
self._sandesh, self._hostname, self._module_name,
self._instance_id,
staticmethod(ConnectionState.get_conn_state_cb),
NodeStatusUVE, NodeStatus, self.table)
VncGreenlet.register_sandesh_handler()
def introspect_init(self):
self._sandesh.run_introspect_server(int(self._args.http_server_port))
def sandesh_reconfig_collectors(self, args):
self._sandesh.reconfig_collectors(args.random_collectors)