本文整理汇总了Python中pysandesh.sandesh_base.Sandesh.run_introspect_server方法的典型用法代码示例。如果您正苦于以下问题:Python Sandesh.run_introspect_server方法的具体用法?Python Sandesh.run_introspect_server怎么用?Python Sandesh.run_introspect_server使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pysandesh.sandesh_base.Sandesh
的用法示例。
在下文中一共展示了Sandesh.run_introspect_server方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MesosManagerLogger
# 需要导入模块: from pysandesh.sandesh_base import Sandesh [as 别名]
# 或者: from pysandesh.sandesh_base.Sandesh import run_introspect_server [as 别名]
#.........这里部分代码省略.........
# Log using the desired logging function.
self.log(log_msg, level=log_level, fun=logging_fun)
# NOTICE.
def notice(self, log_msg, log_fun=None):
log_level = SandeshLevel.SYS_NOTICE
logging_fun = log_fun if log_fun else sandesh.MesosManagerNoticeLog
# Log to syslog.
self.syslog(log_msg, log_level)
# Log using the desired logging function.
self.log(log_msg, level=log_level, fun=logging_fun)
# INFO.
def info(self, log_msg, log_fun=None):
log_level = SandeshLevel.SYS_INFO
logging_fun = log_fun if log_fun else sandesh.MesosManagerInfoLog
# Log using the desired logging function.
self.log(log_msg, level=log_level, fun=logging_fun)
# DEBUG.
def debug(self, log_msg, log_fun=None):
log_level = SandeshLevel.SYS_DEBUG
logging_fun = log_fun if log_fun else sandesh.MesosManagerDebugLog
# Log using the desired logging function.
self.log(log_msg, level=log_level, fun=logging_fun)
def redefine_sandesh_handles(self):
""" Register custom introspect handlers. """
# Register Virtual Machine DB introspect handler.
introspect.VirtualMachineDatabaseList.handle_request = \
VirtualMachineMM.sandesh_handle_db_list_request
# Register Virtual Router DB introspect handler.
introspect.VirtualRouterDatabaseList.handle_request = \
VirtualRouterMM.sandesh_handle_db_list_request
# Register Virtual Machine Interface DB introspect handler.
introspect.VirtualMachineInterfaceDatabaseList.handle_request = \
VirtualMachineInterfaceMM.sandesh_handle_db_list_request
# Register Virtual Network DB introspect handler.
introspect.VirtualNetworkDatabaseList.handle_request = \
VirtualNetworkMM.sandesh_handle_db_list_request
# Register Instance IP DB introspect handler.
introspect.InstanceIpDatabaseList.handle_request = \
InstanceIpMM.sandesh_handle_db_list_request
# Register Project DB introspect handler.
introspect.ProjectDatabaseList.handle_request = \
ProjectMM.sandesh_handle_db_list_request
# Register Domain DB introspect handler.
introspect.DomainDatabaseList.handle_request = \
DomainMM.sandesh_handle_db_list_request
# Register NetworkIpam DB introspect handler.
introspect.NetworkIpamDatabaseList.handle_request = \
NetworkIpamMM.sandesh_handle_db_list_request
def sandesh_init(self):
""" Init Sandesh """
self._sandesh = Sandesh()
# Register custom sandesh request handlers.
self.redefine_sandesh_handles()
# Initialize Sandesh generator.
self._sandesh.init_generator(
self.module['name'], self.module['hostname'],
self.module['node_type_name'], self.module['instance_id'],
self._args.collectors, 'mesos_manager_context',
int(self._args.http_server_port),
['cfgm_common', 'mesos_manager.sandesh', 'mesos_introspect.sandesh'],
logger_class=self._args.logger_class,
logger_config_file=self._args.logging_conf,
config=self._args.sandesh_config)
# Set Sandesh logging params.
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)
# Connect to collector.
ConnectionState.init(self._sandesh, self.module['hostname'],
self.module['name'], self.module['instance_id'],
staticmethod(ConnectionState.get_conn_state_cb),
NodeStatusUVE, NodeStatus, self.module['table'])
def introspect_init(self):
self._sandesh.run_introspect_server(int(self._args.http_server_port))
示例2: ConfigServiceLogger
# 需要导入模块: from pysandesh.sandesh_base import Sandesh [as 别名]
# 或者: from pysandesh.sandesh_base.Sandesh import run_introspect_server [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)
示例3: KubeManagerLogger
# 需要导入模块: from pysandesh.sandesh_base import Sandesh [as 别名]
# 或者: from pysandesh.sandesh_base.Sandesh import run_introspect_server [as 别名]
#.........这里部分代码省略.........
# WARNING.
def warning(self, log_msg, log_fun=None):
log_level = SandeshLevel.SYS_WARN
logging_fun = log_fun if log_fun else sandesh.KubeManagerWarningLog
# Log to syslog.
self.syslog(log_msg, log_level)
# Log using the desired logging function.
self.log(log_msg, level=log_level, fun=logging_fun)
# NOTICE.
def notice(self, log_msg, log_fun=None):
log_level = SandeshLevel.SYS_NOTICE
logging_fun = log_fun if log_fun else sandesh.KubeManagerNoticeLog
# Log to syslog.
self.syslog(log_msg, log_level)
# Log using the desired logging function.
self.log(log_msg, level=log_level, fun=logging_fun)
# INFO.
def info(self, log_msg, log_fun=None):
log_level = SandeshLevel.SYS_INFO
logging_fun = log_fun if log_fun else sandesh.KubeManagerInfoLog
# Log using the desired logging function.
self.log(log_msg, level=log_level, fun=logging_fun)
# DEBUG.
def debug(self, log_msg, log_fun=None):
log_level = SandeshLevel.SYS_DEBUG
logging_fun = log_fun if log_fun else sandesh.KubeManagerDebugLog
# Log using the desired logging function.
self.log(log_msg, level=log_level, fun=logging_fun)
def _redefine_sandesh_handles(self):
""" Register custom introspect handlers. """
# Register Pod DB introspect handler.
introspect.PodDatabaseList.handle_request =\
PodKM.sandesh_handle_db_list_request
# Register Namespace DB introspect handler.
introspect.NamespaceDatabaseList.handle_request =\
NamespaceKM.sandesh_handle_db_list_request
# Register Service DB introspect handler.
introspect.ServiceDatabaseList.handle_request =\
ServiceKM.sandesh_handle_db_list_request
# Register NetworkPolicy DB introspect handler.
introspect.NetworkPolicyDatabaseList.handle_request =\
NetworkPolicyKM.sandesh_handle_db_list_request
# Register Ingress DB introspect handler.
introspect.IngressDatabaseList.handle_request =\
IngressKM.sandesh_handle_db_list_request
def sandesh_init(self, http_server_port=None):
""" Init Sandesh """
self._sandesh = Sandesh()
# Register custom sandesh request handlers.
self._redefine_sandesh_handles()
if not http_server_port:
http_server_port = self._args.http_server_port
# Initialize Sandesh generator.
self._sandesh.init_generator(
self._module["name"], self._module["hostname"],
self._module["node_type_name"], self._module["instance_id"],
self._args.random_collectors, 'kube_manager_context',
int(http_server_port),
['cfgm_common', 'kube_manager'],
logger_class=self._args.logger_class,
logger_config_file=self._args.logging_conf,
config=self._args.sandesh_config)
# Set Sandesh logging params.
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)
# Connect to collector.
ConnectionState.init(
self._sandesh, self._module["hostname"], self._module["name"],
self._module["instance_id"],
staticmethod(ConnectionState.get_process_state_cb),
NodeStatusUVE, NodeStatus, self._module["table"])
def sandesh_uninit(self):
self._sandesh.uninit()
def introspect_init(self):
self._sandesh.run_introspect_server(int(self._args.http_server_port))