23 #include <blackboard/bbconfig.h>
24 #include <blackboard/internal/memory_manager.h>
25 #include <blackboard/internal/interface_mem_header.h>
26 #include <blackboard/exceptions.h>
27 #include <utils/system/console_colors.h>
28 #include <utils/time/time.h>
29 #include <config/sqlite.h>
35 using namespace fawkes;
38 main(
int argc,
char **argv)
43 std::string token =
"";
45 token = config.
get_string(
"/fawkes/mainapp/blackboard_magic_token");
47 cout <<
"Could not read shared memory token for blackboard." << endl;
48 cout <<
"BlackBoard is probably running without shared memory." << endl;
59 cout <<
"No BlackBoard shared memory segment found!" << endl;
63 cout << endl << cblue <<
"Fawkes BlackBoard Memory Info" << cnormal << endl
64 <<
"========================================================================" << endl;
66 printf(
"Memory Size: %s%8u%s %sB%s BlackBoard version: %s%u%s\n"
67 "Free Memory: %s%8u%s %sB%s Alloc. memory: %s%8u%s %sB%s Overhang: %s%8u%s %sB%s\n"
68 "Free Chunks: %s%8u%s Alloc. chunks: %s%8u%s\n",
69 cdarkgray.c_str(), memmgr->
memory_size(), cnormal.c_str(),
70 clightgray.c_str(), cnormal.c_str(),
71 cdarkgray.c_str(), memmgr->
version(), cnormal.c_str(),
72 cdarkgray.c_str(), memmgr->
free_size(), cnormal.c_str(),
73 clightgray.c_str(), cnormal.c_str(),
75 clightgray.c_str(), cnormal.c_str(),
77 clightgray.c_str(), cnormal.c_str(),
83 gettimeofday(&a, NULL);
84 cout <<
"Waiting for lock on shared memory.. " << flush;
86 gettimeofday(&b, NULL);
87 cout <<
"lock aquired. Waited " <<
time_diff_sec(b, a) <<
" seconds" << endl;
90 if ( memmgr->
begin() == memmgr->
end() ) {
91 cout <<
"No interfaces allocated." << endl;
93 cout << endl <<
"Interfaces:" << endl;
95 printf(
"%sMemSize Overhang Type/ID/Hash Serial Ref W/R%s\n"
96 "------------------------------------------------------------------------\n",
97 cdarkgray.c_str(), cnormal.c_str());
101 for ( cit = memmgr->
begin(); cit != memmgr->
end(); ++cit ) {
102 if ( *cit == NULL ) {
103 cout <<
"*cit == NULL" << endl;
107 char tmp_hash[__INTERFACE_HASH_SIZE * 2 + 1];
108 for (
size_t s = 0; s < __INTERFACE_HASH_SIZE; ++s) {
109 snprintf(&tmp_hash[s*2], 3,
"%02X", ih->hash[s]);
111 printf(
"%7u %8u %sT%s %-32s %6u %3u %1d/%-3d\n%18s %sI%s %-32s\n%18s %sH%s %-32s\n",
112 cit.
size(), cit.
overhang(), clightgray.c_str(), cnormal.c_str(), ih->type,
113 ih->serial, ih->refcount, ih->flag_writer_active, ih->num_readers,
114 "", clightgray.c_str(), cnormal.c_str(), ih->id,
115 "", clightgray.c_str(), cnormal.c_str(), tmp_hash);