diff options
| author | Paul Buetow <paul@buetow.org> | 2013-04-06 13:14:45 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2013-04-06 13:14:45 +0200 |
| commit | 5f4e214740242513c837c8a005ca23779bab1d0c (patch) | |
| tree | 3880f745b0d3376030e3342e60679f25b38bdc4c /src/monitor | |
| parent | 23c5e7d57e1e9216f4da3446656df2dc7202975d (diff) | |
tagging ychat-0.8.2ychat-0.8.2
Diffstat (limited to 'src/monitor')
| -rw-r--r-- | src/monitor/dump.cpp | 38 | ||||
| -rw-r--r-- | src/monitor/dump.h | 31 | ||||
| -rw-r--r-- | src/monitor/stats.cpp | 48 | ||||
| -rw-r--r-- | src/monitor/stats.h | 13 |
4 files changed, 108 insertions, 22 deletions
diff --git a/src/monitor/dump.cpp b/src/monitor/dump.cpp index 6b49bfe..71cc862 100644 --- a/src/monitor/dump.cpp +++ b/src/monitor/dump.cpp @@ -8,13 +8,13 @@ using namespace std; const string dumpable::s_sep = "->"; const int dumpable::i_max_level = 100; -dumpable::dumpable() +dumpable::dumpable() { initialize(0); } void -dumpable::initialize(int i_level) +dumpable::initialize(int i_level) { this->i_level = i_level; this->i_lined = i_level; @@ -24,13 +24,13 @@ dumpable::initialize(int i_level) } string -dumpable::dump() +dumpable::dump() { return dump(0); } string -dumpable::dump(int i_level) +dumpable::dump(int i_level) { initialize(i_level); dumpit(); @@ -38,34 +38,37 @@ dumpable::dump(int i_level) } void -dumpable::add(string s_line) +dumpable::add + (string s_line) { if ( i_lined > i_max_level ) i_lined = i_max_level; - if (!b_lined) + if (!b_lined) s_dump.append(s_sep); - else for ( int i = 0; i < i_lined; ++i ) - s_dump.append(" "); + else + for ( int i = 0; i < i_lined; ++i ) + s_dump.append(" "); s_dump.append(s_line); - if (b_next_no_nl) + if (b_next_no_nl) b_next_no_nl = false; else s_dump.append("\n"); - if (!b_lined) { + if (!b_lined) + { b_lined = true; i_lined = i_level + s_sep.length(); } } int -dumpable::get_level() const -{ +dumpable::get_level() const +{ return i_lined; } @@ -74,6 +77,7 @@ dump::dump(vector<string> vec_params) if (vec_params.empty()) { cout << CLIPRMO << "all conf sock"; + cout << " chat modl sman"; //<< Not for yhttpd cout << endl; return; } @@ -98,6 +102,16 @@ dump::run(vector<string> &vec_params) if (!s_part.compare("sock") || !s_part.compare("all")) s_ret.append(wrap::SOCK->dump()); + //<<* + if (!s_part.compare("modl") || !s_part.compare("all")) + s_ret.append(wrap::MODL->dump()); + + if (!s_part.compare("sman") || !s_part.compare("all")) + s_ret.append(wrap::SMAN->dump()); + + if (!s_part.compare("chat") || !s_part.compare("all")) + s_ret.append(wrap::CHAT->dump()); + //*>> } return s_ret; diff --git a/src/monitor/dump.h b/src/monitor/dump.h index 8e84cb1..ffb3529 100644 --- a/src/monitor/dump.h +++ b/src/monitor/dump.h @@ -15,24 +15,35 @@ private: string s_dump; static const string s_sep; - static const int i_max_level; + static const int i_max_level; virtual void dumpit() = 0; void initialize(int i_level); void reset(); protected: - void add(unsigned i_num) - { add("<unsigned>"); } - - void add(int i_num) - { add("<int>"); } - - void add(string s_line); + void add + (unsigned i_num) + { + add + ("<unsigned>"); + } + + void add + (int i_num) + { + add + ("<int>"); + } + + void add + (string s_line); dumpable(); - void next_no_newline() - { b_next_no_nl = true; } + void next_no_newline() + { + b_next_no_nl = true; + } public: string dump(); diff --git a/src/monitor/stats.cpp b/src/monitor/stats.cpp index e0aa146..5d5cc39 100644 --- a/src/monitor/stats.cpp +++ b/src/monitor/stats.cpp @@ -10,14 +10,17 @@ stats::stats() i_rusage_vec_size = tool::string2int( wrap::CONF->get_elem("httpd.stats.rusagehistory")); + i_num_rooms = 0; //<< pthread_mutex_init( &mut_vec_rusage, NULL ); + pthread_mutex_init( &mut_num_rooms, NULL ); //<< } stats::~stats() { pthread_mutex_destroy( &mut_vec_rusage ); + pthread_mutex_destroy( &mut_num_rooms ); //<< } void @@ -98,5 +101,50 @@ stats::get_rusage_history( string s_type, string s_seperator ) return s_ret; } +//<<* +int +stats::get_num_rooms() +{ + pthread_mutex_lock ( &mut_num_rooms ); + int i_ret = i_num_rooms; + pthread_mutex_unlock( &mut_num_rooms ); + return i_ret; +} + +void +stats::increment_num_rooms() +{ + pthread_mutex_lock ( &mut_num_rooms ); + ++i_num_rooms; + pthread_mutex_unlock( &mut_num_rooms ); +#ifdef NCURSES + + print_num_rooms(); +#endif +} +void +stats::decrement_num_rooms() +{ + pthread_mutex_lock ( &mut_num_rooms ); + --i_num_rooms; + pthread_mutex_unlock( &mut_num_rooms ); +#ifdef NCURSES + + print_num_rooms(); +#endif +} + +#ifdef NCURSES +void +stats::print_num_rooms() +{ + if ( !wrap::NCUR->is_ready() ) + return; + + mvprintw( NCUR_NUM_ROOMS_X, NCUR_NUM_ROOMS_Y, "Rooms: %d", get_num_rooms()); + refresh(); +} +#endif +//*>> #endif diff --git a/src/monitor/stats.h b/src/monitor/stats.h index 0478258..231d876 100644 --- a/src/monitor/stats.h +++ b/src/monitor/stats.h @@ -21,6 +21,8 @@ private: vector< map<string,long> > vec_rusage_history; pthread_mutex_t mut_vec_rusage; + int i_num_rooms; //<< + pthread_mutex_t mut_num_rooms; //<< void set_rusage_vec_size( int i_rusage_vec_size ); @@ -28,9 +30,20 @@ public: stats( ); ~stats( ); + //<<* + int get_num_rooms(); + void increment_num_rooms(); + void decrement_num_rooms(); + //*>> void update_rusage_history(); string get_rusage_history( string s_type, string s_seperator ); long get_ru_maxrss(); + //<<* +#ifdef NCURSES + + void print_num_rooms(); +#endif + //*>> }; #endif |
