11 #include <boost/filesystem.hpp>
12 #include <boost/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;
49 using namespace contrail::sandesh::protocol;
50 using namespace contrail::sandesh::transport;
51 using namespace log4cplus;
82 getenv(
"SANDSH_UT_DEBUG") ? SandeshLevel::SYS_DEBUG : SandeshLevel::UT_DEBUG;
88 log4cplus::Logger::getInstance(LOG4CPLUS_TEXT(
"SANDESH"));
90 log4cplus::Logger::getInstance(LOG4CPLUS_TEXT(
"SLO_SESSION"));
92 log4cplus::Logger::getInstance(LOG4CPLUS_TEXT(
"SAMPLED_SESSION"));
98 " %h [Thread %t, Pid %i]: %m%n";
102 case SandeshRole::Generator:
104 case SandeshRole::Collector:
106 case SandeshRole::Test:
108 case SandeshRole::Invalid:
116 assert(recv_task_id_ == -1);
118 recv_task_id_ = scheduler->
GetTaskId(
"sandesh::RecvQueue");
119 recv_queue_.reset(
new SandeshRxQueue(recv_task_id_, recv_task_inst,
125 connect_to_collector_ =
true;
126 SANDESH_LOG(INFO,
"SANDESH: CONNECT TO COLLECTOR: " <<
127 connect_to_collector_);
129 assert(client_ == NULL);
130 std::vector<Endpoint> collector_endpoints = boost::assign::list_of(server);
131 client_ =
new SandeshClient(evm, collector_endpoints, config,
145 const std::string &module,
146 const std::string &source,
147 const std::string &node_type,
148 const std::string &instance_id,
150 unsigned short http_port,
157 if (role_ != SandeshRole::Invalid || role == SandeshRole::Invalid) {
161 SANDESH_LOG(INFO,
"SANDESH: ROLE : " << SandeshRoleToString(role));
164 SANDESH_LOG(INFO,
"SANDESH: NODE TYPE : " << node_type);
165 SANDESH_LOG(INFO,
"SANDESH: INSTANCE ID : " << instance_id);
166 SANDESH_LOG(INFO,
"SANDESH: HTTP SERVER PORT : " << http_port);
171 node_type_ = node_type;
172 instance_id_ = instance_id;
173 client_context_ = client_context;
175 event_manager_ =
evm;
183 SANDESH_LOG(ERROR,
"SANDESH: HTTP INIT FAILED (PORT " <<
187 RecordPort(
"http", module_, http_port_);
193 std::ostringstream myfifoss;
194 myfifoss <<
"/tmp/" << module <<
"." << getppid() <<
"." << name <<
"_port";
195 std::string myfifo = myfifoss.str();
196 std::ostringstream hss;
198 std::string hstr = hss.str();
200 fd = open(myfifo.c_str(), O_WRONLY | O_NONBLOCK);
202 SANDESH_LOG(INFO,
"SANDESH: Write " << name <<
"_port " << port <<
204 write(fd, hstr.c_str(), hstr.length());
207 SANDESH_LOG(INFO,
"SANDESH: NOT Writing " << name <<
"_port " << port <<
213 int collector_port,
bool periodicuve) {
214 boost::system::error_code ec;
217 SANDESH_LOG(ERROR, __func__ <<
": Invalid collector address: " <<
218 collector_ip <<
" Error: " << ec);
222 SANDESH_LOG(INFO,
"SANDESH: COLLECTOR : " << collector_ip);
223 SANDESH_LOG(INFO,
"SANDESH: COLLECTOR PORT : " << collector_port);
225 tcp::endpoint collector(collector_addr, collector_port);
232 client_->ReConfigCollectors(collector_list);
237 const std::vector<std::string> &collectors,
239 connect_to_collector_ =
true;
240 SANDESH_LOG(INFO,
"SANDESH: CONNECT TO COLLECTOR: " <<
241 connect_to_collector_);
242 std::vector<Endpoint> collector_endpoints;
243 BOOST_FOREACH(
const std::string &collector, collectors) {
246 SANDESH_LOG(ERROR, __func__ <<
": Invalid collector address: " <<
250 collector_endpoints.push_back(ep);
252 client_ =
new SandeshClient(evm, collector_endpoints, config,
true);
258 const std::string &source,
259 const std::string &node_type,
260 const std::string &instance_id,
262 unsigned short http_port,
267 return Initialize(SandeshRole::Generator, module, source, node_type,
268 instance_id, evm, http_port, client_context, config);
272 const std::string &source,
273 const std::string &node_type,
274 const std::string &instance_id,
276 unsigned short http_port,
277 const std::vector<std::string> &collectors,
282 bool success(Initialize(SandeshRole::Generator, module, source, node_type,
283 instance_id, evm, http_port, client_context,
288 return InitClient(evm, collectors, config);
293 const std::string &source,
294 const std::string &node_type,
295 const std::string &instance_id,
297 const std::string &collector_ip,
int collector_port,
298 unsigned short http_port,
301 bool success(Initialize(SandeshRole::Collector, module, source, node_type,
302 instance_id, evm, http_port, client_context,
307 return ConnectToCollector(collector_ip, collector_port,
true);
311 const std::string &source,
312 const std::string &node_type,
313 const std::string &instance_id,
315 unsigned short http_port,
318 return Initialize(SandeshRole::Test, module, source, node_type,
319 instance_id, evm, http_port, client_context, config);
323 static const int kTimeout = 15;
326 for (
int i = 0; i < (kTimeout * 1000); i++) {
350 role_ = SandeshRole::Invalid;
351 if (recv_queue_.get() != NULL) {
352 recv_queue_->Shutdown();
353 recv_queue_.reset(NULL);
354 assert(recv_task_id_ != -1);
357 assert(recv_task_id_ == -1);
359 if (client_ != NULL) {
361 while (client()->IsSession()) usleep(100);
363 client_->ClearSessions();
370 std::string level,
bool enable_trace_print,
bool enable_flow_log,
371 bool enable_session_syslog) {
372 SetLocalLogging(enable_local_log);
373 SetLoggingCategory(category);
375 SetTracePrint(enable_trace_print);
376 SetFlowLogging(enable_flow_log);
377 SetSessionSyslogging(enable_session_syslog);
382 bool enable_flow_log) {
383 SetLocalLogging(enable_local_log);
384 SetLoggingCategory(category);
386 SetTracePrint(enable_trace_print);
387 SetFlowLogging(enable_flow_log);
398 case SandeshLevel::SYS_EMERG:
399 case SandeshLevel::SYS_ALERT:
400 case SandeshLevel::SYS_CRIT:
401 return log4cplus::FATAL_LOG_LEVEL;
402 case SandeshLevel::SYS_ERR:
403 return log4cplus::ERROR_LOG_LEVEL;
404 case SandeshLevel::SYS_WARN:
405 case SandeshLevel::SYS_NOTICE:
406 return log4cplus::WARN_LOG_LEVEL;
407 case SandeshLevel::SYS_INFO:
408 return log4cplus::INFO_LOG_LEVEL;
409 case SandeshLevel::SYS_DEBUG:
410 return log4cplus::DEBUG_LOG_LEVEL;
413 return log4cplus::ALL_LOG_LEVEL;
419 log4cplus::LogLevel log4_old_level(logger_.getLogLevel());
420 if (logging_level_ != level ||
421 log4_old_level != log4_new_level) {
422 const log4cplus::LogLevelManager &log4level_manager(
423 log4cplus::getLogLevelManager());
424 SANDESH_LOG(INFO,
"SANDESH: Logging: LEVEL: " <<
"[ " <<
425 LevelToString(logging_level_) <<
" ] -> [ " <<
426 LevelToString(level) <<
" ] log4level: [ " <<
427 log4level_manager.toString(log4_old_level) <<
429 log4level_manager.toString(log4_new_level) <<
431 logging_level_ = level;
432 logger_.setLogLevel(log4_new_level);
439 if (logging_category_ != category) {
440 SANDESH_LOG(INFO,
"SANDESH: Logging: CATEGORY: " <<
441 (logging_category_.empty() ?
"*" : logging_category_) <<
" -> " <<
442 (category.empty() ?
"*" : category));
443 logging_category_ = category;
448 if (enable_local_log_ != enable_local_log) {
450 (enable_local_log_ ?
"ENABLED" :
"DISABLED") <<
" -> " <<
451 (enable_local_log ?
"ENABLED" :
"DISABLED"));
452 enable_local_log_ = enable_local_log;
457 if (enable_trace_print_ != enable_trace_print) {
459 (enable_trace_print_ ?
"ENABLED" :
"DISABLED") <<
" -> " <<
460 (enable_trace_print ?
"ENABLED" :
"DISABLED"));
461 enable_trace_print_ = enable_trace_print;
466 if (enable_flow_log_ != enable_flow_log) {
468 (enable_flow_log_ ?
"ENABLED" :
"DISABLED") <<
" -> " <<
469 (enable_flow_log ?
"ENABLED" :
"DISABLED"));
470 enable_flow_log_ = enable_flow_log;
475 if (enable_session_syslog_ != enable_session_syslog) {
477 (enable_session_syslog_ ?
"ENABLED" :
"DISABLED") <<
" -> " <<
478 (enable_session_syslog ?
"ENABLED" :
"DISABLED"));
479 enable_session_syslog_ = enable_session_syslog;
485 if (disable_flow_collection_ != disable) {
486 SANDESH_LOG(INFO,
"SANDESH: Disable Flow Collection: " <<
487 disable_flow_collection_ <<
" -> " << disable);
488 disable_flow_collection_ = disable;
493 if (disable_sending_all_ != disable) {
494 SANDESH_LOG(INFO,
"SANDESH: Disable Sending ALL Messages: " <<
495 disable_sending_all_ <<
" -> " << disable);
496 disable_sending_all_ = disable;
501 return disable_sending_all_;
505 if (disable_sending_object_logs_ != disable) {
506 SANDESH_LOG(INFO,
"SANDESH: Disable Sending Object Logs: " <<
507 disable_sending_object_logs_ <<
" -> " << disable);
508 disable_sending_object_logs_ = disable;
513 return disable_sending_object_logs_;
517 if (disable_sending_flows_ != disable) {
518 SANDESH_LOG(INFO,
"SANDESH: Disable Sending Flows: " <<
519 disable_sending_flows_ <<
" -> " << disable);
520 disable_sending_flows_ = disable;
525 return disable_sending_flows_;
529 return sandesh_send_ratelimit_ == 0;
533 if (rate_limit >= 0) {
534 SANDESH_LOG(INFO,
"SANDESH: System Log Send Rate Limit: " <<
535 sandesh_send_ratelimit_ <<
" -> " << rate_limit);
536 sandesh_send_ratelimit_ = rate_limit;
541 return sandesh_send_ratelimit_;
546 if (IsLoggingDroppedAllowed(
type())) {
547 SANDESH_LOG(ERROR, __func__ <<
": SandeshQueue NULL : Dropping Message: "
550 UpdateTxMsgFailStats(name_, 0, SandeshTxDropReason::NoQueue);
574 boost::shared_ptr<TMemoryBuffer> btrans =
575 boost::shared_ptr<TMemoryBuffer>(
577 btrans->setWriteBuffer(buf, buf_len);
578 boost::shared_ptr<TBinaryProtocol> prot =
582 SANDESH_LOG(DEBUG, __func__ <<
"Write sandesh to " << buf_len <<
583 " bytes FAILED" << std::endl);
593 boost::shared_ptr<TMemoryBuffer> btrans =
594 boost::shared_ptr<TMemoryBuffer>(
596 boost::shared_ptr<TBinaryProtocol> prot =
600 SANDESH_LOG(DEBUG, __func__ <<
"Read sandesh from " << buf_len <<
601 " bytes FAILED" << std::endl);
610 boost::shared_ptr<TSimpleFileTransport> btrans =
611 boost::shared_ptr<TSimpleFileTransport>(
613 boost::shared_ptr<TBinaryProtocol> prot =
617 SANDESH_LOG(DEBUG, __func__ <<
"Write sandesh to file FAILED"
627 boost::shared_ptr<TSimpleFileTransport> btrans =
628 boost::shared_ptr<TSimpleFileTransport>(
630 boost::shared_ptr<TBinaryProtocol> prot =
634 SANDESH_LOG(DEBUG, __func__ <<
"Read sandesh from file FAILED"
645 std::string sandesh_name;
646 boost::shared_ptr<TMemoryBuffer> btrans =
647 boost::shared_ptr<TMemoryBuffer>(
649 boost::shared_ptr<TBinaryProtocol> prot =
652 xfer = prot->readSandeshBegin(sandesh_name);
654 SANDESH_LOG(DEBUG, __func__ <<
"Read sandesh begin from " << buf_len <<
655 " bytes FAILED" << std::endl);
661 if (sandesh == NULL) {
662 SANDESH_LOG(DEBUG, __func__ <<
" Unknown sandesh:" <<
663 sandesh_name << std::endl);
668 btrans = boost::shared_ptr<TMemoryBuffer>(
670 prot = boost::shared_ptr<TBinaryProtocol>(
new TBinaryProtocol(btrans));
671 xfer = sandesh->
Read(prot);
673 SANDESH_LOG(DEBUG, __func__ <<
" Decoding " << sandesh_name <<
" FAILED" <<
679 if (bsnh) bsnh->
Process(client_context);
688 while (xfer < buf_len) {
689 ret = ReceiveBinaryMsgOne(buf + xfer, buf_len - xfer, error,
692 SANDESH_LOG(DEBUG, __func__ <<
"Read sandesh from " << buf_len <<
693 " bytes at offset " << xfer <<
" FAILED (" <<
704 if (IsLoggingDroppedAllowed(
type())) {
705 if (IsConnectToCollectorEnabled()) {
711 UpdateTxMsgFailStats(name_, 0, SandeshTxDropReason::NoClient);
715 if (!client_->SendSandesh(
this)) {
716 if (IsLoggingDroppedAllowed(
type())) {
719 UpdateTxMsgFailStats(name_, 0,
720 SandeshTxDropReason::ClientSendFailed);
732 return SendEnqueue();
737 assert(sconn == NULL);
738 if ((context().find(
"http%") == 0) ||
739 (context().find(
"https%") == 0)) {
743 if (response_callback_) {
744 response_callback_(
this);
750 assert(sconn == NULL);
751 if ((0 == context().find(
"http%")) ||
752 (0 == context().find(
"https%"))) {
760 assert(sconn == NULL);
761 if ((0 == context().find(
"http%")) ||
762 (0 == context().find(
"https%"))) {
767 if (IsSendingAllMessagesDisabled()) {
769 UpdateTxMsgFailStats(Name(), 0,
770 SandeshTxDropReason::SendingDisabled);
780 if (SandeshLevel::SYS_UVE >= SendingLevel()) {
781 client_->CloseSMSession();
783 if (!client_->SendSandeshUVE(
this)) {
785 UpdateTxMsgFailStats(Name(), 0,
786 SandeshTxDropReason::ClientSendFailed);
792 if (IsConnectToCollectorEnabled()) {
797 UpdateTxMsgFailStats(Name(), 0, SandeshTxDropReason::NoClient);
805 UpdateRxMsgFailStats(Name(), 0, SandeshRxDropReason::NoQueue);
817 return level >= SandeshLevel::UT_START &&
818 level <= SandeshLevel::UT_END;
823 const std::string& category) {
826 if (type == SandeshType::UVE) {
829 bool level_allowed = logging_level_ >= level;
830 bool category_allowed = !logging_category_.empty() ?
831 logging_category_ == category :
true;
832 return level_allowed && category_allowed;
836 if (type_ == SandeshType::FLOW || type_ == SandeshType::SESSION) {
837 return enable_flow_log_;
839 return IsLocalLoggingEnabled() &&
840 IsLevelCategoryLoggingAllowed(type_, level_, category_);
845 if (type == SandeshType::FLOW || type == SandeshType::SESSION) {
846 return enable_flow_log_;
853 std::map<int, const char*>::const_iterator it = _SandeshLevel_VALUES_TO_NAMES.find(level);
854 if (it != _SandeshLevel_VALUES_TO_NAMES.end()) {
862 std::map<int, const char*>::const_iterator it = _SandeshLevel_VALUES_TO_NAMES.begin();
863 while (it != _SandeshLevel_VALUES_TO_NAMES.end()) {
864 if (strncmp(level.c_str(), it->second, strlen(it->second)) == 0) {
874 tbb::mutex::scoped_lock lock(stats_mutex_);
875 msg_stats_.UpdateRecv(msg_name, bytes);
880 tbb::mutex::scoped_lock lock(stats_mutex_);
881 msg_stats_.UpdateRecvFailed(msg_name, bytes, dreason);
886 tbb::mutex::scoped_lock lock(stats_mutex_);
887 msg_stats_.UpdateSend(msg_name, bytes);
892 tbb::mutex::scoped_lock lock(stats_mutex_);
893 msg_stats_.UpdateSendFailed(msg_name, bytes, dreason);
897 std::vector<SandeshMessageTypeStats> *mtype_stats,
898 SandeshMessageStats *magg_stats) {
899 tbb::mutex::scoped_lock lock(stats_mutex_);
900 msg_stats_.Get(mtype_stats, magg_stats);
904 boost::ptr_map<std::string, SandeshMessageTypeStats> *mtype_stats,
905 SandeshMessageStats *magg_stats) {
906 tbb::mutex::scoped_lock lock(stats_mutex_);
907 msg_stats_.Get(mtype_stats, magg_stats);
911 if (send_queue_enabled_ != enable) {
912 SANDESH_LOG(INFO,
"SANDESH: CLIENT: SEND QUEUE: " <<
913 (send_queue_enabled_ ?
"ENABLED" :
"DISABLED") <<
" -> " <<
914 (enable ?
"ENABLED" :
"DISABLED"));
915 send_queue_enabled_ = enable;
917 if (client_ && client_->IsSession()) {
918 client_->session()->send_queue()->MayBeStartRunner();
930 if (stype == SandeshType::SYSTEM ||
931 stype == SandeshType::OBJECT ||
932 stype == SandeshType::FLOW ||
933 stype == SandeshType::SESSION) {
936 static_cast<SandeshLevel::type>(header.get_Level()));
937 if (slevel >= drop_level) {
943 (stype == SandeshType::FLOW || stype == SandeshType::SESSION)) {
950 ModuleContextMap::const_iterator loc = module_context_.find(module_name);
951 if (loc != module_context_.end()) {
959 std::pair<ModuleContextMap::iterator, bool> result =
960 module_context_.insert(std::make_pair(module_name, context));
961 if (!result.second) {
962 result.first->second = context;
967 const std::string& category) {
969 if (IsUnitTest() || IsLevelUT(level)) {
989 size_t sandesh_size = element->
GetSize();
990 return count_.fetch_and_add(sandesh_size) + sandesh_size;
996 size_t sandesh_size = element->
GetSize();
997 return count_.fetch_and_add((
size_t)(0-sandesh_size)) - sandesh_size;
1004 int max_backup_index,
1005 const std::string &syslog_facility,
1006 const std::vector<std::string> &destn,
1007 const std::string &ident,
1008 bool is_sampled_logger) {
1009 log4cplus::Logger logger;
1010 if (is_sampled_logger) {
1015 logger.setAdditivity(
false);
1017 logger.setLogLevel(SandeshLevel::SYS_NOTICE);
1019 if (std::find(destn.begin(), destn.end(),
"file") !=
1022 SharedAppenderPtr fileappender(
new RollingFileAppender(file_name,
1023 max_file_size, max_backup_index));
1024 logger.addAppender(fileappender);
1025 if (is_sampled_logger) {
1032 if (std::find(destn.begin(), destn.end(),
"syslog") !=
1034 helpers::Properties props;
1035 std::string syslogident = boost::str(
1036 boost::format(
"%1%[%2%]") % ident % getpid());
1037 props.setProperty(LOG4CPLUS_TEXT(
"facility"),
1038 boost::starts_with(syslog_facility,
"LOG_")
1039 ? syslog_facility.substr(4)
1041 props.setProperty(LOG4CPLUS_TEXT(
"ident"), syslogident);
1042 props.setProperty(LOG4CPLUS_TEXT(
"additivity"),
"false");
1043 SharedAppenderPtr syslogappender(
new SysLogAppender(props));
1044 std::unique_ptr<Layout> syslog_layout_ptr(
new PatternLayout(
1046 syslogappender->setLayout(std::move(syslog_layout_ptr));
1047 logger.addAppender(syslogappender);
1048 if (is_sampled_logger) {
1057 const std::vector<std::string> &sampled_destn,
1058 const std::vector<std::string> &slo_destn) {
1059 if (std::find(slo_destn.begin(), slo_destn.end(),
"collector") !=
1063 if (std::find(sampled_destn.begin(), sampled_destn.end(),
"collector") !=
1064 sampled_destn.end()) {
bool MakeEndpoint(TcpServer::Endpoint *ep, const std::string &epstr)
boost::asio::ip::tcp::endpoint Endpoint
log4cplus::LogLevel SandeshLevelTolog4Level(SandeshLevel::type slevel)
static void InitClient(EventManager *evm, Endpoint server, const SandeshConfig &config, bool periodicuve)
static SandeshContext * module_context(const std::string &module_name)
static bool disable_sending_object_logs_
static std::string instance_id_
The TaskScheduler keeps track of what tasks are currently schedulable. When a task is enqueued it is ...
static bool sampled_to_collector_
uint32_t system_logs_rate_limit
static void WaitForIdle()
static SandeshRole::type role_
static SandeshLevel::type StringToLevel(std::string level)
bool Dispatch(SandeshConnection *sconn=NULL)
static void InitReceive(int recv_task_inst=-1)
static SandeshLevel::type SendingLevel()
static bool InitDerivedStats(const std::map< std::string, ds_conf_elem > &)
static const int kTaskInstanceAny
virtual int32_t WriteBinary(u_int8_t *buf, u_int32_t buf_len, int *error)
virtual void HandleRequest() const =0
static void ReConfigCollectors(const std::vector< std::string > &collector_list)
static Sandesh * CreateInstance(std::string const &s)
int PullSandeshGenStatsReq
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 bool HandleTest(SandeshLevel::type level, const std::string &category)
static tbb::atomic< long > GetPendingTaskCount()
static void SetSendQueue(bool enable)
static void set_send_rate_limit(int rate_limit)
static bool enable_trace_print_
const char * loggingPattern
static std::unique_ptr< SandeshRxQueue > recv_queue_
std::map< std::string, SandeshContext * > ModuleContextMap
virtual int32_t ReadBinaryFromFile(const std::string &path, int *error)
static const char * SandeshRoleToString(SandeshRole::type role)
static void SetDscpValue(uint8_t value)
static log4cplus::Logger sampled_logger_
#define SANDESH_LOG(_Level, _Msg)
static log4cplus::Logger & sampled_logger()
std::map< std::string, std::map< std::string, std::string > > DerivedStats
static void UpdateRxMsgStats(const std::string &msg_name, uint64_t bytes)
void SetDscpValue(uint8_t value)
static void SetLoggingCategory(std::string category)
static bool ProcessRecv(SandeshRequest *)
static bool ConnectToCollector(const std::string &collector_ip, int collector_port, bool periodicuve=false)
int GetTaskId(const std::string &name)
SandeshLevel::type SendingLevel() const
static void DisableSendingObjectLogs(bool disable)
static tbb::mutex stats_mutex_
static void UpdateRxMsgFailStats(const std::string &msg_name, uint64_t bytes, SandeshRxDropReason::type dreason)
static log4cplus::Logger & slo_logger()
static void UpdateTxMsgStats(const std::string &msg_name, uint64_t bytes)
boost::function< void(Sandesh *)> SandeshCallback
static string ToString(PhysicalDevice::ManagementProtocol proto)
static SandeshLevel::type logging_ut_level_
bool Enqueue(SandeshRxQueue *queue)
static void SetLocalLogging(bool enable)
static tbb::atomic< uint32_t > sandesh_send_ratelimit_
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 bool disable_sending_flows_
static void UpdateTxMsgFailStats(const std::string &msg_name, uint64_t bytes, SandeshTxDropReason::type dreason)
static bool IsSendingObjectLogsDisabled()
static bool disable_flow_collection_
static const char * LevelToString(SandeshLevel::type level)
static void SetSessionSyslogging(bool enable_session_syslog)
static void SetLoggingLevel(std::string level)
static std::string node_type_
virtual int32_t Read(boost::shared_ptr< contrail::sandesh::protocol::TProtocol > iprot)=0
static SandeshLevel::type logging_level_
static TaskScheduler * GetInstance()
bool Dispatch(SandeshConnection *sconn=NULL)
static bool enable_flow_log_
static std::string module_
static bool enable_session_syslog_
static bool send_queue_enabled_
static log4cplus::Logger slo_logger_
static bool IsFlowCollectionDisabled()
bool IsLoggingAllowed() const
bool DoDropSandeshMessage(const SandeshHeader &header, const SandeshLevel::type drop_level)
static SandeshClient * client_
static int32_t ReceiveBinaryMsgOne(u_int8_t *buf, u_int32_t buf_len, int *error, SandeshContext *client_context)
static SandeshConfig config_
static SandeshClient * client()
virtual bool SendEnqueue()
static std::string logging_category_
TBinaryProtocolT< TTransport > TBinaryProtocol
bool IsEmpty(bool running_only=false)
Returns true if there are no tasks running and/or enqueued If running_only is true, enqueued tasks are ignored i.e. return true if there are no running tasks. Ignore TaskGroup or TaskEntry if it is disabled.
static void DeleteServer(TcpServer *server)
static log4cplus::Logger logger_
static int32_t ReceiveBinaryMsg(u_int8_t *buf, u_int32_t buf_len, int *error, SandeshContext *client_context)
static bool IsSendingSystemLogsDisabled()
static void set_module_context(const std::string &module_name, SandeshContext *context)
static bool connect_to_collector_
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())
size_t AtomicIncrementQueueCount(QueueEntryT *entry)
static bool IsSendingAllMessagesDisabled()
IpAddress AddressFromString(const std::string &ip_address_str, boost::system::error_code *ec)
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())
size_t AtomicDecrementQueueCount(QueueEntryT *entry)
virtual int32_t ReadBinary(u_int8_t *buf, u_int32_t buf_len, int *error)
static bool enable_local_log_
static uint32_t get_send_rate_limit()
static int32_t SandeshHttpCallback(SandeshRequest *rsnh)
static SandeshRxQueue * recv_queue()
bool Dispatch(SandeshConnection *sconn=NULL)
static bool IsLoggingDroppedAllowed(SandeshType::type)
static bool disable_sending_all_
static SandeshCallback response_callback_
static bool IsLevelUT(SandeshLevel::type level)
static void DisableFlowCollection(bool disable)
static void SetFlowLogging(bool enable)
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 SandeshMessageStatistics msg_stats_
static bool Init(EventManager *evm, const std::string module, short port, RequestCallbackFn reqcb, int *hport, const SandeshConfig &config=SandeshConfig())
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())
virtual bool Dispatch(SandeshConnection *sconn=NULL)
static void RecordPort(const std::string &name, const std::string &module, unsigned short port)
static bool sampled_to_logger_
static bool slo_to_collector_
void SetLoggingLevel(LogLevel logLevel)
static std::string source_
static void Response(Sandesh *snh, std::string context)
static void DisableSendingAllMessages(bool disable)
static EventManager * event_manager_
static void GetMsgStats(std::vector< SandeshMessageTypeStats > *mtype_stats, SandeshMessageStats *magg_stats)
bool Enqueue(QueueEntryT entry)
static SandeshContext * client_context_
bool SendSandesh(Sandesh *snh)
static bool IsSendingFlowsDisabled()
static bool slo_to_logger_
static bool IsLevelCategoryLoggingAllowed(SandeshType::type type, SandeshLevel::type level, const std::string &category)
static void DisableSendingFlows(bool disable)
static void set_send_to_collector_flags(const std::vector< std::string > &sampled_destination, const std::vector< std::string > &slo_destination)
static void SetTracePrint(bool enable)
static ModuleContextMap module_context_
virtual int32_t WriteBinaryToFile(const std::string &path, int *error)
virtual void Process(SandeshContext *context)=0
static SandeshConfig & config()
bool Enqueue(SandeshQueue *queue)