11 #include <boost/filesystem.hpp>
12 #include <boost/bind/bind.hpp>
13 #include <boost/foreach.hpp>
14 #include <boost/format.hpp>
15 #include <boost/algorithm/string/predicate.hpp>
24 #include <sandesh/transport/TBufferTransports.h>
25 #include <sandesh/transport/TSimpleFileTransport.h>
26 #include <sandesh/protocol/TBinaryProtocol.h>
27 #include <sandesh/protocol/TProtocol.h>
29 #include <sandesh/sandesh_types.h>
30 #include <sandesh/sandesh.h>
31 #include <sandesh/sandesh_trace.h>
32 #include <sandesh/sandesh_uve_types.h>
41 #include <log4cplus/helpers/pointer.h>
42 #include <log4cplus/configurator.h>
43 #include <log4cplus/fileappender.h>
44 #include <log4cplus/syslogappender.h>
46 using boost::asio::ip::tcp;
47 using boost::asio::ip::address;
51 using namespace log4cplus;
52 using namespace boost::placeholders;
83 getenv(
"SANDSH_UT_DEBUG") ? SandeshLevel::SYS_DEBUG : SandeshLevel::UT_DEBUG;
89 log4cplus::Logger::getInstance(LOG4CPLUS_TEXT(
"SANDESH"));
91 log4cplus::Logger::getInstance(LOG4CPLUS_TEXT(
"SLO_SESSION"));
93 log4cplus::Logger::getInstance(LOG4CPLUS_TEXT(
"SAMPLED_SESSION"));
99 " %h [Thread %t, Pid %i]: %m%n";
103 case SandeshRole::Generator:
105 case SandeshRole::Collector:
107 case SandeshRole::Test:
109 case SandeshRole::Invalid:
117 assert(recv_task_id_ == -1);
119 recv_task_id_ = scheduler->
GetTaskId(
"sandesh::RecvQueue");
120 recv_queue_.reset(
new SandeshRxQueue(recv_task_id_, recv_task_inst,
126 connect_to_collector_ =
true;
127 SANDESH_LOG(INFO,
"SANDESH: CONNECT TO COLLECTOR: " <<
128 connect_to_collector_);
130 assert(client_ == NULL);
131 std::vector<Endpoint> collector_endpoints = boost::assign::list_of(server);
146 const std::string &module,
147 const std::string &source,
148 const std::string &node_type,
149 const std::string &instance_id,
151 unsigned short http_port,
158 if (role_ != SandeshRole::Invalid || role == SandeshRole::Invalid) {
162 SANDESH_LOG(INFO,
"SANDESH: ROLE : " << SandeshRoleToString(role));
165 SANDESH_LOG(INFO,
"SANDESH: NODE TYPE : " << node_type);
166 SANDESH_LOG(INFO,
"SANDESH: INSTANCE ID : " << instance_id);
167 SANDESH_LOG(INFO,
"SANDESH: HTTP SERVER PORT : " << http_port);
172 node_type_ = node_type;
173 instance_id_ = instance_id;
174 client_context_ = client_context;
176 event_manager_ =
evm;
184 SANDESH_LOG(ERROR,
"SANDESH: HTTP INIT FAILED (PORT " <<
188 RecordPort(
"http", module_, http_port_);
194 std::ostringstream myfifoss;
195 myfifoss <<
"/tmp/" << module <<
"." << getppid() <<
"." << name <<
"_port";
196 std::string myfifo = myfifoss.str();
197 std::ostringstream hss;
199 std::string hstr = hss.str();
201 fd = open(myfifo.c_str(), O_WRONLY | O_NONBLOCK);
203 SANDESH_LOG(INFO,
"SANDESH: Write " << name <<
"_port " << port <<
205 write(fd, hstr.c_str(), hstr.length());
208 SANDESH_LOG(INFO,
"SANDESH: NOT Writing " << name <<
"_port " << port <<
214 int collector_port,
bool periodicuve) {
215 boost::system::error_code ec;
218 SANDESH_LOG(ERROR, __func__ <<
": Invalid collector address: " <<
219 collector_ip <<
" Error: " << ec);
223 SANDESH_LOG(INFO,
"SANDESH: COLLECTOR : " << collector_ip);
224 SANDESH_LOG(INFO,
"SANDESH: COLLECTOR PORT : " << collector_port);
226 tcp::endpoint collector(collector_addr, collector_port);
233 client_->ReConfigCollectors(collector_list);
238 const std::vector<std::string> &collectors,
240 connect_to_collector_ =
true;
241 SANDESH_LOG(INFO,
"SANDESH: CONNECT TO COLLECTOR: " <<
242 connect_to_collector_);
243 std::vector<Endpoint> collector_endpoints;
244 BOOST_FOREACH(
const std::string &collector, collectors) {
247 SANDESH_LOG(ERROR, __func__ <<
": Invalid collector address: " <<
251 collector_endpoints.push_back(ep);
259 const std::string &source,
260 const std::string &node_type,
261 const std::string &instance_id,
263 unsigned short http_port,
268 return Initialize(SandeshRole::Generator, module, source, node_type,
269 instance_id,
evm, http_port, client_context, config);
273 const std::string &source,
274 const std::string &node_type,
275 const std::string &instance_id,
277 unsigned short http_port,
278 const std::vector<std::string> &collectors,
283 bool success(Initialize(SandeshRole::Generator, module, source, node_type,
284 instance_id,
evm, http_port, client_context,
289 return InitClient(
evm, collectors, config);
294 const std::string &source,
295 const std::string &node_type,
296 const std::string &instance_id,
298 const std::string &collector_ip,
int collector_port,
299 unsigned short http_port,
302 bool success(Initialize(SandeshRole::Collector, module, source, node_type,
303 instance_id,
evm, http_port, client_context,
308 return ConnectToCollector(collector_ip, collector_port,
true);
312 const std::string &source,
313 const std::string &node_type,
314 const std::string &instance_id,
316 unsigned short http_port,
319 return Initialize(SandeshRole::Test, module, source, node_type,
320 instance_id,
evm, http_port, client_context, config);
324 static const int kTimeout = 15;
327 for (
int i = 0; i < (kTimeout * 1000); i++) {
351 role_ = SandeshRole::Invalid;
352 if (recv_queue_.get() != NULL) {
353 recv_queue_->Shutdown();
354 recv_queue_.reset(NULL);
355 assert(recv_task_id_ != -1);
358 assert(recv_task_id_ == -1);
360 if (client_ != NULL) {
362 while (client()->IsSession()) usleep(100);
364 client_->ClearSessions();
371 std::string level,
bool enable_trace_print,
bool enable_flow_log,
372 bool enable_session_syslog) {
373 SetLocalLogging(enable_local_log);
374 SetLoggingCategory(category);
376 SetTracePrint(enable_trace_print);
377 SetFlowLogging(enable_flow_log);
378 SetSessionSyslogging(enable_session_syslog);
383 bool enable_flow_log) {
384 SetLocalLogging(enable_local_log);
385 SetLoggingCategory(category);
387 SetTracePrint(enable_trace_print);
388 SetFlowLogging(enable_flow_log);
399 case SandeshLevel::SYS_EMERG:
400 case SandeshLevel::SYS_ALERT:
401 case SandeshLevel::SYS_CRIT:
402 return log4cplus::FATAL_LOG_LEVEL;
403 case SandeshLevel::SYS_ERR:
404 return log4cplus::ERROR_LOG_LEVEL;
405 case SandeshLevel::SYS_WARN:
406 case SandeshLevel::SYS_NOTICE:
407 return log4cplus::WARN_LOG_LEVEL;
408 case SandeshLevel::SYS_INFO:
409 return log4cplus::INFO_LOG_LEVEL;
410 case SandeshLevel::SYS_DEBUG:
411 return log4cplus::DEBUG_LOG_LEVEL;
414 return log4cplus::ALL_LOG_LEVEL;
420 log4cplus::LogLevel log4_old_level(logger_.getLogLevel());
421 if (logging_level_ != level ||
422 log4_old_level != log4_new_level) {
423 const log4cplus::LogLevelManager &log4level_manager(
424 log4cplus::getLogLevelManager());
425 SANDESH_LOG(INFO,
"SANDESH: Logging: LEVEL: " <<
"[ " <<
426 LevelToString(logging_level_) <<
" ] -> [ " <<
427 LevelToString(level) <<
" ] log4level: [ " <<
428 log4level_manager.toString(log4_old_level) <<
430 log4level_manager.toString(log4_new_level) <<
432 logging_level_ = level;
433 logger_.setLogLevel(log4_new_level);
440 if (logging_category_ != category) {
441 SANDESH_LOG(INFO,
"SANDESH: Logging: CATEGORY: " <<
442 (logging_category_.empty() ?
"*" : logging_category_) <<
" -> " <<
443 (category.empty() ?
"*" : category));
444 logging_category_ = category;
449 if (enable_local_log_ != enable_local_log) {
451 (enable_local_log_ ?
"ENABLED" :
"DISABLED") <<
" -> " <<
452 (enable_local_log ?
"ENABLED" :
"DISABLED"));
453 enable_local_log_ = enable_local_log;
458 if (enable_trace_print_ != enable_trace_print) {
460 (enable_trace_print_ ?
"ENABLED" :
"DISABLED") <<
" -> " <<
461 (enable_trace_print ?
"ENABLED" :
"DISABLED"));
462 enable_trace_print_ = enable_trace_print;
467 if (enable_flow_log_ != enable_flow_log) {
469 (enable_flow_log_ ?
"ENABLED" :
"DISABLED") <<
" -> " <<
470 (enable_flow_log ?
"ENABLED" :
"DISABLED"));
471 enable_flow_log_ = enable_flow_log;
476 if (enable_session_syslog_ != enable_session_syslog) {
478 (enable_session_syslog_ ?
"ENABLED" :
"DISABLED") <<
" -> " <<
479 (enable_session_syslog ?
"ENABLED" :
"DISABLED"));
480 enable_session_syslog_ = enable_session_syslog;
486 if (disable_flow_collection_ != disable) {
487 SANDESH_LOG(INFO,
"SANDESH: Disable Flow Collection: " <<
488 disable_flow_collection_ <<
" -> " << disable);
489 disable_flow_collection_ = disable;
494 if (disable_sending_all_ != disable) {
495 SANDESH_LOG(INFO,
"SANDESH: Disable Sending ALL Messages: " <<
496 disable_sending_all_ <<
" -> " << disable);
497 disable_sending_all_ = disable;
502 return disable_sending_all_;
506 if (disable_sending_object_logs_ != disable) {
507 SANDESH_LOG(INFO,
"SANDESH: Disable Sending Object Logs: " <<
508 disable_sending_object_logs_ <<
" -> " << disable);
509 disable_sending_object_logs_ = disable;
514 return disable_sending_object_logs_;
518 if (disable_sending_flows_ != disable) {
519 SANDESH_LOG(INFO,
"SANDESH: Disable Sending Flows: " <<
520 disable_sending_flows_ <<
" -> " << disable);
521 disable_sending_flows_ = disable;
526 return disable_sending_flows_;
530 return sandesh_send_ratelimit_ == 0;
534 if (rate_limit >= 0) {
535 SANDESH_LOG(INFO,
"SANDESH: System Log Send Rate Limit: " <<
536 sandesh_send_ratelimit_ <<
" -> " << rate_limit);
537 sandesh_send_ratelimit_ = rate_limit;
542 return sandesh_send_ratelimit_;
547 if (IsLoggingDroppedAllowed(
type())) {
548 SANDESH_LOG(ERROR, __func__ <<
": SandeshQueue NULL : Dropping Message: "
551 UpdateTxMsgFailStats(name_, 0, SandeshTxDropReason::NoQueue);
575 boost::shared_ptr<TMemoryBuffer> btrans =
576 boost::shared_ptr<TMemoryBuffer>(
578 btrans->setWriteBuffer(buf, buf_len);
579 boost::shared_ptr<TBinaryProtocol> prot =
583 SANDESH_LOG(DEBUG, __func__ <<
"Write sandesh to " << buf_len <<
584 " bytes FAILED" << std::endl);
594 boost::shared_ptr<TMemoryBuffer> btrans =
595 boost::shared_ptr<TMemoryBuffer>(
597 boost::shared_ptr<TBinaryProtocol> prot =
601 SANDESH_LOG(DEBUG, __func__ <<
"Read sandesh from " << buf_len <<
602 " bytes FAILED" << std::endl);
611 boost::shared_ptr<TSimpleFileTransport> btrans =
612 boost::shared_ptr<TSimpleFileTransport>(
614 boost::shared_ptr<TBinaryProtocol> prot =
618 SANDESH_LOG(DEBUG, __func__ <<
"Write sandesh to file FAILED"
628 boost::shared_ptr<TSimpleFileTransport> btrans =
629 boost::shared_ptr<TSimpleFileTransport>(
631 boost::shared_ptr<TBinaryProtocol> prot =
635 SANDESH_LOG(DEBUG, __func__ <<
"Read sandesh from file FAILED"
646 std::string sandesh_name;
647 boost::shared_ptr<TMemoryBuffer> btrans =
648 boost::shared_ptr<TMemoryBuffer>(
650 boost::shared_ptr<TBinaryProtocol> prot =
653 xfer = prot->readSandeshBegin(sandesh_name);
655 SANDESH_LOG(DEBUG, __func__ <<
"Read sandesh begin from " << buf_len <<
656 " bytes FAILED" << std::endl);
663 SANDESH_LOG(DEBUG, __func__ <<
" Unknown sandesh:" <<
664 sandesh_name << std::endl);
669 btrans = boost::shared_ptr<TMemoryBuffer>(
671 prot = boost::shared_ptr<TBinaryProtocol>(
new TBinaryProtocol(btrans));
674 SANDESH_LOG(DEBUG, __func__ <<
" Decoding " << sandesh_name <<
" FAILED" <<
680 if (bsnh) bsnh->
Process(client_context);
689 while (xfer < buf_len) {
690 ret = ReceiveBinaryMsgOne(buf + xfer, buf_len - xfer, error,
693 SANDESH_LOG(DEBUG, __func__ <<
"Read sandesh from " << buf_len <<
694 " bytes at offset " << xfer <<
" FAILED (" <<
705 if (IsLoggingDroppedAllowed(
type())) {
706 if (IsConnectToCollectorEnabled()) {
712 UpdateTxMsgFailStats(name_, 0, SandeshTxDropReason::NoClient);
716 if (!client_->SendSandesh(
this)) {
717 if (IsLoggingDroppedAllowed(
type())) {
720 UpdateTxMsgFailStats(name_, 0,
721 SandeshTxDropReason::ClientSendFailed);
733 return SendEnqueue();
738 assert(sconn == NULL);
739 if ((context().find(
"http%") == 0) ||
740 (context().find(
"https%") == 0)) {
744 if (response_callback_) {
745 response_callback_(
this);
751 assert(sconn == NULL);
752 if ((0 == context().find(
"http%")) ||
753 (0 == context().find(
"https%"))) {
761 assert(sconn == NULL);
762 if ((0 == context().find(
"http%")) ||
763 (0 == context().find(
"https%"))) {
768 if (IsSendingAllMessagesDisabled()) {
770 UpdateTxMsgFailStats(Name(), 0,
771 SandeshTxDropReason::SendingDisabled);
781 if (SandeshLevel::SYS_UVE >= SendingLevel()) {
782 client_->CloseSMSession();
784 if (!client_->SendSandeshUVE(
this)) {
786 UpdateTxMsgFailStats(Name(), 0,
787 SandeshTxDropReason::ClientSendFailed);
793 if (IsConnectToCollectorEnabled()) {
798 UpdateTxMsgFailStats(Name(), 0, SandeshTxDropReason::NoClient);
806 UpdateRxMsgFailStats(Name(), 0, SandeshRxDropReason::NoQueue);
818 return level >= SandeshLevel::UT_START &&
819 level <= SandeshLevel::UT_END;
824 const std::string& category) {
827 if (
type == SandeshType::UVE) {
830 bool level_allowed = logging_level_ >= level;
831 bool category_allowed = !logging_category_.empty() ?
832 logging_category_ == category :
true;
833 return level_allowed && category_allowed;
837 if (type_ == SandeshType::FLOW || type_ == SandeshType::SESSION) {
838 return enable_flow_log_;
840 return IsLocalLoggingEnabled() &&
841 IsLevelCategoryLoggingAllowed(type_, level_, category_);
846 if (
type == SandeshType::FLOW ||
type == SandeshType::SESSION) {
847 return enable_flow_log_;
854 std::map<int, const char*>::const_iterator it = _SandeshLevel_VALUES_TO_NAMES.find(level);
855 if (it != _SandeshLevel_VALUES_TO_NAMES.end()) {
863 std::map<int, const char*>::const_iterator it = _SandeshLevel_VALUES_TO_NAMES.begin();
864 while (it != _SandeshLevel_VALUES_TO_NAMES.end()) {
865 if (strncmp(level.c_str(), it->second, strlen(it->second)) == 0) {
875 std::scoped_lock lock(stats_mutex_);
876 msg_stats_.UpdateRecv(msg_name, bytes);
881 std::scoped_lock lock(stats_mutex_);
882 msg_stats_.UpdateRecvFailed(msg_name, bytes, dreason);
887 std::scoped_lock lock(stats_mutex_);
888 msg_stats_.UpdateSend(msg_name, bytes);
893 std::scoped_lock lock(stats_mutex_);
894 msg_stats_.UpdateSendFailed(msg_name, bytes, dreason);
898 std::vector<SandeshMessageTypeStats> *mtype_stats,
899 SandeshMessageStats *magg_stats) {
900 std::scoped_lock lock(stats_mutex_);
901 msg_stats_.Get(mtype_stats, magg_stats);
905 boost::ptr_map<std::string, SandeshMessageTypeStats> *mtype_stats,
906 SandeshMessageStats *magg_stats) {
907 std::scoped_lock lock(stats_mutex_);
908 msg_stats_.Get(mtype_stats, magg_stats);
912 if (send_queue_enabled_ != enable) {
913 SANDESH_LOG(INFO,
"SANDESH: CLIENT: SEND QUEUE: " <<
914 (send_queue_enabled_ ?
"ENABLED" :
"DISABLED") <<
" -> " <<
915 (enable ?
"ENABLED" :
"DISABLED"));
916 send_queue_enabled_ = enable;
918 if (client_ && client_->IsSession()) {
919 client_->session()->send_queue()->MayBeStartRunner();
931 if (stype == SandeshType::SYSTEM ||
932 stype == SandeshType::OBJECT ||
933 stype == SandeshType::FLOW ||
934 stype == SandeshType::SESSION) {
938 if (slevel >= drop_level) {
944 (stype == SandeshType::FLOW || stype == SandeshType::SESSION)) {
951 ModuleContextMap::const_iterator loc = module_context_.find(module_name);
952 if (loc != module_context_.end()) {
960 std::pair<ModuleContextMap::iterator, bool> result =
961 module_context_.insert(std::make_pair(module_name, context));
962 if (!result.second) {
963 result.first->second = context;
968 const std::string& category) {
970 if (IsUnitTest() || IsLevelUT(level)) {
990 size_t sandesh_size = element->
GetSize();
991 return count_.fetch_add(sandesh_size) + sandesh_size;
997 size_t sandesh_size = element->
GetSize();
998 return count_.fetch_sub(sandesh_size) - sandesh_size;
1005 int max_backup_index,
1006 const std::string &syslog_facility,
1007 const std::vector<std::string> &destn,
1008 const std::string &ident,
1009 bool is_sampled_logger) {
1010 log4cplus::Logger logger;
1011 if (is_sampled_logger) {
1016 logger.setAdditivity(
false);
1018 logger.setLogLevel(SandeshLevel::SYS_NOTICE);
1020 if (std::find(destn.begin(), destn.end(),
"file") !=
1023 SharedAppenderPtr fileappender(
new RollingFileAppender(file_name,
1024 max_file_size, max_backup_index));
1025 logger.addAppender(fileappender);
1026 if (is_sampled_logger) {
1033 if (std::find(destn.begin(), destn.end(),
"syslog") !=
1035 helpers::Properties props;
1036 std::string syslogident = boost::str(
1037 boost::format(
"%1%[%2%]") % ident % getpid());
1038 props.setProperty(LOG4CPLUS_TEXT(
"facility"),
1039 boost::starts_with(syslog_facility,
"LOG_")
1040 ? syslog_facility.substr(4)
1042 props.setProperty(LOG4CPLUS_TEXT(
"ident"), syslogident);
1043 props.setProperty(LOG4CPLUS_TEXT(
"additivity"),
"false");
1044 SharedAppenderPtr syslogappender(
new SysLogAppender(props));
1045 std::unique_ptr<Layout> syslog_layout_ptr(
new PatternLayout(
1047 syslogappender->setLayout(std::move(syslog_layout_ptr));
1048 logger.addAppender(syslogappender);
1049 if (is_sampled_logger) {
1058 const std::vector<std::string> &sampled_destn,
1059 const std::vector<std::string> &slo_destn) {
1060 if (std::find(slo_destn.begin(), slo_destn.end(),
"collector") !=
1064 if (std::find(sampled_destn.begin(), sampled_destn.end(),
"collector") !=
1065 sampled_destn.end()) {
IpAddress AddressFromString(const std::string &ip_address_str, boost::system::error_code *ec)
static Sandesh * CreateInstance(std::string const &s)
virtual void Process(SandeshContext *context)=0
void SetDscpValue(uint8_t value)
bool SendSandesh(Sandesh *snh)
static void Response(Sandesh *snh, std::string context)
static bool Init(EventManager *evm, const std::string module, short port, RequestCallbackFn reqcb, int *hport, const SandeshConfig &config=SandeshConfig())
virtual void HandleRequest() const =0
bool Enqueue(SandeshRxQueue *queue)
bool Dispatch(SandeshConnection *sconn=NULL)
SandeshLevel::type SendingLevel() const
bool Dispatch(SandeshConnection *sconn=NULL)
static bool InitDerivedStats(const std::map< std::string, ds_conf_elem > &)
bool Dispatch(SandeshConnection *sconn=NULL)
static bool ConnectToCollector(const std::string &collector_ip, int collector_port, bool periodicuve=false)
static void SetLoggingLevel(std::string level)
static bool IsSendingSystemLogsDisabled()
static void UpdateTxMsgFailStats(const std::string &msg_name, uint64_t bytes, SandeshTxDropReason::type dreason)
static log4cplus::Logger logger_
static void set_module_context(const std::string &module_name, SandeshContext *context)
static bool disable_sending_all_
boost::asio::ip::tcp::endpoint Endpoint
static SandeshLevel::type SendingLevel()
static bool disable_sending_object_logs_
static void InitClient(EventManager *evm, Endpoint server, const SandeshConfig &config, bool periodicuve)
static bool slo_to_logger_
static SandeshLevel::type logging_ut_level_
static bool enable_session_syslog_
static std::unique_ptr< SandeshRxQueue > recv_queue_
virtual int32_t WriteBinary(u_int8_t *buf, u_int32_t buf_len, int *error)
static bool enable_flow_log_
static log4cplus::Logger & sampled_logger()
static int32_t ReceiveBinaryMsgOne(u_int8_t *buf, u_int32_t buf_len, int *error, SandeshContext *client_context)
static EventManager * event_manager_
static void DisableSendingFlows(bool disable)
static std::mutex stats_mutex_
static void ReConfigCollectors(const std::vector< std::string > &collector_list)
static SandeshConfig & config()
static void UpdateRxMsgFailStats(const std::string &msg_name, uint64_t bytes, SandeshRxDropReason::type dreason)
static void set_send_to_collector_flags(const std::vector< std::string > &sampled_destination, const std::vector< std::string > &slo_destination)
static void GetMsgStats(std::vector< SandeshMessageTypeStats > *mtype_stats, SandeshMessageStats *magg_stats)
static bool IsLevelCategoryLoggingAllowed(SandeshType::type type, SandeshLevel::type level, const std::string &category)
static void UpdateTxMsgStats(const std::string &msg_name, uint64_t bytes)
static void SetLocalLogging(bool enable)
static void UpdateRxMsgStats(const std::string &msg_name, uint64_t bytes)
static bool InitGenerator(const std::string &module, const std::string &source, const std::string &node_type, const std::string &instance_id, EventManager *evm, unsigned short http_port, const std::vector< std::string > &collectors, SandeshContext *client_context=NULL, DerivedStats ds=DerivedStats(), const SandeshConfig &config=SandeshConfig())
static ModuleContextMap module_context_
static bool connect_to_collector_
bool Enqueue(SandeshQueue *queue)
static std::string node_type_
static void SetSendQueue(bool enable)
static bool IsFlowCollectionDisabled()
std::map< std::string, std::map< std::string, std::string > > DerivedStats
static bool disable_sending_flows_
static SandeshClient * client()
static SandeshContext * client_context_
static void SetLoggingCategory(std::string category)
static void set_logger_appender(const std::string &file_name, long max_file_size, int max_backup_index, const std::string &syslog_facility, const std::vector< std::string > &destn, const std::string &ident, bool is_sampled_logger)
static const char * SandeshRoleToString(SandeshRole::type role)
static SandeshConfig config_
static bool IsSendingObjectLogsDisabled()
static bool IsSendingAllMessagesDisabled()
virtual int32_t ReadBinary(u_int8_t *buf, u_int32_t buf_len, int *error)
static const char * LevelToString(SandeshLevel::type level)
static bool send_queue_enabled_
static void set_send_rate_limit(int rate_limit)
static uint32_t get_send_rate_limit()
static void DisableFlowCollection(bool disable)
static log4cplus::Logger slo_logger_
static bool HandleTest(SandeshLevel::type level, const std::string &category)
static bool ProcessRecv(SandeshRequest *)
static bool slo_to_collector_
static bool InitCollector(const std::string &module, const std::string &source, const std::string &node_type, const std::string &instance_id, EventManager *evm, const std::string &collector_ip, int collector_port, unsigned short http_port, SandeshContext *client_context=NULL, const SandeshConfig &config=SandeshConfig())
static void RecordPort(const std::string &name, const std::string &module, unsigned short port)
static bool sampled_to_logger_
static void SetDscpValue(uint8_t value)
static SandeshMessageStatistics msg_stats_
static bool IsLoggingDroppedAllowed(SandeshType::type)
bool IsLoggingAllowed() const
static void SetSessionSyslogging(bool enable_session_syslog)
boost::function< void(Sandesh *)> SandeshCallback
static void DisableSendingAllMessages(bool disable)
static SandeshRxQueue * recv_queue()
static SandeshRole::type role_
static SandeshContext * module_context(const std::string &module_name)
static std::string instance_id_
static SandeshCallback response_callback_
static std::atomic< uint32_t > sandesh_send_ratelimit_
static int32_t ReceiveBinaryMsg(u_int8_t *buf, u_int32_t buf_len, int *error, SandeshContext *client_context)
static SandeshLevel::type logging_level_
static SandeshClient * client_
static log4cplus::Logger & slo_logger()
static bool enable_trace_print_
virtual int32_t WriteBinaryToFile(const std::string &path, int *error)
virtual int32_t ReadBinaryFromFile(const std::string &path, int *error)
static void SetFlowLogging(bool enable)
static bool IsSendingFlowsDisabled()
static void SetTracePrint(bool enable)
static void InitReceive(int recv_task_inst=-1)
static bool Initialize(SandeshRole::type role, const std::string &module, const std::string &source, const std::string &node_type, const std::string &instance_id, EventManager *evm, unsigned short http_port, SandeshContext *client_context=NULL, const SandeshConfig &config=SandeshConfig())
std::map< std::string, SandeshContext * > ModuleContextMap
virtual bool SendEnqueue()
static std::string source_
static std::string logging_category_
static bool IsLevelUT(SandeshLevel::type level)
static bool InitGeneratorTest(const std::string &module, const std::string &source, const std::string &node_type, const std::string &instance_id, EventManager *evm, unsigned short http_port, SandeshContext *client_context=NULL, const SandeshConfig &config=SandeshConfig())
static bool enable_local_log_
static bool disable_flow_collection_
static void SetLoggingParams(bool enable_local_log, std::string category, std::string level, bool enable_trace_print=false, bool enable_flow_log=false, bool enable_session_syslog=false)
static log4cplus::Logger sampled_logger_
static std::string module_
static void DisableSendingObjectLogs(bool disable)
virtual bool Dispatch(SandeshConnection *sconn=NULL)
static SandeshLevel::type StringToLevel(std::string level)
static bool sampled_to_collector_
The TaskScheduler keeps track of what tasks are currently schedulable. When a task is enqueued it is ...
int GetTaskId(const std::string &name)
static TaskScheduler * GetInstance()
bool IsEmpty(bool running_only=false)
Returns true if there are no tasks running and/or enqueued If running_only is true,...
static const int kTaskInstanceAny
Specifies value for wildcard (any or *) task data ID.
static void DeleteServer(TcpServer *server)
bool Enqueue(QueueEntryT entry)
size_t AtomicDecrementQueueCount(QueueEntryT *entry)
size_t AtomicIncrementQueueCount(QueueEntryT *entry)
#define SANDESH_LOG(_Level, _Msg)
void SetLoggingLevel(LogLevel logLevel)
TBinaryProtocolT< TTransport > TBinaryProtocol
static string ToString(PhysicalDevice::ManagementProtocol proto)
bool DoDropSandeshMessage(const SandeshHeader &header, const SandeshLevel::type drop_level)
const char * loggingPattern
log4cplus::LogLevel SandeshLevelTolog4Level(SandeshLevel::type slevel)
static int32_t SandeshHttpCallback(SandeshRequest *rsnh)
int PullSandeshGenStatsReq
static void WaitForIdle()
bool MakeEndpoint(TcpServer::Endpoint *ep, const std::string &epstr)
static long GetPendingTaskCount()
uint32_t system_logs_rate_limit