9 m_stop(boost::posix_time::neg_infin),
14 m_stop = boost::posix_time::microsec_clock::universal_time();
15 m_status = commit_status;
19 m_connectionString( connectionString ),
21 m_stop(boost::posix_time::neg_infin),
22 m_currentTransaction(0),
28 for(std::map<std::string,TransactionMonitoringData*>::const_iterator iT = m_transactions.begin();
29 iT != m_transactions.end();iT++ ){
36 m_transactions.insert(std::make_pair(
guidFromTime(),m_currentTransaction));
37 m_ncur = m_transactions.size();
43 if(m_currentTransaction){
44 m_currentTransaction->stop( commit_status );
45 m_currentTransaction = 0;
53 m_stop = boost::posix_time::microsec_clock::universal_time();
54 m_currentTransaction = 0;
59 return m_transactions.size();
64 for(std::map<std::string,TransactionMonitoringData*>::const_iterator iT = m_transactions.begin();
65 iT != m_transactions.end();iT++ ){
67 boost::posix_time::time_duration duration;
68 if( !data.
m_stop.is_neg_infinity() ){
71 out <<
" -> Transaction #"<<i<<
" duration="<<boost::posix_time::to_simple_string(duration)<<
" status="<<(data.
m_status?std::string(
"COMMIT"):std::string(
"ROLLBACK"))<<std::endl;
85 const char* envVar = ::getenv(
"ORA_MONITORING_LEVEL" );
86 if( envVar && ::strcmp(envVar,
"SESSION")==0 ) s_enabled =
true;
96 static std::string s_outFileName(
"");
97 if( s_outFileName.empty() ){
98 const char* fileEnvVar = ::getenv(
"ORA_MONITORING_FILE" );
100 s_outFileName = fileEnvVar;
103 return s_outFileName;
109 if( !outFileName().
empty() ){
111 outFile.open( outFileName().c_str() );
122 std::cout <<
"ORA_MONITORING Error: "<<e.what()<<std::endl;
126 for(std::map<std::string,SessionMonitoringData*>::const_iterator iS = m_sessions.begin();
127 iS != m_sessions.end();iS++ ){
139 out <<
"### ---------------------------------------------------------------------- "<<std::endl;
140 out <<
"### ORA Monitoring Summary "<<std::endl;
141 out <<
"### "<<m_sessions.size()<<
" session(s) registered."<<std::endl;
143 for( std::map<std::string,SessionMonitoringData*>::const_iterator iS = m_sessions.begin();
144 iS != m_sessions.end(); ++iS ){
146 boost::posix_time::time_duration duration;
147 if( !data.
m_stop.is_neg_infinity() ){
150 out <<
" -> Session #"<<j<<
": connection=\""<<data.
m_connectionString<<
"\" duration="<<boost::posix_time::to_simple_string(duration)<<
" transactions="<<(iS->second)->numberOfTransactions()<<std::endl;
151 (iS->second)->
report(out);
154 out <<
"### ---------------------------------------------------------------------- "<<std::endl;
TransactionMonitoringData(boost::posix_time::ptime start)
size_t stopTransaction(bool commit_status=true)
boost::posix_time::ptime m_stop
static Monitoring & get()
std::string m_connectionString
static std::string & outFileName()
SessionMonitoringData * startSession(const std::string &connectionString)
void report(std::ostream &out) const
boost::posix_time::ptime m_stop
SessionMonitoringData(boost::posix_time::ptime start, const std::string &connectionString)
void report(std::ostream &out)
boost::posix_time::ptime m_start
void stop(bool commit_status=true)
size_t numberOfTransactions() const
char data[epos_bytes_allocation]
boost::posix_time::ptime m_start
std::string guidFromTime()